feat: add extensions attribute to ClientCapabilities and ServerCapabilities#1064
Open
YousefHaggy wants to merge 3 commits into
Open
feat: add extensions attribute to ClientCapabilities and ServerCapabilities#1064YousefHaggy wants to merge 3 commits into
YousefHaggy wants to merge 3 commits into
Conversation
Add the optional `extensions` field to `ClientCapabilities`, mirroring the MCP extensions framework (SEP-2133) as declared in the draft schema and already shipped by the TypeScript, Python, C#, Go, Rust, and Kotlin SDKs. Keys are extension identifiers (e.g. "io.modelcontextprotocol/oauth-client-credentials") and values are per-extension settings objects; an empty object indicates support with no settings. The field is optional, defaults to null, and is omitted from the wire when unset, so it is backward compatible with existing peers. Follows CONTRIBUTING.md "Evolving wire-serialized records" Case A: the new component is appended, annotated with @JsonProperty, boxed/nullable, and the prior 4-arg constructor is retained as a source-compatible overload. Adds a builder `extensions(Map)` setter plus an `extension(id, settings)` helper that normalizes null settings to an empty object. Includes the required absent/omit/unknown-field tests plus a round-trip test in SchemaEvolutionTests. Refs modelcontextprotocol#785 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Mirror the ClientCapabilities `extensions` change on ServerCapabilities, as the MCP extensions framework (SEP-2133) declares the field on both capability objects. Same Case A treatment: appended optional component, retained 6-arg constructor overload, builder `extensions(Map)` + `extension(id, settings)` helper, and `mutate()` carries the new field. Adds absent/omit/round-trip tests in SchemaEvolutionTests. Refs modelcontextprotocol#785 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Keep only the whole-map extensions(Map) setter on both capability builders, matching the existing experimental(Map) convention. The per-entry extension(id, settings) helper was a novel API for a single field, duplicated verbatim across both builders, with copy-on-write merge semantics no sibling setter has. Callers pass Map.of(id, Map.of()) for "supported, no settings". Co-Authored-By: Claude Opus 4.8 <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.
Add the optional
extensionsfield toClientCapabilitiesandServerCapabilities, mirroring the MCP extensions framework (SEP-2133) as declared in the draft schema and already shipped by the TypeScript, Python, C#, Go, Rust, and Kotlin SDKs.Refs #785
Motivation and Context
Spec + cross-SDK precedent
ClientCapabilities(andServerCapabilities) in thedraft schema —
schema/draft/schema.ts#L785(server twin at
#L882) —introduced by SEP-2133
(merged into the spec 2026-01-26). Type:
{ [key: string]: object }. Keys areextension identifiers following
_metanaming rules; an empty object means"supported, no settings". See also the
extensions overview docs.
ClientCapabilities. Java is the only majorSDK without it:
extensions?: { [key: string]: JSONObject };extensions: dict[str, dict[str, Any]] | None = NoneIDictionary<string, object>? ExtensionsExtensions map[string]anyextensions: Option<ExtensionCapabilities>Map<String, JsonObject>? = nullHow Has This Been Tested?
Added 3 tests per new field per the contributing guidelines.
Breaking Changes
No breaking changes
Types of changes
Checklist
Additional context