diff --git a/.changeset/fix-discriminated-union-schema.md b/.changeset/fix-discriminated-union-schema.md new file mode 100644 index 000000000..06b0b3927 --- /dev/null +++ b/.changeset/fix-discriminated-union-schema.md @@ -0,0 +1,5 @@ +--- +"@modelcontextprotocol/server": patch +--- + +fix: ensure tool inputSchema includes type: object for discriminated unions diff --git a/packages/server/src/server/mcp.ts b/packages/server/src/server/mcp.ts index 05136f5b6..67fbaafd5 100644 --- a/packages/server/src/server/mcp.ts +++ b/packages/server/src/server/mcp.ts @@ -147,7 +147,7 @@ export class McpServer { title: tool.title, description: tool.description, inputSchema: tool.inputSchema - ? (schemaToJson(tool.inputSchema, { io: 'input' }) as Tool['inputSchema']) + ? ({ type: 'object' as const, ...schemaToJson(tool.inputSchema, { io: 'input' }) } as Tool['inputSchema']) : EMPTY_OBJECT_JSON_SCHEMA, annotations: tool.annotations, execution: tool.execution,