MCPSERV.CLUB
kEND

MCP over SSE Server

MCP Server

Server‑Side Event implementation of the Model Context Protocol

Stale(50)
64stars
2views
Updated Aug 20, 2025

About

This Elixir library implements a full MCP server over Server‑Sent Events, supporting Phoenix and Plug/Bandit applications. It handles JSON‑RPC messaging, tool registration, session management, keepalive pings, and provides a plug‑in for quick integration.

Capabilities

Resources
Access data sources
Tools
Execute functions
Prompts
Pre-built templates
Sampling
AI model interactions

MCP over SSE – A Lightweight, Plug‑Friendly MCP Server

The mcp_sse library implements the Model Context Protocol (MCP) over Server‑Sent Events (SSE), providing a minimal yet fully compliant MCP server that can be dropped into any Elixir application. It solves the common pain point of wiring an AI assistant to external tools: developers no longer need to hand‑craft JSON‑RPC endpoints or manage long‑lived WebSocket connections. Instead, a single SSE endpoint exposes the entire MCP surface—initialisation, ping, tool registration, and execution—in a streaming fashion that is both browser‑friendly and easy to test with simple HTTP clients.

At its core, the server follows the MCP specification exactly. When a client opens an SSE stream, the server negotiates the protocol version and establishes a session. From that point on, every JSON‑RPC message sent by the client is routed through a small dispatcher that calls user‑implemented callbacks. The library supplies a behaviour and a macro that injects routing logic, protocol validation, error handling, and logging. Developers only need to implement two mandatory callbacks— for session setup and for keep‑alive checks—while optional callbacks enable tool registration, sampling, and custom error handling.

Key capabilities include:

  • Full MCP support: initialization, ping, tool registration and execution, session management, and response formatting.
  • SSE‑based streaming: responses are pushed as messages, allowing the client to consume data incrementally without polling.
  • JSON‑RPC integration: every MCP message is wrapped in a standard JSON‑RPC envelope, making it compatible with existing RPC tooling.
  • Automatic keepalive: the server sends periodic pings to maintain the connection and detect dropped clients.
  • Plug/ Phoenix compatibility: a single plug () can be wired into any router, and the library automatically configures MIME types for .

Real‑world scenarios that benefit from this server include:

  • Tool‑enabled AI assistants: expose custom command execution (e.g., database queries, file operations) to a Claude or GPT‑style assistant.
  • Interactive notebooks: stream live computation results back to a front‑end that consumes SSE streams.
  • CI/CD pipelines: run dynamic tests or deployment steps triggered by an AI assistant, with immediate feedback streamed to the user.
  • Educational platforms: provide sandboxed execution environments where an AI tutor can invoke code snippets and stream results.

Because the server is built on top of standard Elixir libraries (Plug, Bandit, Phoenix), it integrates seamlessly into existing workflows. Developers can spin up a new MCP server with a handful of configuration lines, or extend an existing Phoenix application by adding a single route. The behaviour encourages clean separation of concerns: the plug handles HTTP/SSE plumbing, while your module implements business logic. This modularity makes it straightforward to add features such as authentication, rate limiting, or custom logging without touching the core protocol handling.

In summary, mcp_sse delivers a ready‑to‑use, specification‑compliant MCP server that leverages SSE for efficient streaming. It removes boilerplate, reduces the risk of protocol errors, and fits naturally into modern Elixir web stacks—enabling developers to focus on building powerful AI‑driven tools rather than low‑level networking details.