Skip to content

fix: remove draft-07 outputSchema that blocks 2020-12-only clients (fixes #132) - #138

Open
shoemoney wants to merge 1 commit into
perplexityai:mainfrom
shoemoney:shoemoney/fix-modelcontextprotocol-132
Open

fix: remove draft-07 outputSchema that blocks 2020-12-only clients (fixes #132)#138
shoemoney wants to merge 1 commit into
perplexityai:mainfrom
shoemoney:shoemoney/fix-modelcontextprotocol-132

Conversation

@shoemoney

Copy link
Copy Markdown

Fixes #132

Root cause

McpServer.registerTool converts zod schemas via zod-to-json-schema / zod/v4-mini with the SDK's default target draft-7. Every tool's inputSchema and outputSchema therefore advertises

"$schema": "http://json-schema.org/draft-07/schema#"

2020-12-only validators (Ajv configured for 2020-12, Claude Cowork / Claude Desktop) reject the dialect before any network call:

Tool 'perplexity_ask' has an invalid outputSchema: JSON Schema declares an unsupported dialect ("$schema": "http://.../draft-07/schema#"). The default validator supports JSON Schema 2020-12 only

Reproduced locally on v1.2.0: tools/list returned 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 to zod/v4 both still emit draft-07 because no target reaches mapMiniTarget.

Fix

  • Drop optional outputSchema from all 4 tools (perplexity_ask, perplexity_research, perplexity_reason, perplexity_search). outputSchema is optional in the MCP spec; omitting it restores every affected client immediately without losing runtime behavior (structuredContent is still returned). Suggested as the stopgap in All tools unusable in 2020-12-only clients: outputSchema declares draft-07 dialect #132 option 2.
  • Strip $schema at the tools/list boundary for inputSchema (required, cannot be dropped) and any residual outputSchema. The emitted schemas use only type/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

  • Repro script via InMemoryTransport before fix: 8/8 schemas rejected (4 tools x input+output), after fix: 0/8 rejected, outputSchema absent, inputSchema has no $schema.
  • npm test — 89/89 passed (4 suites) — npm run build clean.
  • No behavior change to tool execution or structuredContent shape; plugin.json/mcp.json/server.json untouched.

Future

Re-add outputSchema once the SDK emits 2020-12 by default (target draft-2020-12 reaches the converter). The kept _responseOutputSchema / _searchOutputSchema constants document the intended shape.

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
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.

All tools unusable in 2020-12-only clients: outputSchema declares draft-07 dialect

1 participant