mcp: add Extensions field to capabilities per SEP-2133#794
Merged
maciej-kisiel merged 4 commits intomodelcontextprotocol:mainfrom Feb 17, 2026
Merged
mcp: add Extensions field to capabilities per SEP-2133#794maciej-kisiel merged 4 commits intomodelcontextprotocol:mainfrom
maciej-kisiel merged 4 commits intomodelcontextprotocol:mainfrom
Conversation
Implement SEP-2133 which defines a formal `extensions` field for MCP
capability negotiation. This allows clients and servers to advertise
support for formally recognized, composable extensions during
initialization, using the "{vendor-prefix}/{extension-name}" identifier
format (e.g., "io.modelcontextprotocol/oauth-client-credentials").
Changes to mcp/protocol.go:
- Add `Extensions map[string]any` field with `json:"extensions,omitempty"`
tag to both ClientCapabilities and ServerCapabilities, following the
same pattern as the existing Experimental field.
- Add AddExtension(name string, settings map[string]any) helper methods
on both capability structs. These lazily initialize the Extensions map
and normalize nil settings to an empty map[string]any{}, enforcing the
spec requirement that each extension's settings value must be a JSON
object (never null).
- Update both clone() methods to clone the Extensions map via
maps.Clone, preventing shared mutation between the original and cloned
capabilities. Add "maps" import.
Changes to mcp/server_test.go:
- Add "extensions preserved" test case to TestServerCapabilities,
verifying extensions set via AddExtension (including nil settings
normalization) appear in computed capabilities.
- Add "Extensions over wire" test case to TestServerCapabilitiesOverWire,
verifying extensions round-trip through the initialize handshake.
- Add TestAddExtensionNilSafety, verifying that AddExtension with nil
settings produces map[string]any{} (not nil) for both
ServerCapabilities and ClientCapabilities.
Changes to mcp/client_test.go:
- Add "extensions preserved" test case to TestClientCapabilities,
verifying extensions set via AddExtension appear in computed
capabilities.
- Add "Extensions over wire" test case to TestClientCapabilitiesOverWire,
verifying client extensions round-trip through the initialize
handshake.
Fixes modelcontextprotocol#777
anowardear062-svg
approved these changes
Feb 16, 2026
anowardear062-svg
approved these changes
Feb 16, 2026
maciej-kisiel
requested changes
Feb 16, 2026
Contributor
|
Also, please fix lint. |
Move misplaced clone() doc comment to its correct location above the method, and remove TestAddExtensionNilSafety which duplicates coverage already provided by TestServerCapabilities and TestClientCapabilities.
Shallow-copy the Experimental map in both ClientCapabilities.clone and ServerCapabilities.clone, matching the existing pattern for Extensions. Add doc comments clarifying that map values are shallow-copied and that callers should not modify maps after assigning them.
Contributor
Author
|
Addressed all review comments, including the lint error. |
maciej-kisiel
approved these changes
Feb 17, 2026
Contributor
|
Thanks for contributing! |
rafaeljusto
added a commit
to Teamwork/mcp
that referenced
this pull request
Feb 27, 2026
Enable the Apps extension: https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx Related to: * modelcontextprotocol/go-sdk#794 * #156
10 tasks
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.
This implements SEP-2133 and resolves #777.
Summary of changes
Extensionsfield toServerCapabilitiesandClientCapabilitiesstructs per SEP-2133AddExtensionhelper methods on both types that normalize nil settings to empty maps.maps.Clonein the existingclone()methodsExperimentalfield.What's tested
go test ./mcp/...passes