kotlin-sdk/kotlin-sdk-core
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yusuf İhsan Görgel 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>
2026-08-05 23:20:07 +02:00
..
api feat(core): add SEP-2575 request metadata and discovery types (#893) 2026-08-05 23:20:07 +02:00
src feat(core): add SEP-2575 request metadata and discovery types (#893) 2026-08-05 23:20:07 +02:00
build.gradle.kts refactor: explicit locked detekt config (#729) 2026-04-29 12:31:49 +02:00
detekt-baseline-main.xml refactor: explicit locked detekt config (#729) 2026-04-29 12:31:49 +02:00
Module.md docs: Update readme, enable Knit (#162) (#510) 2026-02-06 18:40:31 +02:00