OptionaloncloseCallback for when the connection is closed for any reason.
This should be invoked when close() is called as well.
OptionalonerrorCallback for when an error occurs.
Note that errors are not necessarily fatal; they are used for reporting any kind of exceptional condition out of band.
OptionalonmessageCloses the connection.
Sends a JSON-RPC message (request or response).
If present, relatedRequestId is used to indicate to the transport which incoming request to associate this outgoing message with.
Starts listening for messages on stdin.
Server transport for stdio: this communicates with an MCP client by reading from the current process'
stdinand writing tostdout.This transport is only available in Node.js environments.
Example