Title: API Defined and/or Client-Defined Session IDs · Issue #231 · modelcontextprotocol/modelcontextprotocol · GitHub
Open Graph Title: API Defined and/or Client-Defined Session IDs · Issue #231 · modelcontextprotocol/modelcontextprotocol
X Title: API Defined and/or Client-Defined Session IDs · Issue #231 · modelcontextprotocol/modelcontextprotocol
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 th...
Open Graph 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 impl...
X 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 impl...
Opengraph URL: https://github.com/modelcontextprotocol/modelcontextprotocol/issues/231
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"API Defined and/or Client-Defined Session IDs","articleBody":"**Is your feature request related to a problem? Please describe.**\nThe latest specification for **stateful** HTTP connections mandates that the server issue a Session ID in the InitializeResponse. The implication of this is: \n1. 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. \n2. 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) \n\nSecondly, 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\n1. require them to keep track of a session ID\n2. potentially upgrade the connection to SSE and stream back a bunch of data\n\n**Describe the solution you'd like**\nTo be honest, I'm not yet sure the best way to deal with this. \n\nOption 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.\n\nOption 2: TBH this is more to get ideas flowing -- not yet convinced this is the right approach. \n1. 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. \n2. Introduce a capabilities key within tool specification. Example:\n```\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"result\": {\n \"tools\": [\n {\n \"name\": \"get_weather\",\n \"description\": \"Get current weather information for a location\",\n \"inputSchema\": {\n \"type\": \"object\",\n \"properties\": {\n \"location\": {\n \"type\": \"string\",\n \"description\": \"City name or zip code\"\n }\n },\n \"required\": [\"location\"],\n// [New] Note I thought this makes more sense here than capability negotiation because it seems tool-specific\n \"capabilities\": {\n \"transport\": {\n \"sse\": true/false,\n \"stateful\": true/false,\n \"customizableSessionIds\": true/false\n } \n }\n }\n }\n ],\n \"nextCursor\": \"next-page-cursor\"\n }\n}\n```\n3. Enable clients to set session ID IFF customizableSessionIds == true\n\nOne 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. \n\n","author":{"url":"https://github.com/000-000-000-000-000","@type":"Person","name":"000-000-000-000-000"},"datePublished":"2025-03-26T12:54:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/231/modelcontextprotocol/issues/231"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d92836f4-6b4b-ec06-3570-ee85f46d7f3f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF0A:1F2D8B:61E58D5:86B8E5C:6A5E7147 |
| html-safe-nonce | 1cbc046bd41d9b5e2e81baa7ac5b305823a0658023376b9baab7757af10e5e8f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjBBOjFGMkQ4Qjo2MUU1OEQ1Ojg2QjhFNUM6NkE1RTcxNDciLCJ2aXNpdG9yX2lkIjoiNzI5MTk5NTM0ODA4NDM1NTM5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 82cacde1fb68439f75c4780a65abba0293084d5d0b5727d83719ac138ce34f08 |
| hovercard-subject-tag | issue:2949512861 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/modelcontextprotocol/231/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ce19caa1660352e3f8440b0bbda08679901e194e965ceccf3b2fa317e016b9e/modelcontextprotocol/modelcontextprotocol/issues/231 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ce19caa1660352e3f8440b0bbda08679901e194e965ceccf3b2fa317e016b9e/modelcontextprotocol/modelcontextprotocol/issues/231 |
| og:image:alt | 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 impl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 000-000-000-000-000 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 71950bbe6bf7e15662b868c102fed9d1682c29a05970d9b2daa2e4dd3522c52e |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/modelcontextprotocol git https://github.com/modelcontextprotocol/modelcontextprotocol.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862570523 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/modelcontextprotocol |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862570523 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/modelcontextprotocol |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7514606601325843bc1c464d2d8bf5fe9af2c154 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width