tools/list.
This distinction matters because
registerAppTool() does not
accept a plain JSON Schema object as its runtime schema. It expects a schema library value that
implements Standard Schema validation and the ~standard.jsonSchema interface. Use manual
onlisttools and oncalltool handlers when you want to author the wire schemas and validation
logic yourself.
Server Tool Schemas
Pass complete schema objects toregisterAppTool(). Zod 4.2 or later implements both required
Standard Schema interfaces.
- It converts each registered schema to JSON Schema for
tools/list. - Before the callback runs, it validates and parses
tools/call.argumentswithinputSchema. - After a successful callback, it requires
structuredContentwhenoutputSchemaexists and validates that value. Tool results withisError: trueare not checked againstoutputSchema.
App-Side Tool Schemas
Views can expose tools withapp.registerTool().
The same schema value supplies TypeScript inference, runtime validation, and the JSON Schema sent
to the host.
app.registerTool() parses arguments before calling the handler. For successful results, it also
parses structuredContent with outputSchema. A missing or invalid structured result rejects the
tool call. Results marked isError: true bypass output validation.
If you define app-side tools through onlisttools and
oncalltool instead, return JSON Schema from
onlisttools and validate params.arguments inside oncalltool. The low-level handlers do not add
runtime validation for you.
Input Schema Rules
Every MCP tool definition has an object-shapedinputSchema, including tools without arguments.
The SDK emits an empty object schema when you omit inputSchema, but an explicit schema documents
intent and rejects unexpected fields when you use .strict():
Output Schema Rules
AddoutputSchema when a View or another client depends on structuredContent. The handler must
then return matching data on every successful path.
2026-07-28 permits any JSON value at the root of structuredContent when the output
schema permits it. Core MCP 2025-11-25 requires an object, so use an object root for MCP Apps that
must work across both versions. See MCP structuredContent, content, and
_meta for the
compatibility rules.
Keep a readable content block alongside structuredContent. Clients without a View still need a
useful result, and the MCP specification recommends serialized JSON in a text block for backwards
compatibility.
Standard Schema Requirements
The SDK reads two members from a compatible runtime schema:~standard.validatevalidates input and output values.~standard.jsonSchema.input()or.output()exports JSON Schema 2020-12.
{ type: 'object', properties: ... } is already
wire JSON Schema, but it has no runtime validator or Standard Schema metadata, so do not pass it to
registerAppTool() or app.registerTool().
The SDK 2.x server helper still accepts a raw Zod shape such as { query: z.string() }, but that
overload is deprecated. Wrap the shape with z.object() so input and output schemas follow the same
pattern.
Common Schema Errors
Test the Contract
Test the schema boundary without rendering the View:Related
registerAppTool
Register a server tool that renders a View.
App-Side Tools
Let the host call tools exposed by a View.
Tool Results and Model Context
Decide what belongs in content, structuredContent, and _meta.
MCP Tools
Review the core tools/list and tools/call contract.