## 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>