mcp-use TypeScript API
    Preparing search index...

    Type Alias ToolResult<TOutput>

    ToolResult:
        | InputRequiredResult
        | (
            [TOutput] extends [never]
                ? CallToolResult
                :
                    | CallToolResult & { structuredContent: TOutput }
                    | CallToolResult & { isError: true }
        )

    Result a tool callback may return, keyed by the tool's inferred output type. Prefer the SDK's raw CallToolResult; interactive calls may return an InputRequiredResult. Deprecated response helpers (text, object, …) return the same envelope and remain accepted.

    Without an outputSchema (TOutput = never) any CallToolResult is accepted. With one, the result must carry structuredContent matching the schema or set isError: true — mirroring the SDK's runtime rule, which rejects results from schema'd tools that carry no structured content unless isError is set.

    The SDK auto-appends a JSON text block when structuredContent is a non-object value and no type: "text" block is present; for object-shaped payloads include the text serialization yourself:

    return {
    content: [{ type: "text", text: JSON.stringify(data) }],
    structuredContent: data,
    };

    Type Parameters

    • TOutput = never