McpSseServer class
SSE transport for the runtime MCP server.
Listens on 127.0.0.1:[port] (or 0.0.0.0 when authToken is
set, mirroring the WebSocket server's behaviour) and exposes:
GET /sse— opens the SSE stream; the first event isendpointwith the message POST URL the client should use. Subsequent events are JSON-RPC responses to the client's POSTed requests, keyed byid.POST /message?sessionId=<id>— accepts a JSON-RPC request body and dispatches it to the McpToolRegistry.GET /health— returns{"status": "ok"}for readiness probes.
Constructors
-
McpSseServer({required McpToolRegistry registry, String serverName = 'zuraffa-app-mcp', String serverVersion = '1.0.0', String? authToken, int? maxConnections, Map<
String, Set< ? toolAllowlist})String> >
Properties
- authToken → String?
-
final
- boundPort → int?
-
The bound port. Returns
nullbefore start runs or after stop. If start was called with port0(ephemeral), this returns the OS-assigned port. Useful for tests.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isRunning → bool
-
Whether the server is currently listening.
no setter
- maxConnections → int?
-
Maximum number of concurrent SSE sessions. When non-null and the
limit is reached, new
GET /sseconnections are rejected with HTTP 503.null(default) means unbounded. See zuraffa#384, req #3.final - registry → McpToolRegistry
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serverName → String
-
final
- serverVersion → String
-
final
-
toolAllowlist
→ Map<
String, Set< ?String> > -
Per-token tool allowlists passed through to
McpAuth. When non-null, a caller may only invoke the tools listed for its bearer token. See zuraffa#384, req #3.final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
{int port = 8372}) → Future< void> -
Starts listening on
port. Returns when the server is bound. -
stop(
) → Future< void> - Stops the server gracefully. Safe to call after start or after a failed start attempt. Closes all open SSE streams (so connected clients observe a clean stream termination), then stops listening without force-closing sockets so in-flight requests can drain.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited