Skip to content

schema: use JSONObject for extensions capability values#2508

Merged
felixweinberger merged 1 commit intomainfrom
fweinberger/extensions-jsonobject
Apr 9, 2026
Merged

schema: use JSONObject for extensions capability values#2508
felixweinberger merged 1 commit intomainfrom
fweinberger/extensions-jsonobject

Conversation

@felixweinberger
Copy link
Copy Markdown
Contributor

Change the extensions capability value type from object to JSONObject, matching experimental and every other open-ended record in the schema.

Motivation and Context

SEP-2133 added extensions using bare object:

experimental?: { [key: string]: JSONObject };  // line 495, 604
extensions?:   { [key: string]: object };      // line 592, 709 — outlier

This is the only use of bare object in the entire schema file. Over the wire the two validate identical JSON documents (JSON parsing already guarantees JSON-serializable values), but at the TypeScript level JSONObject catches accidental Date/Map/function values at compile time.

The practical impact: the typescript-sdk's nightly spec-sync workflow has a type-parity test that asserts bidirectional assignability between spec types and Zod-inferred types. The SDK's Zod schemas for extensions (correctly) use JSONObject semantics, so the parity test fails when spec.types.ts reverts to object. See modelcontextprotocol/typescript-sdk#1782 for context.

How Has This Been Tested?

  • npm run check:schema:ts passes
  • npm run check:schema:json passes
  • npm run check:schema:examples passes (134/134, including both extensions examples)
  • Verified that normal extension config interfaces remain assignable to JSONObject under both --strict and --strict --exactOptionalPropertyTypes

Breaking Changes

None on the wire. TypeScript consumers who were passing non-JSON-serializable values (class instances, Dates, functions) as extension configs will get a compile error, which is the intended effect.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

No type discussion in the SEP-2133 review — the object choice appears to have been unintentional. schema.json and schema.mdx regenerated.

The extensions field in ClientCapabilities/ServerCapabilities used bare
`object` as the value type, while the sibling experimental field (same
semantic concept — open-ended vendor-prefixed config) uses JSONObject.
This was the only use of bare `object` in the entire schema file.

Over the wire the two validate identical JSON — both mean 'any object'.
The difference is TypeScript ergonomics: JSONObject catches accidental
Date/Map/function values at compile time. Normal extension config
interfaces (including optional fields under exactOptionalPropertyTypes)
remain assignable.

Ref: SEP-2133
@felixweinberger felixweinberger requested a review from a team as a code owner March 31, 2026 16:30
@mintlify
Copy link
Copy Markdown

mintlify bot commented Mar 31, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
mcp-staging 🟢 Ready View Preview Mar 31, 2026, 4:32 PM

@felixweinberger felixweinberger merged commit 10de8dd into main Apr 9, 2026
10 checks passed
@felixweinberger felixweinberger deleted the fweinberger/extensions-jsonobject branch April 9, 2026 12:18
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.

2 participants