@Tool

Checked against FrontMCP 1.12.2 on

@Tool declares an MCP tool: a function an AI model can decide to call. FrontMCP checks every call against the tool's input schema before your code runs.

@Tool(options)
class MyTool extends ToolContext {
  async execute(input) { /* ... */ }
}

Reference

@Tool(options)

Apply @Tool to a class that extends ToolContext, and list the class in an app's tools array.

get-weather.tool.ts
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "get_weather",
  description: "Get current weather for a city",
  inputSchema: {
    city: z.string().describe("City name"),
    units: z.enum(["celsius", "fahrenheit"]).default("celsius"),
  },
})
class GetWeatherTool extends ToolContext {
  async execute(input: { city: string; units: "celsius" | "fahrenheit" }) {
    const weather = await fetchWeather(input.city, input.units);
    return { temperature: weather.temp, conditions: weather.conditions };
  }
}

See more examples below.

Options

Required:

OptionTypeDescription
namestringWhat the model calls. Unique within the server. Prefer verb_noun in snake_case.
inputSchemaobject of Zod typesOne Zod type per argument, like { city: z.string() }. Becomes the JSON Schema clients see in tools/list.

Optional:

OptionTypeDescription
aliasesstring[]Optional; defaults to none. Old names that remain callable but never listed. Aliases win over dotted owner.name lookup. Conflicts stop startup with ToolAliasConflictError.
enabledEnabledOptionOptional; defaults to on. A boolean or { get(context?), subscribe(listener), remedy? }. Off entries are omitted from lists and refused with FEATURE_OFF. Changes announce list_changed. See live availability.
descriptionstringWhat the tool does, what it returns, and when to use it. Always set it; it's the model's only documentation.
titlestringA display name for people, like "Search tickets". Sent in tools/list only when set.
outputSchemaZod schema, or one of "string", "number", "boolean", "date", "image", "audio", "resource", "resource_link"The shape of the result. Object schemas and unions of object schemas are advertised in tools/list; string, number, boolean and date literals advertise a wrapper schema. Results are checked against the declared schema: undeclared keys follow output.undeclaredKeys, and a result that doesn't match fails with INVALID_OUTPUT (see Shaping Tool Results).
outputOutputPolicyHow results are validated and their schema is advertised. Overrides app and server defaults. See Output policy.
annotationsToolAnnotationsHints for clients: title, readOnlyHint, destructiveHint, idempotentHint, openWorldHint. See describing side effects.
examplesToolExample[]Sample calls: description, input and optionally output.
tagsstring[]Labels for grouping and filtering.
visibility"public" | "hidden" | "internal"hidden leaves the tool out of tools/list but it can still be called by name. internal keeps it for in-process callers only.
rateLimitRateLimitConfigPer-tool rate limit: maxRequests, windowMs, partitionBy. See Guard options.
concurrencyConcurrencyConfigCap on simultaneous executions: maxConcurrent, optional queue. See Guard options.
timeoutTimeoutConfigExecution timeout: executeMs. See Guard options.
authProvidersToolAuthProviderRef[]Credentials the tool needs, such as { name: "github", scopes: ["repo"] }. Required by default. Before execute(), FrontMCP looks each one up in the server's credential providers, then in the caller's credential vault, and refuses the call without it. A server with neither doesn't check them.
availableWhenEntryAvailabilityOnly offer the tool on certain platforms, runtimes or deployments, or to some callers: surface lists who may call it, like ["mcp"] for clients only, or ["agent"] for agents only. Since 1.8.4, surface holds for agents and jobs too. See Environment awareness.
execution{ taskSupport }Whether the tool can run as a background task: "required", "optional" or "forbidden". See Background tasks.
uiToolUIConfigA widget to render the result in clients that support it. With ui, outputSchema still drops the fields it doesn't declare (Fields the schema doesn't declare).

Plugins add options of their own, which only take effect where the plugin is installed: cache (Cache), approval (Approval), featureFlag (Feature flags) and codecall (CodeCall). A server whose tool sets approval or featureFlag, with no plugin that enforces it, doesn't start: see Unenforced metadata.

Output policy

Set output on @FrontMcp, @App or @Tool. schemaMode, schemaDescriptionFormat and undeclaredKeys resolve from tool, then app, then server, then their defaults. allowNonFinite follows the same tool > app > server order. Changed in 1.11.3: before, only the server's value was used.

Changed in 1.10.16: before, tools contributed by an app's plugins and adapters could miss the app's output policy. They now inherit its schema advertisement and undeclared-key settings too.

OptionTypeDefaultDescription
budgetfalse | { maxBytes: number; lists?: "keep-newest" | "keep-oldest" }offLimit each copy of answer data; tool overrides app, then server. maxBytes is a whole number of at least 1024. See fitting an answer.
schemaMode"definition" | "description" | "both" | "none""definition"Advertise the schema in outputSchema, append it to the description, do both, or omit it. Validation still runs.
schemaDescriptionFormat"summary" | "jsonSchema""summary"A readable field list or a fenced JSON Schema. Object unions are summarized member by member.
allowNonFinitebooleanfalseAllow NaN and infinities to serialize as null instead of failing, with tool > app > server precedence.
undeclaredKeys"strip" | "warn" | "keep" | "fail""warn" in development; "strip" otherwiseWhat happens to keys dropped by parsing the Zod output schema. See Choosing what happens to undeclared keys.
undeclaredKeysResult
"strip"Drop keys the schema doesn't declare.
"warn"Drop them and log each key path once per tool, up to 100 paths. Array paths look like lines[].margin.
"keep"Restore them in text and structuredContent. The listed schema omits additionalProperties: false at every level so clients accept those keys.
"fail"Refuse the answer with InvalidOutputError, code INVALID_OUTPUT. The internal message names the keys; the production message stays generic.

Changed in 1.10.16: before, undeclared keys were silently stripped in development too. The default now warns when NODE_ENV=development; set "strip" for silent stripping.

A call that renders a UI still sends declared keys only, even under "keep". A schema containing a transform, preprocess, pipe or codec always uses its parsed answer: the undeclared-key policy doesn't apply. A schema's own unknown-key rules win: z.strictObject() refuses extra keys even under "keep", and z.looseObject() keeps them even under "strip" or "fail". Raw JSON Schema outputs aren't parsed by Zod and pass through as before.

Object schemas and unions whose members all resolve to objects are listed, including nested unions and $ref members registered with .meta({ id }). z.union() and z.discriminatedUnion() need no cast. The union gets top-level type: "object" and keeps anyOf or oneOf. With elicitation enabled, $defs stays at the root of the fallback wrapper so its references resolve.

Changed in 1.10.16: before, bare unions were omitted and readonly union tuples failed to compile. Schemas that cannot be listed, such as arrays, nullable objects, mixed unions and schemas without a JSON Schema representation, now log one startup warning naming the tool and reason. schemaMode: "none" suppresses it. Primitive Zod outputs, media and multi-content arrays remain unlisted and quiet. String, number, boolean and date literals advertise their wrapped structured-content schemas. A recursive union reference is left out too.

Output parsing helpers

ToolEntry.getOutputJsonSchema() returns the cached object-compatible JSON Schema or null; getUnlistedOutputSchemaReason() returns the reason a declared schema cannot be listed, or undefined when it is listed or intentionally unlisted. getRawOutputSchema() also applies the elicitation fallback wrapper.

A ToolEntry's parseOutput(value, options?) and safeParseOutput(value, options?) accept OutputParseOptions: undeclaredKeys (default "strip") and onUndeclaredKeys?: (keyPaths: string[]) => void for "warn". Omitting options preserves stripping, as on the UI and cache paths.

The SDK exports UNDECLARED_KEYS_POLICIES, its UndeclaredKeysPolicy type, resolveUndeclaredKeysPolicy(tool?, app?, server?) for the cascade above, and withUndeclaredKeysAllowed(schema) for a copy of a JSON Schema without additionalProperties: false. @frontmcp/utils's findDroppedKeys(original, parsed) returns dropped key paths; hasTransform(schema) from @frontmcp/lazy-zod detects schemas where comparing those paths is inappropriate.

execute(input)

FrontMCP calls execute() once the arguments pass validation. Inside it, this is a ToolContext: Context classes lists everything on it.

  • input: the validated arguments. Its TypeScript type must match inputSchema.
  • Returns anything. Objects arrive as the result's structuredContent. Plain values, like strings and numbers, arrive as { "value": ... }, unless outputSchema is "string", "number" or "boolean": then the text block is the value itself. The same data is also sent as text in content, for clients that don't read structured output.

Inside execute(), this is the ToolContext: this.get() for providers, this.fetch() for outbound HTTP, this.notify() and this.progress() for status, this.elicit() to ask the user for input, and this.fail() to return an error.

Caveats

  • The class must extend ToolContext.
  • The type of execute()'s parameter must match inputSchema exactly, and with an outputSchema, its return type must match that. @Tool checks all three when TypeScript compiles, and reports a mismatch on the decorator line (see Troubleshooting).
  • Arguments that aren't in inputSchema are dropped before execute() runs.
  • If execute() throws a plain Error, clients see the message and stack in development, and a generic "Internal FrontMCP error" with an error ID in production. Use PublicMcpError for messages the model should read.
  • The class can declare hooks that run for this tool's calls only: instance methods from Did("createToolCallContext") on, and, since 1.9.4, static methods on any stage, like parseInput. An instance method on an earlier stage stops the server from starting.

fileSignal(path, key, options?)

Returns an EnabledSource for enabled that reads the boolean under key in the JSON file at path, on Node. It watches the file's folder and reads the file again every pollIntervalMs. A missing file, or a key without a boolean, gives defaultValue; content that isn't JSON, as a write in progress leaves it, keeps the last value read. An empty path or key, or a pollIntervalMs that isn't a positive number, throws InvalidFileSignalError (INVALID_FILE_SIGNAL) where the entry is declared. New in 1.11.0.

OptionTypeDefaultDescription
defaultValuebooleanfalseUsed while the file is missing or its key has no boolean.
pollIntervalMsnumber2000Positive finite milliseconds between reads, alongside file watching.
remedyErrorRemedyTurn on the "<key>" feature, then try again.Next step sent with the FEATURE_OFF refusal.
logger{ warn(message: string): void }consoleReports each file problem once.

Answer budget helpers

fitToolAnswer(result, budget) and fitResourceAnswer(result, budget) from @frontmcp/sdk return a shortened result, or undefined when no change is needed. budget is { maxBytes: number; lists?: "keep-newest" | "keep-oldest" }, with "keep-newest" as the default. They add a text note and _meta[BUDGET_META_KEY] ("frontmcp/budget") describing omissions. Tool images, audio and resource blocks, and resource HTML and blobs, are left whole. These helpers don't check an output schema; the server's tool flow does, as Fitting an answer to a budget describes. New in 1.11.0.


Usage

Validating input

Put every constraint in the schema. The model sees it in tools/list, and FrontMCP rejects calls that break it before execute() runs, with an isError result that lists each problem.

Open
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "create_ticket",
  description: "Open a new support ticket",
  inputSchema: {
    title: z.string().min(5).max(120).describe("One-line summary of the problem"),
    priority: z.enum(["low", "normal", "high"]).default("normal"),
    email: z.string().email().optional().describe("Where to send updates"),
  },
})
export class CreateTicket extends ToolContext {
  async execute(input: { title: string; priority: "low" | "normal" | "high"; email?: string }) {
    return { id: "T-4", ...input };
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Returning results

Return a plain value, an object, or an object that matches an outputSchema. Clients get objects as structuredContent, and plain values wrapped as { "value": ... }. Both also arrive as text. To send a plain value as it is, declare it with a primitive outputSchema.

Return values

Example 1 of 4

Plain value

A number, string or boolean is wrapped as { "value": ... }.

Open
import { Tool, ToolContext } from "@frontmcp/sdk";

@Tool({ name: "count_open", description: "How many tickets are open", inputSchema: {} })
export class CountOpen extends ToolContext {
  async execute() {
    return 12;
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Link to this example

Listing a union result

Use a discriminator when each result kind has different fields. The listed schema describes both outcomes:

Open
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "lookup_ticket",
  inputSchema: { id: z.string() },
  outputSchema: z.discriminatedUnion("kind", [
    z.object({ kind: z.literal("found"), title: z.string() }).meta({ id: "FoundTicket" }),
    z.object({ kind: z.literal("missing"), id: z.string() }).meta({ id: "MissingTicket" }),
  ]),
  output: { schemaMode: "both" },
})
export class LookupTicket extends ToolContext {
  async execute({ id }: { id: string }) {
    return id === "T-1" ? { kind: "found" as const, title: "Cannot log in" } : { kind: "missing" as const, id };
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

z.union() chooses its first matching member. Put the widest matching member first, or use a discriminated union as above, so fields declared only by a later member aren't dropped.

Choosing what happens to undeclared keys

Here the app keeps extra keys for a plugin's tool, while individual tools override the app with "strip", "warn" and "fail":

Open
import { App, DynamicPlugin, Plugin, Tool, ToolContext, z } from "@frontmcp/sdk";

const schema = { id: z.string() };
const answer = () => ({ id: "T-1", category: "billing" });

@Tool({ name: "keep_ticket", inputSchema: {}, outputSchema: schema })
class KeepTicket extends ToolContext { async execute() { return answer(); } }

@Tool({ name: "strip_ticket", inputSchema: {}, outputSchema: schema, output: { undeclaredKeys: "strip" } })
class StripTicket extends ToolContext { async execute() { return answer(); } }

@Tool({ name: "warn_ticket", inputSchema: {}, outputSchema: schema, output: { undeclaredKeys: "warn" } })
class WarnTicket extends ToolContext { async execute() { return answer(); } }

@Tool({ name: "fail_ticket", inputSchema: {}, outputSchema: schema, output: { undeclaredKeys: "fail" } })
class FailTicket extends ToolContext { async execute() { return answer(); } }

@Plugin({ name: "ticket-export", tools: [KeepTicket] })
class TicketExport extends DynamicPlugin<object> {}

@App({
  name: "Help Desk",
  plugins: [TicketExport],
  tools: [StripTicket, WarnTicket, FailTicket],
  output: { undeclaredKeys: "keep" },
})
export class HelpDeskApp {}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

"keep" fails with INVALID_OUTPUT if a key cannot be restored because parsing replaced its containing object with a primitive. To catch missing declarations in tests before a server strips them, use toPassOutputSchemaWhole().

Returning an error the model can read

Call this.fail() with a PublicMcpError. The call ends, and the client gets an isError result with your message, in development and in production.

Open
import { PublicMcpError, Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "get_ticket",
  description: "Get one support ticket by id",
  inputSchema: { id: z.string() },
})
export class GetTicket extends ToolContext {
  async execute({ id }: { id: string }) {
    if (id !== "T-1") this.fail(new PublicMcpError(`There's no ticket ${id}.`));
    return { id, title: "Cannot log in" };
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Describing side effects with annotations

Annotations tell clients how a tool behaves, so they can decide how carefully to confirm a call with the user. They're hints: clients may rely on them, but FrontMCP doesn't enforce them.

AnnotationMeaning when true
readOnlyHintThe tool doesn't change anything.
destructiveHintThe tool may delete or overwrite things. Only meaningful when it isn't read-only.
idempotentHintCalling it again with the same arguments has no further effect.
openWorldHintThe tool reaches outside systems, like the web, rather than a closed set of data.
Open
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "delete_ticket",
  description: "Permanently delete a ticket",
  inputSchema: { id: z.string() },
  annotations: { title: "Delete ticket", destructiveHint: true, idempotentHint: true },
})
export class DeleteTicket extends ToolContext {
  async execute({ id }: { id: string }) {
    return { deleted: id };
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Using a provider

Get shared services with this.get(). Register the provider in the same app's providers array.

Open
import { Tool, ToolContext } from "@frontmcp/sdk";
import { Directory } from "./directory";

@Tool({ name: "whoami", description: "Which support team is on duty", inputSchema: {} })
export class WhoAmI extends ToolContext {
  async execute() {
    return this.get(Directory).onDuty();
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Writing a tool as a function

For a small tool that doesn't need context, the function form is shorter. It takes the same options.

Open
import { tool, z } from "@frontmcp/sdk";

export const shout = tool({
  name: "shout",
  description: "Uppercase some text",
  inputSchema: { text: z.string() },
})(async ({ text }) => text.toUpperCase());

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Keeping an old tool name callable

List the current name once, and keep an old integration working through aliases. Aliases also use the tool's authorization and availability checks. New in 1.11.0.

Open
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({ name: "get_ticket", aliases: ["find_ticket"], inputSchema: { id: z.string() } })
export class GetTicket extends ToolContext {
  async execute({ id }: { id: string }) { return { id }; }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Changing availability while the server runs

enabled turns a tool on and off while the server runs. It is independent of availableWhen: both must allow the call. An off tool is left out of tools/list, and a call to it is refused with FEATURE_OFF and a remedy. New in 1.11.0.

Open
import { Tool, ToolContext } from "@frontmcp/sdk";

@Tool({ name: "export_tickets", inputSchema: {}, enabled: false })
export class ExportTickets extends ToolContext {
  async execute() { return { rows: 12 }; }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

For a switch that changes while sessions are live, pass an EnabledSource: get(context?) answers for each request, and subscribe(listener) calls listener when the answer may have changed and returns the function that stops it. A source that throws counts as off, and its optional remedy goes with the FEATURE_OFF refusal. fileSignal() is a source backed by a JSON file on Node.

When a source changes, FrontMCP sends each connected client one notifications/tools/list_changed for the burst. tools/list results carry _meta["frontmcp/surface"], a hash of the names the list shows. When the tool list has changed since a client with a session, such as a connect() client, last read it, that client's call to a tool missing from the new list gets STALE_TOOL_LIST once, with another notifications/tools/list_changed; calling an off tool again gets FEATURE_OFF. A 2026-07-28 request has no session, so it gets FEATURE_OFF at once, as the Playground's client does.

Open
import { App, Tool, ToolContext, type EnabledSource } from "@frontmcp/sdk";

let reviewsOn = true;
const listeners = new Set<() => void>();

export const reviews: EnabledSource = {
  get: () => reviewsOn,
  subscribe(listener) {
    listeners.add(listener);
    return () => listeners.delete(listener);
  },
  remedy: { say: "Turn on Reviews in Settings" },
};

export function setReviews(on: boolean) {
  reviewsOn = on;
  for (const listener of [...listeners]) listener();
}

@Tool({ name: "list_reviews", description: "List ticket reviews", inputSchema: {}, enabled: reviews })
class ListReviews extends ToolContext {
  async execute() {
    return { reviews: ["R-1"] };
  }
}

@App({ name: "Help Desk", tools: [ListReviews] })
export class HelpDesk {}

export const config = { info: { name: "help-desk", version: "1.0.0" }, apps: [HelpDesk] };

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Fitting an answer to a budget

output.budget applies at tool, app or server level, in that order. It defaults to off; false disables an inherited budget. maxBytes is a whole number of at least 1024 bytes. lists keeps the last items ("keep-newest", the default), or the first ("keep-oldest"). Each copy of the data, text and structured content, gets the budget separately. FrontMCP leaves out whole items or string endings and records omissions in _meta["frontmcp/budget"] and a text note. When tools/list advertises the tool's outputSchema (schemaMode "definition" or "both", with an object schema) and the caller's client profile doesn't limit it to text, a cut that would break the schema is not made: the answer goes whole, and the server warns once for that tool. Otherwise the shortened answer is sent. The budget applies to calls from clients, not to in-process calls such as this.callTool(). New in 1.11.0.

Open
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "ticket_history", inputSchema: {},
  outputSchema: { events: z.array(z.string()) },
  output: { budget: { maxBytes: 1024, lists: "keep-newest" } },
})
export class TicketHistory extends ToolContext {
  async execute() { return { events: Array.from({ length: 100 }, (_, i) => `${i}: ${"note ".repeat(20)}`) }; }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Checking literal outputs

Literal outputSchema types validate the value, and "string", "number", "boolean" and "date" advertise an object schema wrapping the value in content. Dates are sent as ISO 8601. Media literals require valid MCP blocks; a bad block fails with INVALID_OUTPUT instead of disappearing.

Changed in 1.11.3: before, literal outputs were not checked or advertised, and dates used the server's local date string.

Open
import { Tool, ToolContext } from "@frontmcp/sdk";

@Tool({ name: "bad_count", inputSchema: {}, outputSchema: "number" })
export class BadCount extends ToolContext {
  async execute(): Promise<any> { return "five"; }
}

@Tool({ name: "report_date", inputSchema: {}, outputSchema: "date" })
export class ReportDate extends ToolContext {
  async execute() { return new Date("2026-11-09T12:30:00.000Z"); }
}

@Tool({ name: "nonfinite_count", inputSchema: {}, output: { allowNonFinite: true } })
export class NonfiniteCount extends ToolContext {
  async execute() { return { value: Infinity }; }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.


Troubleshooting

Tool alias conflict

The server didn't start: ToolAliasConflictError (TOOL_ALIAS_CONFLICT) names each alias that two tools declare, or that is also a tool's name. Give each alias to one tool, and never use a tool's name as one.

Tool "…" is not in the current tool list; this session's tool list is out of date

STALE_TOOL_LIST means the tool list changed since this session last read it, and the tool it called isn't in the new one. The server sends notifications/tools/list_changed with it. Call tools/list again, then call a tool from the new list. Calling the same tool again gets FEATURE_OFF with its remedy while it stays off. See Changing availability while the server runs.

Tool "…": tools/list leaves out its outputSchema because …

The schema cannot be advertised as an object or a union of objects. Use an object wrapper for an array or primitive result, or inspect the named conversion failure. A transform has no JSON Schema representation. Set output.schemaMode: "none" only when you intend to hide the schema.

Tool "…" answered with keys its outputSchema does not declare, so they were stripped: …

The undeclared-key policy is "warn", the development default. Declare the named fields, or return only the fields you intend to expose. Set "keep" to send them or "fail" to refuse such answers. UI rendering and transform schemas keep their parsing rules; see Output policy.

My tool doesn't show up in tools/list

Check, in order:

  1. The class is in its app's tools array, and the app is in @FrontMcp({ apps }).
  2. tsconfig.json sets experimentalDecorators and emitDecoratorMetadata to true.
  3. import "reflect-metadata" is the first line of your entry file.
  4. The tool doesn't set visibility: "hidden" or "internal", and its availableWhen matches the environment.

TypeScript says Unable to resolve signature of class decorator

@Tool checks the class against its options, and error TS1238 on the decorator line means a check failed. The rest of the message says which one:

  • 'execute() parameter error': "Parameter type does not match the input schema.": execute()'s parameter type disagrees with inputSchema. "Parameter type is too wide" means it allows more than the schema, like limit?: number for a field with .default().
  • 'execute() return type error': with an outputSchema, execute() returns something that doesn't match it, or any. A complete CallToolResult, with content, is accepted too: FrontMCP sends it as it is, without checking it against outputSchema. (Changed in 1.11.1: before, a CallToolResult failed this check.)
  • 'Tool class error': "Class must extend ToolContext": the class doesn't extend ToolContext.

The message also shows expected_input_type or expected_output_type, the type to use:

// 🚩 inputSchema says string, execute says number
@Tool({ name: "get_ticket", inputSchema: { id: z.string() } })
class GetTicket extends ToolContext {
  async execute(input: { id: number }) { /* ... */ }
}

// ✅ The types match
@Tool({ name: "get_ticket", inputSchema: { id: z.string() } })
class GetTicket extends ToolContext {
  async execute(input: { id: string }) { /* ... */ }
}

The client sees "Internal FrontMCP error" instead of my message

In production, FrontMCP hides the message of any error that isn't a PublicMcpError, like a plain Error thrown from execute(), so internals don't leak. The client gets an error ID, and FrontMCP logs the same ID with the original message and stack. If the model should see the message, fail with this.fail(new PublicMcpError("...")) instead.

Calls fail with INVALID_OUTPUT

The result didn't match outputSchema, so nothing from it was sent. In development the text names the first field that didn't match; in production it's only "Output validation failed. Please contact support." A NaN or Infinity in a number field fails the same way, with or without an outputSchema, because JSON can't carry it.

Open
import { Tool, ToolContext, z } from "@frontmcp/sdk";

@Tool({
  name: "ticket_stats",
  description: "Count open and closed tickets",
  inputSchema: {},
  outputSchema: z.object({ open: z.number(), closed: z.number() }),
})
export class TicketStats extends ToolContext {
  async execute() {
    const counts: Record<string, number> = { open: 12, pending: 3 }; // no "closed" today
    return { open: counts.open, closed: counts.closed };
  }
}

Starting FrontMCP in your browser…

FrontMCP starts when this example comes into view.

Fix the result, or change outputSchema if the result is right. Here, counts.closed ?? 0 would do.

Calls fail with "Invalid tool input"

The arguments didn't match inputSchema, so execute() never ran. The result text lists each problem with the field's path. If a model keeps sending bad arguments, the schema probably isn't telling it enough: add .describe() notes, and prefer z.enum() over free text where you can.

Calls fail with error -32001 and an authUrl

The tool lists a required entry in authProviders, and the user hasn't connected that credential yet. execute() doesn't run. Send the user to authUrl to connect it, or mark the provider required: false if the tool can work without it. With signInRequired: true in the error's data instead, the caller isn't signed in: sign in to the server first, then call the tool again for a link. Without either, no credential provider or vault has one for this caller: see this.authProviders.

Report a docs issue · Report a security concern privately