StdioServerTransport class
Server transport for stdio: communicates with a MCP client by reading from the current process's standard input (io.stdin) and writing to standard output (io.stdout).
This transport is primarily intended for server processes that are directly invoked by a client managing the process lifecycle.
Note: This transport assumes exclusive control over stdin/stdout for JSON-RPC communication while active. Other uses of stdin/stdout might interfere.
- Implemented types
Constructors
- StdioServerTransport.new({Stdin? stdin, IOSink? stdout})
- Creates a new stdio server transport.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- onclose ↔ void Function()?
-
Callback for when the connection is closed.
getter/setter pairoverride
- onerror ↔ void Function(Error error)?
-
Callback for reporting errors.
getter/setter pairoverride
- onmessage ↔ void Function(JsonRpcMessage message)?
-
Callback for received messages.
getter/setter pairoverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sessionId → String?
-
Session ID is not typically applicable to stdio transport.
no setteroverride
Methods
-
close(
) → Future< void> -
Closes the transport by detaching from stdin and invoking onclose.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
JsonRpcMessage message) → Future< void> -
Sends a JsonRpcMessage to the client by writing its serialized form
(JSON string followed by newline) to stdout.
override
-
start(
) → Future< void> -
Starts listening for messages on stdin.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited