Driven by the wave of digitalization, data transmission protocols are undergoing unprecedented transformations. Today, we focus on a significant innovation within the MCP (Model Context Protocol) — Streamable HTTP. This new protocol not only simplifies the traditional HTTP+SSE transmission method but also opens up new pathways for data interaction with features such as stateless server support and pure HTTP implementation. Let us delve into this innovative technology that leads a new era of data transmission.
The Background and Importance of the MCP Protocol
The MCP protocol (Model Context Protocol) is an open protocol designed to provide a standardized solution for seamless integration between large language models (LLM) and external data sources and tools. It simplifies the connection between AI applications and external resources through a unified interface, reducing integration complexity and providing developers with flexible tool invocation capabilities. The core of MCP lies in its bidirectional communication mechanism, supporting real-time data interaction and automation of complex tasks.
As application scenarios become increasingly complex, the traditional HTTP+SSE transmission method has gradually revealed its limitations. SSE requires long connections and only supports unidirectional communication, which can be inflexible in certain scenarios. The emergence of Streamable HTTP aims to break through these bottlenecks and inject new vitality into the MCP protocol.
Simplifying Transmission, Enhancing Efficiency
Technical Principles and Working Mode
Streamable HTTP is designed based on the HTTP protocol, supporting both HTTP POST and GET requests through a single MCP endpoint (e.g., <span>/message</span>
). Its workflow can be roughly divided into the following steps:
-
Message Sending:
- The client sends JSON-RPC messages to the MCP endpoint using HTTP POST. Each POST request is an independent message transmission, ensuring data real-time.
- The POST request must include the
<span>Accept</span>
header, indicating that the client supports both<span>application/json</span>
and<span>text/event-stream</span>
data formats, preparing for subsequent streaming transmission.
Message Reception and Response:
- For POST requests containing request messages, the server will open an SSE (Server-Sent Events) stream with
<span>Content-Type: text/event-stream</span>
based on the request content, or directly return a JSON object. - Once the server starts the SSE stream, it will continuously send JSON-RPC messages related to the client’s request, ensuring that all requests receive a response.
Streaming Transmission and Reconnection:
- The server supports sending multiple responses or notifications within the SSE stream, and can even push all subsequent messages before the stream closes, ensuring the integrity of information transmission.
- To cope with network fluctuations or unexpected disconnections, the server can implement stream recovery functionality through additional event IDs. The client, when reconnecting, carries the
<span>Last-Event-ID</span>
, and the server replays the messages that were not sent during the disconnection based on that ID.
Session Management and Multi-Connection Support:
- To ensure data consistency across multiple connections, the server can generate a globally unique session identifier through
<span>Mcp-Session-Id</span>
during the initialization phase. Each subsequent request must carry this identifier for the server to associate messages with the corresponding session. - At the same time, the client can connect to multiple SSE streams simultaneously, but the server ensures that each JSON-RPC message is transmitted in only one stream, avoiding data redundancy caused by duplicate broadcasting.
Comparison with the Old HTTP+SSE
In the early HTTP+SSE transmission method, there were certain limitations in data interaction between the client and server, such as:
- After the SSE stream closes, the client finds it difficult to ensure message integrity.
- For batch message transmission, there is a lack of clear message boundaries and retransmission mechanisms.
- Session management and state maintenance are relatively weak, making it difficult to adapt to large-scale concurrent scenarios.
Streamable HTTP effectively addresses these issues by introducing more comprehensive message distribution, reconnection, and session management mechanisms. Its advantages mainly include:
- Improved Real-Time Performance: By independently POSTing each message and continuously transmitting the SSE stream, the client can receive server responses in real-time, significantly reducing system latency.
- Connection Elasticity and Fault Tolerance: Using
<span>Last-Event-ID</span>
and other disconnection reconnection strategies ensures seamless message transmission even in fluctuating network environments. - Flexible Session Management: By generating encrypted session IDs, communication across devices and processes becomes more secure and reliable.
- Compatibility and Extensibility: It can accommodate the usage scenarios of the old HTTP+SSE while providing standardized interfaces for future custom transmission protocols, reserving ample space for technological evolution.
Why Not Choose WebSocket
The team discussed in detail the possibility of using WebSocket as the primary transmission protocol but ultimately decided against it for the following reasons:
- In “RPC-style” usage scenarios, it incurs unnecessary operational and network overhead.
- The browser cannot attach authorization and other header information.
- Only GET requests can be transparently upgraded to WebSocket, requiring a complex two-step upgrade process.
Application Scenarios
Efficient Collaboration of Autonomous Agents
In future AI systems, autonomous agents will be ubiquitous — from smart homes and autonomous driving to industrial robots, all requiring high-speed information exchange among multiple nodes. Traditional communication protocols often struggle to handle massive, concurrent messages, while the MCP protocol leverages the advantages of Streamable HTTP to achieve:
- Low-Latency Communication: Autonomous agents can quickly transmit commands and status information to each other, ensuring a more real-time and efficient decision-making process.
- Message Retransmission Mechanism: Through disconnection reconnection and message retransmission, it avoids data loss due to network instability, significantly enhancing system stability.
- Flexible Scalability: The new protocol allows autonomous agents to customize transmission methods as needed, flexibly adapting to the requirements of different scenarios while ensuring compatibility.
Distributed AI Platforms and Data Collaboration
Currently, many large cloud platforms and AI service providers are laying out distributed AI platforms, where the real-time and integrity of data interaction become key to the platform’s success. Streamable HTTP provides a solid technical guarantee for this goal:
- Cross-Platform Data Synchronization: Whether in cloud services or edge devices, using the unified MCP protocol enables real-time data synchronization, breaking down information silos.
- High Concurrency Support: Thanks to the new transmission mechanism supporting multiple connections and message batching, the system can operate stably in high-concurrency environments, adapting to large-scale user access.
- Secure Session Management: Through encrypted session IDs and strict protocol agreements, it ensures security and privacy protection during data transmission, receiving unanimous praise from industry security experts.
Other Application Scenarios
Streamable HTTP is suitable for various scenarios, including:
- Real-Time Chat Applications: Providing low-latency, reliable data transmission to enhance user experience.
- Large File Downloads: Supporting efficient file transfers.
- Streaming Media Services: Ensuring smooth media content transmission.
Future Outlook
The emergence of Streamable HTTP not only addresses many pain points of traditional transmission methods but also opens up infinite possibilities for the future development of the MCP protocol. With continuous technological advancements and the expansion of application scenarios, Streamable HTTP is expected to shine in more fields.
Imagine in the future smart cities, Streamable HTTP can efficiently connect various sensors and data centers, achieving real-time data interaction; in the medical field, it can help doctors quickly access patients’ medical records and diagnostic information; in education, it can facilitate smoother communication between students and teachers. These scenarios are just the tip of the iceberg; the potential of Streamable HTTP goes far beyond this.
Conclusion
The emergence of Streamable HTTP is an important milestone in the development history of the MCP protocol. With advantages such as simplified transmission, enhanced efficiency, and lowered barriers, it brings a new experience to data interaction. For developers and enterprises, embracing this change is not only an upgrade of technology but also a strategic layout for future development.
Let us look forward to the application of Streamable HTTP in more fields and witness how it leads a new era of data transmission. In this opportunity-filled era, every innovation could become a chance to change the world. Are you ready to embrace this transformation?