Expand description
SSE (Server-Sent Events) transport for the MCP server.
§MCP SSE Protocol
GET /sse— establish SSE stream, receiveendpointevent with POST URLPOST /messages?session_id=<id>— send JSON-RPC requests
§Thread safety
rusqlite::Connection is not Send+Sync, so we can’t share it across
async tasks. Instead, we open a fresh read-only connection per request
inside spawn_blocking. Since SQLite reads take <1ms and the connection
open is ~0.5ms, this overhead is negligible for an SSE server that
handles maybe 1-5 requests/second.
§Reference
MCP SSE spec: https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse
Structs§
- AppState 🔒
- Shared application state (thread-safe — no rusqlite in here).
Functions§
- handle_
message 🔒 - POST /messages?session_id=
— receive JSON-RPC, respond via SSE. - handle_
sse 🔒 - GET /sse — establish SSE connection, return event stream.
- run_sse
- Run the MCP server in SSE mode (async, multi-session).
Type Aliases§
- Session
Map 🔒 - Per-session state: an SSE sender channel.