fix: remove draft-07 outputSchema that blocks 2020-12-only clients (fixes #132) - #138
Open
shoemoney wants to merge 1 commit into
Open
Conversation
Every tool declared outputSchema with $schema draft-07 via the SDK's zod-to-json-schema conversion. 2020-12-only validators (e.g. Claude Cowork) reject the dialect before any network call, making all 4 tools unusable. outputSchema is optional in the MCP spec; omitting it restores every client immediately while structuredContent is still returned. For inputSchema (required) strip $schema at the tools/list boundary so clients apply their own default dialect (SEP-1613). Safe because schemas use only common keywords with identical semantics. Fixes perplexityai#132 Refs modelcontextprotocol/typescript-sdk#745 / #2084 / #2085 Refs modelcontextprotocol.io/seps/1613
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.
Fixes #132
Root cause
McpServer.registerToolconverts zod schemas viazod-to-json-schema/zod/v4-miniwith the SDK's default targetdraft-7. Every tool'sinputSchemaandoutputSchematherefore advertises2020-12-only validators (Ajv configured for 2020-12, Claude Cowork / Claude Desktop) reject the dialect before any network call:
Reproduced locally on v1.2.0:
tools/listreturned 8/8 schemas with draft-07, rejected by a 2020-12-only Ajv. Upstream tracked at modelcontextprotocol/typescript-sdk#745 and modelcontextprotocol/typescript-sdk#2084 (fix in modelcontextprotocol/typescript-sdk#2085). Bumping the SDK to 1.30.0 and moving tozod/v4both still emit draft-07 because notargetreachesmapMiniTarget.Fix
outputSchemafrom all 4 tools (perplexity_ask,perplexity_research,perplexity_reason,perplexity_search).outputSchemais optional in the MCP spec; omitting it restores every affected client immediately without losing runtime behavior (structuredContentis still returned). Suggested as the stopgap in All tools unusable in 2020-12-only clients:outputSchemadeclares draft-07 dialect #132 option 2.$schemaat thetools/listboundary forinputSchema(required, cannot be dropped) and any residualoutputSchema. The emitted schemas use onlytype/properties/required/additionalProperties/items/enum/minimum/maximum/description, which have identical semantics under draft-07 and 2020-12, so omitting the dialect tag lets clients apply their own default (SEP-1613). Safe for these 4 tools; tuple schemas would need the full 2020-12 conversion (items->prefixItems), not just tag removal.Verification
InMemoryTransportbefore fix: 8/8 schemas rejected (4 tools x input+output), after fix: 0/8 rejected,outputSchemaabsent,inputSchemahas no$schema.npm test— 89/89 passed (4 suites) —npm run buildclean.structuredContentshape;plugin.json/mcp.json/server.jsonuntouched.Future
Re-add
outputSchemaonce the SDK emits 2020-12 by default (targetdraft-2020-12reaches the converter). The kept_responseOutputSchema/_searchOutputSchemaconstants document the intended shape.