mcp-use TypeScript API
    Preparing search index...

    Interface ToolDefinition

    Declares a tool's identity, LLM-facing description, and schemas. First argument to MCPServer.tool.

    interface ToolDefinition {
        _meta?: MetaObject;
        annotations?: {};
        description?: string;
        inputSchema?: StandardSchemaWithJSON<unknown, unknown>;
        name: string;
        outputSchema?: StandardSchemaWithJSON<unknown, unknown>;
        schema?: StandardSchemaWithJSON<unknown, unknown>;
        title?: string;
        view?: ToolViewConfig;
        visibility?: "app" | "model";
    }
    Index
    _meta?: MetaObject

    Extension metadata advertised on this tool's tools/list descriptor.

    Use vendor-namespaced keys for custom data. This definition metadata is distinct from a tool callback result's _meta: it describes the tool, while result _meta belongs to one invocation. For view-bound or visibility-restricted tools, framework-owned MCP Apps keys are derived from ToolDefinition.view and ToolDefinition.visibility; those derived values take precedence over colliding entries here.

    annotations?: {}

    Behavioral hints for clients (readOnlyHint, destructiveHint, …).

    description?: string

    LLM-facing description of what the tool does.

    inputSchema?: StandardSchemaWithJSON<unknown, unknown>

    Object schema for input validation — any Standard Schema library with JSON Schema conversion (StandardSchemaWithJSON): zod v4, ArkType, Valibot, …. Field descriptions become LLM hints. Input is validated by the SDK before the callback runs. Emitted on the wire as inputSchema.

    name: string

    Unique tool identifier, e.g. "fetch-weather".

    outputSchema?: StandardSchemaWithJSON<unknown, unknown>

    Schema for structured output (StandardSchemaWithJSON). Any JSON root is allowed — object, array, or primitive (2026-07-28 protocol). When set, the callback must return a result carrying matching structuredContent or an explicit isError result — enforced at compile time and validated by the SDK at runtime.

    schema?: StandardSchemaWithJSON<unknown, unknown>

    Alias for ToolDefinition.inputSchema. Prefer inputSchema in new code — it matches the MCP wire field name.

    title?: string

    Human-readable title shown in UIs (falls back to name).

    Bind this tool to a view for MCP Apps rendering. Requires ToolDefinition.outputSchema — the view reads the result's structuredContent typed by this schema.

    visibility?: "app" | "model"

    Declares who may call or see the tool. Emitted as _meta.ui.visibility on tools/list. Omitted = host default (callable by the model, visible to the app). The server always lists every registered tool — hosts filter by this declaration; the server never omits tools from tools/list. "app" marks app-private helper tools callable from views via useCallTool while the host hides them from the model.