modelcontextprotocol / modelcontextprotocol/kotlin-sdk

Make client information available in server handlers

Open
#552 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api enhancement P2 ready for work
Dominant language
Kotlin
Stars
1.5k
Forks
248
Avg merge
1d 20h
Merged PRs (30d)
23

Description

Is your feature request related to a problem? Please describe.

It is not possible for server handlers (e.g. tools) to react to information about the client that is connected. Information that is useful includes:

  • The client's name & version (aka Implementation) - useful for patching around specific client behaviors, if some are known to behave poorly or need special handling.
  • The client capabilities. This is required to know which messages can be sent without resulting in unexpected exceptions or erroneous handling. Graceful fallback is often required when certain capabilities are not supported by clients. It's not really possible to do this currently - calling non-supported methods results in non-specific IllegalStateExceptions, which could have come from anywhere.

While server capabilities could also be helpful, it's something that you control anyways, so it's much less impactful.

Describe the solution you'd like

Add clientImplementation and clientCapabilities to ClientConnection.

Describe alternatives you've considered

There's a workaround, which is to use the session ID to extract the full ServerSession object from the Server instance. But that's ugly and awkward.

Additional context
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ClientConnection and the server-handler APIs, then inspect the ServerSession workaround described in the issue to understand where client data is already available. Done means server handlers can access the client's implementation and capabilities without extracting ServerSession through a session ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.