What is SSE?
Quick definition
Server-Sent Events: a standard HTTP protocol enabling servers to push real-time data updates to connected clients over a persistent connection without requiring client polling.
Server-Sent Events (SSE) is a web standard that allows servers to send unsolicited messages to clients through a single HTTP connection. Unlike traditional request-response patterns where clients must repeatedly poll the server for updates, SSE establishes a persistent, one-directional communication channel. The server can push data to the client whenever events occur, making it ideal for real-time applications that need efficient, low-latency updates.
SSE is built on top of standard HTTP and uses a simple text-based format for transmitting events. Each event consists of optional fields like id, retry, and data, allowing servers to organize and manage event streams effectively. The connection remains open, reducing overhead compared to repeated HTTP requests and avoiding the complexity of bidirectional protocols like WebSockets.
In the context of AI agents and MCP (Model Context Protocol) servers, SSE enables efficient streaming of tool outputs, agent responses, and real-time task updates. MCP servers can leverage SSE to send continuous streams of data—such as progress updates, log entries, or incremental results—directly to connected clients, making it essential for responsive agentic workflows and agent orchestration systems where timely information delivery is critical.
Example
How it shows up in practice
curl -N https://api.example.com/events
data: {"status": "task_updated", "task_id": 123}
id: 1
retry: 5000
data: {"status": "task_completed", "result": "success"}
id: 2Frequently asked questions
How does SSE differ from WebSockets?
SSE uses one-way server-to-client communication over standard HTTP, while WebSockets provide bidirectional full-duplex communication. SSE is simpler for push-only scenarios; WebSockets are better for interactive, two-way exchanges like real-time chat or collaborative tools.
Can SSE work with AI agents and MCP servers?
Yes, SSE is excellent for MCP servers streaming tool outputs and agent responses. It allows servers to push incremental results, status updates, and progress notifications to AI agents and clients without polling, improving responsiveness.
What are the limitations of SSE?
SSE supports only server-to-client communication. Connection limits vary by browser (typically 6 per domain). It requires the server to hold connections open, which can impact server scalability under heavy loads compared to stateless request-response patterns.
How do I implement SSE in a Node.js server?
Set response headers to 'Content-Type: text/event-stream' and 'Connection: keep-alive', then write formatted data like 'data: {json}\n\n'. Keep the response open and write events as they occur. Libraries like Express and frameworks support SSE endpoints natively.