Home

Server-Sent Events (SSE) Protocol

This section explains how MCP servers use Server-Sent Events (SSE) for real-time communication, performance monitoring, and streaming capabilities.

What is Server-Sent Events (SSE)?

Server-Sent Events (SSE) is a standard HTTP-based technology that enables servers to push updates to clients over a single, long-lived connection. Unlike WebSockets, SSE is unidirectional (server to client only) and operates over standard HTTP, making it simpler to implement and more compatible with existing infrastructure.

Key Features of SSE

How MCP Servers Use SSE

MCP servers leverage SSE for several critical functions:

  1. Real-time Metrics: Stream performance metrics and resource utilization data
  2. Log Streaming: Provide real-time access to server logs
  3. Stateful Responses: Stream partial responses as they become available
  4. Status Updates: Notify clients of deployment and operational status changes
  5. Progress Indicators: Communicate progress during long-running operations

Table of Contents

Example SSE Flow

Here's a simplified diagram of how SSE works with MCP servers:

Client                                                MCP Server
  │                                                      │
  │  1. HTTP GET /api/servers/{id}/events                │
  │ ─────────────────────────────────────────────────────>
  │                                                      │
  │  2. HTTP 200 OK                                      │
  │  Content-Type: text/event-stream                     │
  │ <─────────────────────────────────────────────────────
  │                                                      │
  │  3. event: metrics                                   │
  │     data: {"cpu": 23, "memory": 128, "requests": 45} │
  │ <─────────────────────────────────────────────────────
  │                                                      │
  │  4. event: log                                       │
  │     data: {"level": "info", "msg": "Request processed"} │
  │ <─────────────────────────────────────────────────────
  │                                                      │
  │                  ... Connection remains open ...     │
  │                                                      │
  │  5. event: status                                    │
  │     data: {"status": "scaling", "instances": 2}      │
  │ <─────────────────────────────────────────────────────
  │                                                      │

Benefits for Integration

Using SSE for integrations with workflow management tools like n8n provides several advantages:

  1. Lower Latency: Real-time updates without polling
  2. Reduced Overhead: Single persistent connection instead of multiple requests
  3. Simplified Error Handling: Automatic reconnection in case of network issues
  4. Event-Driven Workflows: Trigger workflows based on specific events
  5. Efficient Resource Usage: Lower server load compared to polling approaches