Class StdioTransportOptions
Configuration options for stdio-based MCP transport.
public sealed class StdioTransportOptions
- Inheritance
-
StdioTransportOptions
- Inherited Members
Examples
// Simple filesystem server
var options = new StdioTransportOptions
{
Command = "npx",
Arguments = "@modelcontextprotocol/server-filesystem /path/to/dir"
};
// Python server with environment variables
var options = new StdioTransportOptions
{
Command = "python",
Arguments = "-m my_mcp_server --port 8080",
WorkingDirectory = "/path/to/server",
Environment = new Dictionary<string, string>
{
["API_KEY"] = "your-api-key",
["DEBUG"] = "true"
}
};
Remarks
The stdio transport launches an MCP server as a subprocess and communicates via standard input (stdin) and standard output (stdout) using newline-delimited JSON (JSONL).
This is the standard transport for local MCP servers, including:
- Node.js servers via
npx(e.g.,npx @modelcontextprotocol/server-filesystem) - Python servers via
uvxorpython -m - Native executables built for MCP
Constructors
- StdioTransportOptions()
Creates a new instance with default values.
- StdioTransportOptions(string, string)
Creates a new instance with command and arguments.
Properties
- Arguments
Gets or sets the command-line arguments.
- AutoRestart
Gets or sets whether to restart the subprocess automatically on unexpected termination.
- Command
Gets or sets the command to execute.
- ConnectionTimeout
Gets or sets the maximum time to wait for the process to start.
- Environment
Gets or sets additional environment variables for the subprocess.
- GracefulShutdown
Gets or sets whether to gracefully terminate the process on close.
- GracefulShutdownTimeout
Gets or sets the timeout for graceful shutdown before forceful termination.
- InheritEnvironment
Gets or sets whether to inherit the parent process's environment variables.
- MaxRestartAttempts
Gets or sets the maximum number of automatic restart attempts.
- RequestTimeout
Gets or sets the timeout for individual JSON-RPC requests.
- RestartDelay
Gets or sets the delay between restart attempts.
- StartupDelay
Gets or sets the delay after starting the process before sending the first message.
- StderrHandler
Gets or sets a handler for stderr output from the subprocess.
- WorkingDirectory
Gets or sets the working directory for the subprocess.
Methods
- Clone()
Creates a clone of this options instance.