Class McpStdioServer
Runs an McpServer over standard input and output, the transport MCP clients use for locally launched servers.
[Obfuscation(Exclude = true)]
public sealed class McpStdioServer
- Inheritance
-
McpStdioServer
- Inherited Members
Examples
var server = new McpServer(new McpServerOptions { Name = "my-server" });
server.RegisterTool(new MyTool());
await new McpStdioServer(server).RunAsync();
Remarks
Messages are newline-delimited JSON. Standard output carries protocol traffic only, so any diagnostics a host wants to emit must go to standard error; a stray write to standard output corrupts the stream and drops the session.
Constructors
- McpStdioServer(McpServer)
Initializes a new host for the supplied server.
Methods
- RunAsync(TextReader, TextWriter, CancellationToken)
Reads messages from the supplied streams until the reader is exhausted or the token is cancelled.
- RunAsync(CancellationToken)
Reads messages until standard input closes or the token is cancelled.