Skip to content

feat(core): add extensions field to ClientCapabilities and ServerCapabilities#678

Open
eritscher wants to merge 1 commit intomodelcontextprotocol:mainfrom
eritscher:add-extensions-capabilities
Open

feat(core): add extensions field to ClientCapabilities and ServerCapabilities#678
eritscher wants to merge 1 commit intomodelcontextprotocol:mainfrom
eritscher:add-extensions-capabilities

Conversation

@eritscher
Copy link
Copy Markdown

@eritscher eritscher commented Apr 7, 2026

Add support for MCP extension negotiation during the initialize handshake, as defined in the MCP extensions specification. Clients and servers can now advertise supported extensions via a new extensions: Map<String, JsonObject>? field on their respective capabilities objects.

Motivation and Context

Extensions are supported part of the MCP spec and are available in other language libraries e.g. Golang .

How Has This Been Tested?

Existing and added unit tests

Breaking Changes

Adding a new field to existing ClientCapabilities and ServerCapabilities fields will break already compiled clients. They will need to recompile on upgrading.

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

Copilot AI review requested due to automatic review settings April 7, 2026 00:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds MCP extension negotiation support by introducing an extensions capabilities field so clients/servers can advertise supported extensions (with optional per-extension settings) during the initialize handshake.

Changes:

  • Add extensions: Map<String, JsonObject>? to ClientCapabilities and ServerCapabilities (serializable).
  • Extend the client capabilities DSL to set extensions, and add/expand tests covering DSL + serialization behavior.
  • Update the published API surface file to reflect the new constructors/components.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types/capabilities.kt Adds extensions to capability data classes and updates KDoc.
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types/capabilities.dsl.kt Adds extensions(...) to ClientCapabilitiesBuilder.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/dsl/InitializeDslTest.kt Verifies initialize DSL can set/read extensions.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/dsl/CapabilitiesDslTest.kt Adds DSL tests for null/empty/overwrite behavior for extensions.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/CapabilitiesTest.kt Adds serialization + round-trip coverage for extensions on both client/server capabilities.
kotlin-sdk-core/api/kotlin-sdk-core.api Updates API signatures for new capability fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @eritscher

That looks good! Could you please take a look at the ktlint issues and also address the GitHub Copilot findings?

@kpavlov kpavlov added enhancement New feature or request api Public API changes labels Apr 7, 2026
@eritscher eritscher force-pushed the add-extensions-capabilities branch from 171a9e8 to bc8514d Compare April 7, 2026 13:38
@eritscher eritscher requested review from Copilot and kpavlov April 7, 2026 13:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 55 to 59
public val roots: Roots? = null,
public val elicitation: JsonObject? = null,
public val experimental: JsonObject? = null,
public val extensions: Map<String, JsonObject>? = null,
) {
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the new extensions parameter to ClientCapabilities changes the primary constructor/signature and Kotlin default-args synthetic constructor, which is ABI-breaking for already-compiled Kotlin/Java consumers (potential NoSuchMethodError). This should be called out as a breaking change in the PR/release notes, or mitigated by preserving the old constructor signature (e.g., a deprecated secondary constructor delegating to the new one with extensions = null).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

@eritscher eritscher Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kpavlov not sure if this is a false positive. It doesn't look anything has been done to preserve constructor signatures in the past. I can mention this in the PR description.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

Comment on lines 108 to +112
val prompts: Prompts? = null,
val logging: JsonObject? = null,
val completions: JsonObject? = null,
val experimental: JsonObject? = null,
val extensions: Map<String, JsonObject>? = null,
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ABI concern as ClientCapabilities: adding extensions changes the ServerCapabilities constructor and breaks binary compatibility for compiled consumers. Please mark as breaking and/or add a compatibility constructor overload delegating with extensions = null.

Copilot uses AI. Check for mistakes.
@kpavlov kpavlov added the breaking Breaking changes label Apr 7, 2026
@kpavlov kpavlov force-pushed the add-extensions-capabilities branch from bc8514d to 924f425 Compare April 7, 2026 14:36
@kpavlov kpavlov requested a review from devcrocod April 7, 2026 14:37
Copilot AI review requested due to automatic review settings April 9, 2026 14:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@eritscher
Copy link
Copy Markdown
Author

@kpavlov / @devcrocod
Anything else you think I should check on this PR? If not, mind approving the conformance tests?

…bilities

Add support for MCP extension negotiation during the initialize handshake,
as defined in the MCP extensions specification. Clients and servers can now
advertise supported extensions via a new `extensions: Map<String, JsonObject>?`
field on their respective capabilities objects.
@kpavlov kpavlov force-pushed the add-extensions-capabilities branch from d073294 to b6eaeb6 Compare April 10, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Public API changes breaking Breaking changes enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants