| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
76c12274ef |
feat(core): add SEP-2575 request metadata and discovery types (#893)
## Summary Part of #815. Adds the core types and codecs needed for SEP-2575: - experimental accessors for request-scoped metadata while preserving legacy request shapes and unknown `_meta` entries; - `server/discover` request/result types, cache fields, and unsupported-version error data; and - polymorphic request/result decoding with wire-format and malformed-input coverage. The discovery types match the merged draft schema in modelcontextprotocol/modelcontextprotocol#3002: `protocolVersion` and `clientCapabilities` are required, `clientInfo` is optional, and optional server information remains in result `_meta`. ## Motivation and Context SEP-2575 moves protocol and client context onto individual requests and introduces `server/discover`. The shared `RequestMeta` accessors remain nullable so legacy requests stay representable; `DiscoverRequestParams` enforces the fields required by the new discovery request. This PR stops at the core type and codec boundary. It does not add server admission, request-scoped dispatch, Streamable HTTP, authentication, subscriptions, MRTR, lifecycle hooks, or a discovery DSL. ## How Has This Been Tested? - JVM: 597/597 tests - JS Node and Chrome: 528/528 tests per target - WasmJS Node and Chrome: 528/528 tests per target - iOS Simulator arm64 and macOS arm64: 528/528 tests per target - API dump/check, ktlint, detekt, and diff checks Coverage includes required discovery metadata, optional `clientInfo`, required cache fields, unknown metadata round-trips, the legacy `resultType` fallback, unsupported-version data, and polymorphic result classification. ## Breaking Changes This adds `DiscoverRequest` as a new `ClientRequest` subtype. Consumers recompiling exhaustive `when` expressions over `ClientRequest` may need to add a branch. Existing request types and wire representations are unchanged. ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed ## Additional context `ttlMs` and `cacheScope` have Kotlin construction defaults but remain required when decoding. An absent `resultType` decodes as `"complete"` for compatibility with legacy results. Discovery result selection requires the complete required shape so unrelated result extensions are not misclassified. --------- Co-authored-by: Pavel Gorgulov <devcrocod@gmail.com> |
||
|
|
beb3400064 |
feat(core): concurrent inbound dispatch behind an initialization gate (#884)
Make inbound message handling concurrent after the initialization handshake, so a slow or peer-awaiting handler no longer blocks other messages on the same connection fixes #176, #572 ## Motivation and Context Inbound messages were processed serially on the transport read loop. One slow or peer-awaiting request handler (sampling, elicitation, roots) blocked every later message on that connection, including the responses and `notifications/cancelled` those handlers depend on which could deadlock request/response flows. ## How Has This Been Tested? New and old tests ## Breaking Changes - after the handshake, inbound handlers may run concurrently (processing stays serial during initialization). There is no opt-out flag by design, concurrency is bounded by `maxConcurrentHandlers` / `maxInFlightHandlers`. - `ProtocolOptions` / `ClientOptions` / `ServerOptions` gain new parameters with defaults - `RequestHandlerExtra` is now a coroutine-context element and is no longer user-constructible ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
420b64d1bb |
chore(deps): bump the kotlin group across 1 directory with 2 updates (#834)
Bumps the kotlin group with 2 updates in the / directory: [org.jetbrains.kotlin:kotlin-gradle-plugin](https://github.com/JetBrains/kotlin) and [org.jetbrains.kotlin:kotlin-serialization](https://github.com/JetBrains/kotlin). Updates `org.jetbrains.kotlin:kotlin-gradle-plugin` from 2.3.21 to 2.4.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/JetBrains/kotlin/releases">org.jetbrains.kotlin:kotlin-gradle-plugin's releases</a>.</em></p> <blockquote> <h2>Kotlin 2.4.0</h2> <h2>Changelog</h2> <h3>Analysis API</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-83867"><code>KT-83867</code></a> OVERLOAD_RESOLUTION_AMBIGUITY false positive with assertEquals in IJ repo</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83723"><code>KT-83723</code></a> [Analysis API] Enable experimental KDoc resolver by default</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83388"><code>KT-83388</code></a> Analysis API: properly support KMP in KotlinPackageProvider</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-65683"><code>KT-65683</code></a> Analysis API: Dangling file session creation causes a <code>computeIfAbsent</code> contract violation</li> </ul> <h3>Analysis API. Code Compilation</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-78946"><code>KT-78946</code></a> Evaluation of variable with local class in type parameter leads to InventNamesForLocalClasses exception</li> </ul> <h3>Analysis API. FIR</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-68260"><code>KT-68260</code></a> K2 AA: InvalidFirElementTypeException “For CALLABLE_REFERENCE_EXPRESSION with text <code>::lam1</code>, unexpected element of type: no element found” with illegal callable reference call</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-70896"><code>KT-70896</code></a> AA: False positive deprecation warning with override of built-in method in JDK mapped class</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84711"><code>KT-84711</code></a> K2 IDE sometimes loses FIR plugin-generated declarations after file changes</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84625"><code>KT-84625</code></a> Analysis API: collectDesignationPath fails for nested classes inside plugin-generated top-level classes</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84596"><code>KT-84596</code></a> Improve K2 Jooq completion performance</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84525"><code>KT-84525</code></a> KaValueParameterSymbol#getHasSynthesizedName returns false for FirDeclarationOrigin.SubstitutionOverride.DeclarationSite</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83546"><code>KT-83546</code></a> Kotlin analysis reach ClsCustomNavigationPolicy</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84259"><code>KT-84259</code></a> Move CommonDefaultImportsProvider to the frontend independent module</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-82945"><code>KT-82945</code></a> Analysis API: KotlinIllegalArgumentExceptionWithAttachments: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-71135"><code>KT-71135</code></a> AA: exception from sealed inheritors checker when <code>analyzeCopy</code></li> </ul> <h3>Analysis API. Infrastructure</h3> <h4>Fixes</h4> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-83905"><code>KT-83905</code></a> Analysis API: Improve UX with test data</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84913"><code>KT-84913</code></a> Extract compiler classes used by the PSI & Analysis API to a separate module</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-64986"><code>KT-64986</code></a> Analysis API: Implement Analysis API tests for different KMP Platforms</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84776"><code>KT-84776</code></a> The test data manager misses the redundancy check in the update mode</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84962"><code>KT-84962</code></a> The test data manager misses -ea flag</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84388"><code>KT-84388</code></a> Preserve the EOF status in the test data manager to avoid extra changes</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84362"><code>KT-84362</code></a> Analysis API tests produce many warnings due to "not yet loaded registry"</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84279"><code>KT-84279</code></a> Test Data Manager fails on a clean build</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83913"><code>KT-83913</code></a> Exclude compiler-based Analysis API tests from Git tracking</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-80379"><code>KT-80379</code></a> Extract per-module test generators for AA tests</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84120"><code>KT-84120</code></a> Move CLI modules out of kotlin-compiler-fe10-for-ide</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83200"><code>KT-83200</code></a> Track external dependencies of the Analysis API modules</li> </ul> <h3>Analysis API. Light Classes</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-82434"><code>KT-82434</code></a> Light classes should prefer enum entries to properties</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84200"><code>KT-84200</code></a> SLC: return type is not boxed for delegated methods with generic original method</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-72451"><code>KT-72451</code></a> "CCE: class PsiPrimitiveType cannot be cast to class PsiClassType" with same-named enum class and typealias</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md">org.jetbrains.kotlin:kotlin-gradle-plugin's changelog</a>.</em></p> <blockquote> <h2>2.4.0</h2> <h3>Analysis API</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-83867"><code>KT-83867</code></a> OVERLOAD_RESOLUTION_AMBIGUITY false positive with assertEquals in IJ repo</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83723"><code>KT-83723</code></a> [Analysis API] Enable experimental KDoc resolver by default</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83388"><code>KT-83388</code></a> Analysis API: properly support KMP in KotlinPackageProvider</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-65683"><code>KT-65683</code></a> Analysis API: Dangling file session creation causes a <code>computeIfAbsent</code> contract violation</li> </ul> <h3>Analysis API. Code Compilation</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-78946"><code>KT-78946</code></a> Evaluation of variable with local class in type parameter leads to InventNamesForLocalClasses exception</li> </ul> <h3>Analysis API. FIR</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-68260"><code>KT-68260</code></a> K2 AA: InvalidFirElementTypeException “For CALLABLE_REFERENCE_EXPRESSION with text <code>::lam1</code>, unexpected element of type: no element found” with illegal callable reference call</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-70896"><code>KT-70896</code></a> AA: False positive deprecation warning with override of built-in method in JDK mapped class</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84711"><code>KT-84711</code></a> K2 IDE sometimes loses FIR plugin-generated declarations after file changes</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84625"><code>KT-84625</code></a> Analysis API: collectDesignationPath fails for nested classes inside plugin-generated top-level classes</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84596"><code>KT-84596</code></a> Improve K2 Jooq completion performance</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84525"><code>KT-84525</code></a> KaValueParameterSymbol#getHasSynthesizedName returns false for FirDeclarationOrigin.SubstitutionOverride.DeclarationSite</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83546"><code>KT-83546</code></a> Kotlin analysis reach ClsCustomNavigationPolicy</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84259"><code>KT-84259</code></a> Move CommonDefaultImportsProvider to the frontend independent module</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-82945"><code>KT-82945</code></a> Analysis API: KotlinIllegalArgumentExceptionWithAttachments: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-71135"><code>KT-71135</code></a> AA: exception from sealed inheritors checker when <code>analyzeCopy</code></li> </ul> <h3>Analysis API. Infrastructure</h3> <h4>Fixes</h4> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-83905"><code>KT-83905</code></a> Analysis API: Improve UX with test data</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84913"><code>KT-84913</code></a> Extract compiler classes used by the PSI & Analysis API to a separate module</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-64986"><code>KT-64986</code></a> Analysis API: Implement Analysis API tests for different KMP Platforms</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84776"><code>KT-84776</code></a> The test data manager misses the redundancy check in the update mode</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84962"><code>KT-84962</code></a> The test data manager misses -ea flag</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84388"><code>KT-84388</code></a> Preserve the EOF status in the test data manager to avoid extra changes</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84362"><code>KT-84362</code></a> Analysis API tests produce many warnings due to "not yet loaded registry"</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84279"><code>KT-84279</code></a> Test Data Manager fails on a clean build</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83913"><code>KT-83913</code></a> Exclude compiler-based Analysis API tests from Git tracking</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-80379"><code>KT-80379</code></a> Extract per-module test generators for AA tests</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84120"><code>KT-84120</code></a> Move CLI modules out of kotlin-compiler-fe10-for-ide</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-83200"><code>KT-83200</code></a> Track external dependencies of the Analysis API modules</li> </ul> <h3>Analysis API. Light Classes</h3> <ul> <li><a href="https://youtrack.jetbrains.com/issue/KT-82434"><code>KT-82434</code></a> Light classes should prefer enum entries to properties</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-84200"><code>KT-84200</code></a> SLC: return type is not boxed for delegated methods with generic original method</li> <li><a href="https://youtrack.jetbrains.com/issue/KT-72451"><code>KT-72451</code></a> "CCE: class PsiPrimitiveType cannot be cast to class PsiClassType" with same-named enum class and typealias</li> </ul> <h3>Analysis API. PSI</h3> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href=" |
||
|
|
57e546d378 |
feat: SEP-1686 Tasks (#844)
finished SEP-1686 closes #421 ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
c8a1103b16 |
feat: sep-1036 add URL Mode Elicitation (#843)
closes #410 ## How Has This Been Tested? integration and unit tests ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
6e6f80512f |
Merge commit from fork | ||
|
|
ebc53f0ded |
feat!: capabilities for tasks, elicitation (#732)
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) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
f434fcaff1 |
feat!: SEP-1577 sampling with tools (#718)
Implements SEP-1577 sampling With tools closes #409 ## How Has This Been Tested? unit + integration ## Breaking Changes - binary changes - MediaContent -> SamplingMessageContent - ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
bf8dc6d6b1 |
feat(core): add extensions field to ClientCapabilities and ServerCapabilities (#678)
<!-- Provide a brief summary of your changes -->
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
<!-- Why is this change needed? What problem does it solve? -->
Extensions are supported part of the [MCP spec
](https://modelcontextprotocol.io/extensions/overview) and are available
in other language libraries e.g. [Golang
](
|
||
|
|
61fab2ffe0 |
feat: add $schema field to ToolSchema per SEP-1613 (#696)
Add optional `$schema` field to `ToolSchema`, establishing JSON Schema 2020-12 as the default dialect per SEP-1613. closes #422 ## How Has This Been Tested? unit tests ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
e5e5ec206f |
feat: add notification for elicitation complete (#667)
closes #546 ## How Has This Been Tested? unit ## Breaking Changes none ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed |
||
|
|
fdecf6bdf5 |
feat: add URL mode elicitation and typed schema definitions per MCP (#660)
Add URL mode elicitation support and typed `PrimitiveSchemaDefinition` hierarchy to align with MCP specification 2025-11-25 closes #540 ## How Has This Been Tested? unit/integration/conformance ## Breaking Changes - `ElicitRequestParams` changed from `data class` to `sealed interface`. A deprecated factory function preserves source compatibility for `ElicitRequestParams(message, requestedSchema)`. - `RequestedSchema.properties` changed from `JsonObject` to `Map<String, PrimitiveSchemaDefinition>`. - `ElicitRequest.requestedSchema` is deprecated, use `(params as ElicitRequestFormParams).requestedSchema`. ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
558399039c |
chore: deprecation cycle (#615)
Remove all deprecation with error level ## Motivation and Context next minor release ## How Has This Been Tested? - ## Breaking Changes Removing it is a binary-incompatible change ## 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 - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
fd3a8583b8 |
feat: add tasks models (#566)
## Motivation and Context closes #421 #406 ## How Has This Been Tested? Unit tests ## Breaking Changes NaN ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
ee6561c185 |
feat: #502 resource templates with basic template matcher (#606) | ||
|
|
338f94804f |
feat: add tool execution properties to Tool (#567)
closes #543 ## How Has This Been Tested? unit ## Breaking Changes binary compatibility in the Tool class ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed --------- Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com> |
||
|
|
1b255a2baf |
Add $defs to ToolSchema and tests (#526)
Add $defs support in ToolSchema and update tests. Motivation and Context Fix parsing when tool schemas include $defs. How Has This Been Tested? `./gradlew :kotlin-sdk-core:jvmTest --tests "io.modelcontextprotocol.kotlin.sdk.types.ToolsTest"` Breaking Changes No. Types of changes - [x] 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 - [x] I have read the MCP Documentation - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed Additional context N/A |
||
|
|
6120b3109e |
refactor: Introduce AbstractClientTransport and simplify client transport lifecycle (#517) (#516)
## refactor: Introduce AbstractClientTransport and simplify client transport lifecycle This PR unifies state management logic across client transports, except for the websocket transport, as it needs more refactoring first and is not the primary transport. - Introduce `AbstractClientTransport` as base class for other client transports. - Migrate to `ClientTransportState` states with state machine, streamline state management. - Ensure proper cleanup and error handling consistency across transport implementations. - Add unit tests to validate `AbstractClientTransport` behavior and state transitions. - Update related documentation and API contract. - Make sure `onClose` callback is called at most once - fix [StreamableHttpClientTransportTest.kt](https://github.com/modelcontextprotocol/kotlin-sdk/pull/516/changes#diff-b9fe8891d08a492448a7ed2dc782151c6a915ae1403a4d70c2034c6062c84cb5) to throw `McpException` on connect when received invalid Json ## Motivation and Context Unify lifecycle handling and eliminate duplication in client Transport implementations. ## How Has This Been Tested? Unit test, regression tests ## Breaking Changes - `onClose` callback is now called only once - send(...) will throw McpException with message "Transport is not ready" when `ClientTransportState != Operational` ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] Refactoring - [ ] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] 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 See #517 |
||
|
|
6fee82ff1a |
Mark DSL functions for types as public (#472)
<!-- Provide a brief summary of your changes -->
## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
The dsl builders in [this
commit](
|
||
|
|
10a0b67204 |
[WIP] StreamableHttpServerTransport implementation (#449)
# [WIP] StreamableHttpServerTransport implementation - Implement StreamableHttpServerTransport for MCP spec - Support both SSE streaming and direct HTTP JSON responses - Add event store interface for resumability > [!IMPORTANT] > The work is in progress. StreamableHttpServerTransport is not production-ready yet!!! Based on #235 ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> ## Breaking Changes None ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
6ec6d3c52f |
Better exception handling in StdioClientTransport (#444)
# Better exception handling in StdioClientTransport Refactor `McpException` for improved handling with convenience constructors and enhanced exception wrapping logic in `StdioClientTransport`. Update tests to use `kotest` matchers and add JUnit parameterized tests for exception handling. ## Motivation and Context #442 follow up ## How Has This Been Tested? <!-- Have you tested this in a real application? Which scenarios were tested? --> ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] 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 <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [ ] 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 <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
6dd9c80335 |
Add convenience constructors to JSONRPCRequest (#336)
- Add convenience constructors to JSONRPCRequest - Make UUID string a default JSONRPCRequest ## Motivation and Context To create request objects more easily ## How Has This Been Tested? Unit tests ## Breaking Changes No, this is a new API ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] 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 <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
2b9dfd9466 |
Add options in Transport.send method (#408)
Add support for `TransportSendOptions` in `Transport.send` method ## Motivation and Context This change extends the `Transport.send` method signature to support advanced transport features like resumption tokens and progress callbacks. This is needed to enable: - Long-running request resumption after reconnection - Request-response association tracking - Progress token handling in transport layer needed for #235 ## How Has This Been Tested? All transport tests passed ## Breaking Changes Yes, it’s necessary to update the custom Transport implementations. For users who rely on the transports provided by the sdk, there’s no breaking change ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
74c93745cd |
Proposal: DSL Builders for request types (#399)
This PR introduces type-safe DSL builders for all MCP request types,
making it easier to construct requests
### Current Solution
All request types now have DSL builders:
```kotlin
// Initialize request
val request = initializeRequest {
protocolVersion = "2024-11-05"
capabilities {
sampling(ClientCapabilities.sampling)
roots(listChanged = true)
}
info("MyClient", "1.0.0")
}
// Create message request with conversation
val messageRequest = createMessageRequest {
maxTokens = 1000
systemPrompt = "You are a helpful assistant"
messages {
user { "What is the capital of France?" }
assistant { "The capital of France is Paris." }
user { "What about Germany?" }
}
}
// Call tool request
val toolRequest = callToolRequest {
name = "searchDatabase"
arguments {
put("query", "users")
put("limit", 10)
}
}
// Elicit request with schema
val elicitRequest = elicitationRequest {
message = "Please provide your contact information"
requestedSchema {
properties {
put("email", JsonObject(mapOf(
"type" to JsonPrimitive("string"),
"description" to JsonPrimitive("Your email address")
)))
}
required = listOf("email")
}
}
```
Each DSL builder includes:
- Clear separation of required (but runtime) vs optional fields
- Multiple usage examples
- Concise error messages with examples when required fields are missing
- Cross-references to related types
### Design Considerations
1. Function Naming Convention
The current naming convention (e.g., initializeRequest, callToolRequest) might be confusing since these functions don't send requests, they just build request objects.
Alternative approach: Add a build prefix to clarify intent:
- `initializeRequest` → `buildInitializeRequest`
- `callToolRequest` → `buildCallToolRequest`
- `createMessageRequest` → `buildCreateMessageRequest`
This would make it clearer that these are builder functions.
2. Runtime vs Compile-Time Validation
Currently, required fields are validated at runtime in the `build()` method:
```kotlin
val request = initializeRequest {
protocolVersion = "2024-11-05"
// Missing required fields: capabilities, info
// Error thrown at runtime ❌
}
```
Alternative approach: Use Compose UI style where required parameters are in the function signature:
```kotlin
fun initializeRequest(
protocolVersion: String,
capabilities: ClientCapabilities,
info: Implementation,
block: InitializeRequestBuilder.() -> Unit = {}
): InitializeRequest
```
```kotlin
// Usage
val request = initializeRequest(
protocolVersion = "2024-11-05",
capabilities = ClientCapabilities(sampling =
ClientCapabilities.sampling),
info = Implementation("MyClient", "1.0.0")
) {
// Optional fields only
meta { put("key", "value") }
}
```
Pros:
- Compile-time safety for required fields ✅
- Clear which fields are required ✅
- Better IDE autocomplete ✅
Cons:
- Multiple trailing lambdas can be confusing:
```kotlin
// When required fields include lambdas
val request = elicitationRequest(
message = "Enter info",
requestedSchema = { /* lambda 1 */ }
) { /* lambda 2 for optional fields */ }
```
- Less consistent DSL feel
- More verbose for simple cases
|
||
|
|
93d544e618 |
Add experimental mcpClient(...) factory method (#396)
- Introduced `@ExperimentalMcpApi` annotation to mark experimental APIs. - Added `mcpClient` function for initializing and connecting MCP clients. - Modified tests to utilize the new `mcpClient` function. - Refactored variable naming in transport tests for improved readability. ## Motivation and Context To improve the creation of the MCP Client experience. ## How Has This Been Tested? Integration test updated ## Breaking Changes No ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
8bdbd36c32 |
Add backwards compatibility constructors and tests (#395)
- Updated integration tests to include assertions for `meta` being `null` in the `listTools`, `listResources`, `readResource`, and `callTool` results. - Renamed test cases in `SseServerIntegrationTest` for clarity. - Added (deprecated) synthetic constructors for various request parameter classes. - Enhanced naming conventions and structure in integration test cases. - Replaced `throw Error(...)` with `error(...)` for cleaner error handling. ## Motivation and Context To verify backwards-compatibility after schema change ## How Has This Been Tested? CI, integration tests, regression tests (samples) ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] 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 - [x] Test update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] 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 <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
5636faf60c |
Updated ServerPromptsTest, move AbstractTransport to it's own file (#376)
# Refactor and enhance prompt handling logic and tests, update Kotest version and modularize `AbstractTransport` - Added more post-conditions/scenarios to ServerPromptsTest - Extracted `AbstractTransport` to a dedicated file for modularity. - Improved Protocol connection state validation: When disconnected, the Protocol will throw `IllegalStateException` instead of `Error`. - Minor Kotlin fixes and suppressions to improve code quality. ## Motivation and Context Improve test scenarios in ServerPromptsTest ## How Has This Been Tested? Integration tests updated ## Breaking Changes When disconnected, the Protocol will throw `IllegalStateException` instead of `Error`. ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [x] Test update - [x] Refactoring ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
13f858d5d2 |
Add new helper properties to request and notification types (#388)
Add properties for types of new schema ## Motivation and Context Added getters to simplify access to properties in request and notification types. ## How Has This Been Tested? All tests pass ## Breaking Changes None ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed |
||
|
|
21393e7ce3 |
New MCP Schema types (#386)
Implement the last version of the mcp schema and complete restructuring of the mcp schema implementation from a monolithic `types.kt` file into separate files. - #158 - #185 - #353 - #298 - #248 ## Motivation and Context The previous implementation of the mcp schema was outdated and contained several issues. In addition, it stored all mcp types in a single large file, which made maintenance and further development more difficult ## How Has This Been Tested? All tests passed ## Breaking Changes Yes. The new types are now located in a separate package. Additionally, many types have new parameters and modified constructors ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed ## Additional context to adopt the new structure: **Before:** ```kotlin import io.modelcontextprotocol.kotlin.sdk.InitializeRequest import io.modelcontextprotocol.kotlin.sdk.Resource ``` **After:** ```kotlin import io.modelcontextprotocol.kotlin.sdk.types.InitializeRequest import io.modelcontextprotocol.kotlin.sdk.types.Resource ``` |
||
|
|
e6432dbf26 |
Replace Instant with String for lastModified in Annotations (#383)
Replace `Instant` with `String` for `lastModified` in `Annotations` ## Motivation and Context To fix serialization/kotlin library version conflicts ## How Has This Been Tested? Unit test ## Breaking Changes Yes ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [x] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] 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 <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
e4bd866fdd |
Adds optional _meta field to Tool (#339)
<!-- Provide a brief summary of your changes --> ## Motivation and Context The recently released openAI [Apps SDK ](https://developers.openai.com/apps-sdk/reference/#_meta-fields-the-client-provides)adds a '__meta_' field on the Tool Descriptor. This would be in addition to it being available on Messages. It remains optional and defaults to an empty json object, following existing conventions. ## How Has This Been Tested? Unit tests for serialization added ## Breaking Changes N/A ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [X] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [X] My code follows the repository's style guidelines - [X] New and existing tests pass locally - [X] I have added appropriate error handling - [X] I have added or updated documentation as needed ## Additional context https://developers.openai.com/apps-sdk https://developers.openai.com/apps-sdk/reference/#_meta-fields-the-client-provides --------- Co-authored-by: Pavel Gorgulov <devcrocod@gmail.com> |
||
|
|
2f1b659efd |
Adds 'instructions' string to the Server and propagates to the InitializeResult (#290)
<!-- Provide a brief summary of your changes -->
## Motivation and Context
The
[schema](
|
||
|
|
73c0af891b |
Disable OpenAPI Generator (#301)
One may run it manually to generate classes from JSON Schema ## Motivation and Context Most of the generated classes could not be used in the current API today. On the other hand, it is useful to be able to generate such classes to simplify manual API synchronization. So, Gradle plugin configuration is preserved, but detached from the build pipeline. |
||
|
|
d962e28ff7 |
Generate MCP classes with OpenAPI Generator (#294)
- Add OpenAPI Generator to build system to automatically generate MCP protocol data classes from the official schema. - Configure code quality tools to exclude generated files - Add deserialization test ## Motivation and Context Writing classes by hand is error-prone, when json schema exists. See #185, Also, autogenerating model classes ensures the SDK is in sync with the protocol and can quickly catch up with its changes (see #218) ## How Has This Been Tested? Regression tests ## Breaking Changes No ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [ ] 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 <!-- Add any other context, implementation notes, or design decisions --> |
||
|
|
ad8205297e |
Add missing title, size and annotation attributes on Resource/ResourceTemplate and other types (#219)
* Add missing resource and resource template title and size * Add missing annotations * Add serialization test for Annotations * Dump APIs |
||
|
|
fc02cecb79 |
rename ResourceReference to ResourceTemplateReference (#193)
* chore: rename ResourceReference to ResourceTemplateReference * rename resource references in tests and update api --------- Co-authored-by: devcrocod <devcrocod@gmail.com> |
||
|
|
8698b96dd2 |
modularize sdk (#208)
* Modularize SDK: migrated client and server implementations to separate modules. Removed old configuration files and reorganized the source code structure * add support native targets and update js/wasm configurations * Refactor sample projects: add samples as composite builds, replace hardcoded dependencies with version catalog, remove obsolete gradle wrapper files * Update .gitignore: exclude SWE agent directories (.claude/ and .junie/) * Refine CodeQL workflow: update Kotlin build steps to target individual modules separately instead of building all at once |
Renamed from api/kotlin-sdk.api (Previous history)