fix(mcp): inline tool schemas so inputSchema is type:object#121
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
deriveSchema(used byMCPTool/MCPResource) marshalledjsonschema.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/outputSchemato be an object schema withtype: "object". A top-level$refmakes MCP clients (e.g. Claude Code) reject the entiretools/listwithInvalid 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.MCPResourcenow emits spec-valid schemas; existing catalogs re-sync to valid schemas on next install.🤖 Generated with Claude Code