Title: Proposal: Optional High Availability Best Practices for MCP Deployments with Stateful Streaming (SSE) Connections · Issue #2000 · modelcontextprotocol/modelcontextprotocol · GitHub
Open Graph Title: Proposal: Optional High Availability Best Practices for MCP Deployments with Stateful Streaming (SSE) Connections · Issue #2000 · modelcontextprotocol/modelcontextprotocol
X Title: Proposal: Optional High Availability Best Practices for MCP Deployments with Stateful Streaming (SSE) Connections · Issue #2000 · modelcontextprotocol/modelcontextprotocol
Description: TL;DR Summary Proposal: Introduce optional High Availability best practices for MCP deployments to address session continuity and failover in stateful streaming (SSE) connections. Focuses on HA challenges in long-lived streaming sessions...
Open Graph Description: TL;DR Summary Proposal: Introduce optional High Availability best practices for MCP deployments to address session continuity and failover in stateful streaming (SSE) connections. Focuses on HA cha...
X Description: TL;DR Summary Proposal: Introduce optional High Availability best practices for MCP deployments to address session continuity and failover in stateful streaming (SSE) connections. Focuses on HA cha...
Opengraph URL: https://github.com/modelcontextprotocol/modelcontextprotocol/issues/2000
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Optional High Availability Best Practices for MCP Deployments with Stateful Streaming (SSE) Connections","articleBody":"# TL;DR Summary\n\n**Proposal:** Introduce optional High Availability best practices for MCP deployments to address **session continuity and failover in stateful streaming (SSE) connections**. \n- Focuses on **HA challenges in long-lived streaming sessions** behind load balancers. \n- Recommends **non-normative, optional patterns** (pub-sub, cluster coordination, middleware, session partitioning). \n\n---\n\n## Background / Community Context\n\nMCP deployments increasingly target **production environments** with multiple replicas and distributed workloads. Real-world deployments face challenges when **stateful streaming sessions** coexist with **stateless HTTP ingress**. \n\nAdditionally, the community has previously discussed handling MCP sessions behind load balancers (see GitHub PR #325). Contributors highlighted that MCP’s stateful session establishment (e.g., via SSE) can conflict with stateless load balancing unless session affinity is maintained. The conversation concluded that while session stickiness is a practical consideration, specifying such behavior at the protocol level was not appropriate; instead, guidance for gateways and high‑availability deployments would be valuable. ([github.com](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/325))\n\nKey points from the discussion: \n\n- **Session continuity**: Long-lived connections (SSE) may be routed to different replicas, breaking sessions without sticky sessions. \n- **Implementation discretion**: Session management, sticky sessions, and shared session stores are left to implementers. \n- **Best practices guidance**: The community sees value in providing **optional HA patterns or gateway guidance** rather than normative protocol changes.\n\nThis context provides **direct support for proposing optional HA best practices**, aligning with ongoing community awareness of multi-node deployment challenges.\n\n---\n\n## Goals\n\n- Enable MCP servers to **scale horizontally** while preserving session continuity. \n- Avoid reliance on sticky sessions at the load balancer level. \n- Keep MCP **protocol semantics unchanged**. \n- Provide **implementation-agnostic guidance** applicable to diverse transports and environments. \n- Allow gradual adoption without disrupting existing deployments.\n\n---\n\n## Non-Goals\n\n- Mandating specific HA mechanisms or middleware. \n- Introducing protocol-level changes to MCP messages. \n- Replacing existing transports or enforcing Streamable HTTP. \n- Evaluating or criticizing specific platforms or client ecosystems.\n\n---\n\n## Motivation: HA Necessity in Production Deployments\n\nProduction MCP deployments face several HA-related challenges:\n\n- **Stateless ingress vs. stateful session/streaming egress**: load balancers can route connections to different replicas, causing session disruption. \n- **Single-node failure or restart** can interrupt ongoing streaming sessions. \n- **Session resumption across replicas** is non-trivial without additional coordination. \n\nThese issues exist independently of the underlying transport or client support and justify optional HA patterns for reliable operation in multi-node deployments.\n\n---\n\n## Optional HA Patterns\n\n### 1. Core HA Patterns (Optional)\n\n#### 1.1 Event Bus / Pub-Sub\n\n- Externalize session events to a **distributed pub-sub system**. \n- Multiple MCP server replicas can **subscribe and replay events** transparently. \n- Decouples session lifetime from any single server node. \n- Enables failover and session recovery without client awareness.\n\n#### 1.2 Cluster Coordination \u0026 P2P Forwarding\n\n- MCP nodes maintain **lightweight cluster state** via gossip, shared stores, or JDBC ping. \n- Session messages can be **forwarded peer-to-peer** to the node currently handling the session. \n- Provides **best-effort replication and routing** for streaming events. \n- Avoids heavy consensus mechanisms (e.g., Raft) to preserve throughput.\n\n---\n\n### 2. Implementation \u0026 Optimization Support (Optional)\n\n#### 2.1 Middleware / SDK Abstraction\n\n- Encapsulates HA logic (pub-sub, P2P forwarding). \n- Keeps protocol handlers and business logic unchanged. \n- Provides a transparent API for SDK consumers. \n- Optional per deployment, allows gradual adoption.\n\n#### 2.2 Session Partitioning / Affinity Hints\n\n- Opaque session IDs may encode **internal partitioning or affinity hints**. \n- Reduces coordination overhead in large clusters. \n- Affinity is advisory; correctness must not depend on it. \n- Complements middleware, pub-sub, or P2P forwarding.\n\n---\n\n## Illustrative Middleware-Oriented Model (Python, Non-Normative)\n\n```python\nasync def handle_mcp_message(message, send):\n if message[\"type\"] == \"tool_call\":\n result = await run_tool(message[\"payload\"])\n await send({\n \"type\": \"tool_result\",\n \"payload\": result\n })\n\nclass MCPHAMiddleware:\n def __init__(self, ha_backend):\n self.ha = ha_backend\n\n def wrap(self, handler):\n async def wrapped(message, send):\n session_id = self.ha.ensure_session(message)\n\n async with self.ha.bind_session(session_id, send) as ha_send:\n await handler(message, ha_send)\n\n return wrapped\n````\n\n* Business logic remains unchanged.\n* HA logic (pub-sub, gossip, session partition) is fully encapsulated.\n* Works in both single-node and multi-node deployments.\n\n---\n\n## Compatibility\n\n* Fully backward compatible with existing MCP servers.\n* HA support is optional and implementation-defined.\n* Does not require clients to be aware of HA mechanisms.\n* Can coexist with Streamable HTTP.\n\n---\n\n## Summary\n\nProduction MCP deployments need HA considerations to maintain reliability and scalability. This proposal:\n\n* Highlights HA challenges.\n* Recommends **optional, non-invasive best practices**.\n* Maintains protocol compatibility and low intrusion.\n* Supports gradual adoption as ecosystems evolve.","author":{"url":"https://github.com/jizhuozhi","@type":"Person","name":"jizhuozhi"},"datePublished":"2025-12-20T19:40:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2000/modelcontextprotocol/issues/2000"}
| 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:7cf28fe6-a1be-1628-de8d-bc97fd042048 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A54E:171905:37C67F:4A0570:6A5B26DD |
| html-safe-nonce | d162da9ecd2313561fdfa98c67aad2a9f53834caf6b99709b0eaf045eb19b261 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTRFOjE3MTkwNTozN0M2N0Y6NEEwNTcwOjZBNUIyNkREIiwidmlzaXRvcl9pZCI6IjUyMTg1MjAzNTYwMzA3MTk3MDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2056e3d7136455725428b14e8be81a0d16839b414de2899bfc4fe23e12a383a5 |
| hovercard-subject-tag | issue:3750348206 |
| 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/2000/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b972a84a73b6a06c9a910c25671bc875217cb9d39938f5367f604fe24cf149d0/modelcontextprotocol/modelcontextprotocol/issues/2000 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b972a84a73b6a06c9a910c25671bc875217cb9d39938f5367f604fe24cf149d0/modelcontextprotocol/modelcontextprotocol/issues/2000 |
| og:image:alt | TL;DR Summary Proposal: Introduce optional High Availability best practices for MCP deployments to address session continuity and failover in stateful streaming (SSE) connections. Focuses on HA cha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jizhuozhi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width