-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Is your feature request related to a problem? Please describe.
The latest specification for stateful HTTP connections mandates that the server issue a Session ID in the InitializeResponse. The implication of this is:
- In the event that the MCP server fronts a service which already has a notion of sessions, the client will need to keep track of two different session IDs (one provided by MCP server and the other provided in a subsequent response payload from the service itself) which effectively represent the same session.
- The session ID can never be customized by the client, meaning client may need to maintain a mapping between its session identifier (e.g. user-xyz-chat-abcd) and the MCP server session identifier(s) (note the two sessions may not even be 1-1 depending on the application definition of sessions)
Secondly, clients don't have a good way to know whether a tool uses SSE / statefulness. This means that clients can't know ahead of time whether a tool will
- require them to keep track of a session ID
- potentially upgrade the connection to SSE and stream back a bunch of data
Describe the solution you'd like
To be honest, I'm not yet sure the best way to deal with this.
Option 1: Maybe there is some good reason for this rigidity. In which case, probably folks can implement nice client-side abstractions backed by cloud dbs or caches to deal with this tracking.
Option 2: TBH this is more to get ideas flowing -- not yet convinced this is the right approach.
- If MCP Server could issue a session ID post-initialization it would enable it to issue the service session ID as its session ID, resolving the duplication.
- Introduce a capabilities key within tool specification. Example:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
"name": "get_weather",
"description": "Get current weather information for a location",
"inputSchema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name or zip code"
}
},
"required": ["location"],
// [New] Note I thought this makes more sense here than capability negotiation because it seems tool-specific
"capabilities": {
"transport": {
"sse": true/false,
"stateful": true/false,
"customizableSessionIds": true/false
}
}
}
}
],
"nextCursor": "next-page-cursor"
}
}
- Enable clients to set session ID IFF customizableSessionIds == true
One thing I see as an issue in long run is: Clients + Servers can make more informed decisions if metadata given during capability negotiation and (potentially) tool discovery is thorough. On the other hand, to avoid breaking consumers, new keys we introduce in these metadata documents must be optional. This means that it will be a best effort thing for servers to implement these fields and likely many servers will not. This makes these metadata less valuable to consumers.