Skip to content

feat!: capabilities for tasks, elicitation#732

Open
devcrocod wants to merge 1 commit intomainfrom
feat/issue-544-capabilities
Open

feat!: capabilities for tasks, elicitation#732
devcrocod wants to merge 1 commit intomainfrom
feat/issue-544-capabilities

Conversation

@devcrocod
Copy link
Copy Markdown
Contributor

@devcrocod devcrocod commented Apr 29, 2026

closes #544

Replaces opaque JsonObject? modelling of elicitation with a typed ClientCapabilities.Elicitation (form, url), and adds the new tasks capability on both ClientCapabilities and ServerCapabilities (with list, cancel, per-request-type augmentation). Wires capability assertions for tasks/* methods and notifications/tasks/status into Client and ServerSession

How Has This Been Tested?

unit tests

Breaking Changes

yes
now elicitation is a specific class in capabilities

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

Copilot AI review requested due to automatic review settings April 29, 2026 12:01
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

This PR updates the Kotlin MCP SDK capability model to add first-class tasks capabilities and to make elicitation capabilities structured/typed (rather than an opaque JsonObject), along with updating client/server strict-capability assertions and related tests.

Changes:

  • Add typed ClientCapabilities.Elicitation (form/url sub-capabilities) and introduce ClientCapabilities.Tasks / ServerCapabilities.Tasks.
  • Enforce tasks capability checks for tasks/* requests and notifications/tasks/status in Client and ServerSession.
  • Update DSL/tests and API surface snapshots to reflect the new typed capability shapes.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
kotlin-sdk-server/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/server/ServerSessionAssertCapabilityTest.kt Adds tests covering server-side capability assertions for tasks methods/notifications.
kotlin-sdk-server/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/server/ServerSession.kt Adds tasks capability enforcement for outgoing tasks/* requests and notifications/tasks/status.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/dsl/InitializeDslTest.kt Updates DSL tests to use typed elicitation capabilities.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/dsl/CapabilitiesDslTest.kt Updates capabilities DSL tests for typed elicitation.
kotlin-sdk-core/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/types/CapabilitiesTest.kt Expands serialization/deserialization coverage for tasks + typed elicitation.
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types/capabilities.kt Introduces typed elicitation + tasks capability models (client/server) and deprecation bridge.
kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types/capabilities.dsl.kt Updates DSL to accept typed elicitation (but currently lacks tasks support).
kotlin-sdk-core/api/kotlin-sdk-core.api Updates public API snapshot for new capability types and signature changes.
kotlin-sdk-client/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/ClientAssertCapabilityTest.kt Adds tests covering client-side capability assertions for tasks methods/notifications.
kotlin-sdk-client/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/client/Client.kt Adds tasks capability enforcement for outgoing tasks/* requests and notifications/tasks/status.
integration-test/src/commonTest/kotlin/io/modelcontextprotocol/kotlin/sdk/client/ClientTest.kt Updates integration tests to use typed elicitation.

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

Comment on lines +272 to +276
Method.Defined.TasksGet,
Method.Defined.TasksResult,
Method.Defined.TasksList,
Method.Defined.TasksCancel,
-> assertTasksCapabilityForMethod(method)
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Tasks methods were added to assertCapabilityForMethod, but assertRequestHandlerCapability still has no gating for tasks/* handlers. Since tasks requests can be received by either side, this allows registering handlers for tasks/get|result|list|cancel without advertising ClientCapabilities.tasks (and without checking list/cancel sub-capabilities). Consider adding corresponding tasks/* cases in assertRequestHandlerCapability that validate capabilities.tasks and, for list/cancel, capabilities.tasks.list/capabilities.tasks.cancel.

Copilot uses AI. Check for mistakes.
Comment on lines +168 to +172
Defined.TasksGet,
Defined.TasksResult,
Defined.TasksList,
Defined.TasksCancel,
-> assertTasksCapabilityForMethod(method)
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

Tasks methods were added to assertCapabilityForMethod (remote capability check), but assertRequestHandlerCapability still doesn’t enforce ServerCapabilities.tasks when registering local handlers for tasks/* requests. Since tasks requests are bidirectional, this can result in the server handling tasks/get|result|list|cancel without advertising tasks support (and without checking list/cancel sub-capabilities). Consider adding tasks/* cases to assertRequestHandlerCapability that validate serverCapabilities.tasks and the relevant sub-capability fields for list/cancel.

Copilot uses AI. Check for mistakes.
@devcrocod devcrocod force-pushed the feat/issue-544-capabilities branch from dda5a10 to 81c792c Compare May 5, 2026 14:58
@devcrocod devcrocod marked this pull request as ready for review May 5, 2026 20:24
@devcrocod devcrocod requested review from Copilot and e5l May 5, 2026 20:24
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 11 out of 11 changed files in this pull request and generated 3 comments.


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

Comment on lines 38 to 44
public class ClientCapabilitiesBuilder @PublishedApi internal constructor() {
private var sampling: ClientCapabilities.Sampling? = null
private var roots: ClientCapabilities.Roots? = null
private var elicitation: JsonObject? = null
private var elicitation: ClientCapabilities.Elicitation? = null
private var extensions: Map<String, JsonObject>? = null
private var experimental: JsonObject? = null

Comment on lines +271 to +276
Method.Defined.TasksGet,
Method.Defined.TasksResult,
Method.Defined.TasksList,
Method.Defined.TasksCancel,
-> assertTasksCapabilityForMethod(method)

Comment on lines +177 to +180
Defined.TasksList,
Defined.TasksCancel,
-> assertTasksCapabilityForMethod(method)

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.

Capabilities extensions for tasks and sampling/elicitation detail

2 participants