StreamableHttpServerTransport class

MCP 2025-03-26 StreamableHTTP Server Transport Implementation Supports both JSON responses and SSE streaming according to MCP standard

Implemented types

Constructors

StreamableHttpServerTransport({required StreamableHttpServerConfig config, @Deprecated('sessionId parameter is ignored. StreamableHTTP now manages multiple sessions internally.') String? sessionId})

Properties

boundPort → int?
The port actually listened on once start completes — differs from config.port when that is 0 or a fallback port was taken.
no setter
config → StreamableHttpServerConfig
final
hashCode → int
The hash code for this object.
no setterinherited
onClose → Future<void>
Future that completes when the transport is closed
no setteroverride
onMessage → Stream
Stream of incoming messages
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sessionId → String
Get session ID - deprecated Returns empty string as this transport now manages multiple sessions
no setter

Methods

close() → void
Close the transport
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(dynamic message) → void
Send a message through the transport
override
setAuthorizer(Future<HttpAuthDecision> authorizer(String? bearer, List<Map<String, dynamic>> messages)) → void
Register the server's decision for each HTTP request's credentials: every POST (with its messages), GET and DELETE asks it first.
setNegotiatedVersionResolver(String? r(String sessionId)) → void
Injected by Server on connect so the transport can version-gate JSON-RPC batching on the session's negotiated protocol revision.
setProtectedResourceMetadataProvider(Map<String, dynamic>? provider()) → void
Register a callback the transport will invoke to populate the .well-known/oauth-protected-resource document. Returning null from the callback causes the route to respond with 404.
start() → Future<void>
Start the HTTP server
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

authCallerKey → const String
Internal message key: the caller the authorizer accepted for this HTTP request (an AuthContext, or null for an anonymous one).
cancelInflightKey → const String
Internal message key: the client of a 2026-07-28 request closed its stream, which cancels the request ({_cancelInflight, _sessionId, id}).
mcpParamsKey → const String
Internal message key: the request's Mcp-Param-* headers (lower-cased name part → raw value), for the server to check against the arguments.
noResponseKey → const String
Marks an outbound message that ends a request's HTTP exchange without a JSON-RPC response (cancellation: the receiver of a cancel sends none). Internal; never reaches the wire.