Skip to content

fix(mcp): inline tool schemas so inputSchema is type:object#121

Merged
I-am-nothing merged 1 commit into
mainfrom
fix/mcp-schema-inline-type
Jun 15, 2026
Merged

fix(mcp): inline tool schemas so inputSchema is type:object#121
I-am-nothing merged 1 commit into
mainfrom
fix/mcp-schema-inline-type

Conversation

@I-am-nothing

Copy link
Copy Markdown
Contributor

Problem

deriveSchema (used by MCPTool/MCPResource) marshalled jsonschema.Reflect(zero), whose default output is a top-level {"$ref":"#/$defs/<Type>"} with the actual object schema under $defs.

The MCP spec requires a tool's inputSchema/outputSchema to be an object schema with type: "object". A top-level $ref makes MCP clients (e.g. Claude Code) reject the entire tools/list with Invalid input: expected "object" — so one module's tools break every module's tools for that account.

Fix

Use &jsonschema.Reflector{DoNotReference: true} so the struct schema inlines as a concrete {"type":"object","properties":{...}}. Nested types still inline correctly.

Impact

Any module declaring ms.MCPTool/ms.MCPResource now emits spec-valid schemas; existing catalogs re-sync to valid schemas on next install.

🤖 Generated with Claude Code

deriveSchema used jsonschema.Reflect's default, which emits a top-level
{"$ref":"#/$defs/..."} with the object schema nested in $defs. The MCP
spec requires inputSchema/outputSchema to be an object schema (type:"object"),
and clients reject the ENTIRE tools/list when any tool's top-level schema is a
$ref. Setting DoNotReference inlines the struct schema as a concrete
{"type":"object",...}.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@I-am-nothing I-am-nothing merged commit b9893ba into main Jun 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant