What is SSE transport in MCP
SSE transport in MCP (Model Context Protocol) is a communication method using Server-Sent Events to stream data from an AI agent server to a client in real time. It enables efficient, low-latency updates without requiring the client to repeatedly poll the server.How it works
SSE transport uses a persistent HTTP connection where the server continuously sends text-based event data to the client. Unlike WebSockets, SSE is unidirectional (server to client) and simpler to implement. In MCP, this allows AI agents to stream responses or state updates live, similar to a news feed updating in real time.
Think of SSE as a radio broadcast: the server is the radio station sending signals, and the client is the radio receiver continuously listening without needing to ask for each update.
Concrete example
Here is a minimal Python example showing how an MCP server might send SSE events to a client:
from flask import Flask, Response
import time
app = Flask(__name__)
def event_stream():
for i in range(5):
yield f"data: Update {i}\n\n"
time.sleep(1)
@app.route('/mcp-sse')
def sse():
return Response(event_stream(), mimetype='text/event-stream')
if __name__ == '__main__':
app.run(debug=True, threaded=True) When to use it
Use SSE transport in MCP when you need a simple, reliable way to stream continuous AI agent outputs or state changes to clients without complex bidirectional communication. It is ideal for live updates, logs, or streaming partial AI responses.
Do not use SSE if you require full bidirectional communication or need to send large binary data; WebSockets or other protocols are better suited then.
Key terms
| Term | Definition |
|---|---|
| MCP | Model Context Protocol for connecting AI agents to tools and resources. |
| SSE | Server-Sent Events, a unidirectional HTTP streaming protocol from server to client. |
| Transport | The communication method or protocol used to send data between client and server. |
Key Takeaways
- SSE transport streams real-time data from MCP servers to clients over HTTP efficiently.
- It is unidirectional, making it simpler than WebSockets for continuous AI agent updates.
- Use SSE in MCP for live AI output streaming but not for bidirectional or binary data needs.