Skip to content

ToolDefinition

A single tool definition. The input Zod schema is compiled to JSON Schema for tools/list and used to validate arguments before handler runs.

Type ParameterDefault typeDescription
I extends z.ZodTypez.ZodTypeThe Zod schema type for the tool’s arguments.
O extends z.ZodTypez.ZodTypeThe Zod schema type for the tool’s structured output, if declared.
PropertyTypeDescription
alwaysOn?booleanBudget hint: surface this tool even when the per-session cap is reached.
annotations?ToolAnnotationsBehavioral hints surfaced in tools/list. Any field the author omits is filled by a conservative default: readOnlyHint is true UNLESS the tool declares write intent (mutating: true, or the server is invoked with a trove:ingest scope). An explicit author value always wins.
descriptionstringThe description Claude reads to decide whether to call this tool.
inputIA Zod schema describing the tool’s arguments.
mutating?booleanMarks the tool as mutating, which forces client consent. Defaults to false.
namestringA short snake_case identifier, unique within the server.
output?OAn optional Zod schema describing the tool’s structured output. When set, it is compiled to an outputSchema in tools/list and the handler’s structured field is surfaced as the spec structuredContent object.
title?stringA human-readable display name for client tool pickers (MCP title).
handler(args: output<I>, ctx: ToolContext): Promise<string | ToolResult<NoInfer<output<O>>>>;

The tool’s implementation.

NoInfer on the return side is load-bearing: without it O would also be inferred FROM the returned structured, so the schema and the value would agree by construction and check nothing. Pinning O to the declared output alone is what makes the comparison real.

ParameterType
argsoutput<I>
ctxToolContext

Promise<string | ToolResult<NoInfer<output<O>>>>