MCP over SSE
About
An elixir Model Context Protocal (MCP) server library which uses the Server-Sent Events (SSE) transport type
Details
- License
- MIT
Explore
- Full MCP server implementation
- SSE connection management
- JSON-RPC message handling
- Tool registration and execution
- Session management
- Automatic ping/keepalive
- Error handling and validation
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP over SSECommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
config :mime, :types, %{
"text/event-stream" => ["sse"]
}
config :mcp_sse, :mcp_server, YourApp.YourMCPServer
2. Add to your dependencies in mix.exs:
elixirdef deps do
[
{:mcp_sse, "~> 0.1.6"}
]
end
3. Configure your router (lib/your_app_web/router.ex):
elixirpipeline :sse do
plug :accepts, ["sse"]
end
scope "/" do
pipe_through :sse
get "/sse", SSE.ConnectionPlug, :call
post "/message", SSE.ConnectionPlug, :call
end
4. Run your application:
bashmix phx.server
To see the MCP server in action:
1. Start a server in one terminal:
bash
// Connect to SSE endpoint
const sse = new EventSource('/sse');
// Handle endpoint message
sse.addEventListener('endpoint', (e) => {
const messageEndpoint = e.data;
// Use messageEndpoint for subsequent JSON-RPC requests
});
// Send initialize request
fetch('/message?sessionId=YOUR_SESSION_ID', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: {}
}
})
});
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp over sse": {
"mcp_sse": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector@latest"
],
"env": {
"MCP_SERVER_URL": "localhost:4000"
}
}
}
}
}
McpServers
{
"mcp_sse": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector@latest"
],
"env": {
"MCP_SERVER_URL": "localhost:4000"
}
}
}
This library provides a simple implementation of the Model Context Protocol (MCP) over Server-Sent Events (SSE).
For more information about the Model Context Protocol, visit:
Model Context Protocol Documentation.
Table of Contents
- Features
- Create your own MCP server
- Installation
- For Phoenix Applications
- For Plug Applications with Bandit
- Usage
- With MCP Inspector
- With Cursor
- Configuration
- Port and HTTPS
- Paths
- Keepalive
- Quick Demo
- Other Notes
- Example Client Usage
- Session Management
- MCP Response Formatting
- Contributing
Features
- Full MCP server implementation
- SSE connection management
- JSON-RPC message handling
- Tool registration and execution
- Session management
- Automatic ping/keepalive
- Error handling and validation
Create your own MCP server
You must implement the MCPServer behaviour.
You only need to implement the required callbacks (handle_ping/1 and handle_initialize/2) and any optional callbacks for features you want to support.
The use MCPServer macro provides:
- Built-in message routing
- Protocol version validation
- Default implementations for optional callbacks
- JSON-RPC error handling
- Logging
See DefaultServer for a default implementation of the MCPServer behaviour.
Installation
For Phoenix Applications:
1. Add the required configuration to config/config.exs:
```elixir
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



