Transport classes handle the underlying communication between MCP clients and servers. The SDK provides multiple transport implementations for different scenarios.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/modelcontextprotocol/csharp-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Namespace
IClientTransport Interface
Base interface for all client transports.StdioClientTransport
Provides a transport implemented via standard input/output (stdio), launching an external process and communicating through stdin/stdout streams.Constructor
Configuration options for the transport, including the command to execute, arguments, working directory, and environment variables.
A logger factory for creating loggers used for diagnostic output during transport operations.
StdioClientTransportOptions
Configuration options for stdio transport.The command to execute to start the server process (e.g., “node”, “python”, “dotnet”).
The arguments to pass to the server process when it is started.
A transport identifier used for logging purposes.
The working directory for the server process.
Environment variables to set for the server process. By default, the server process inherits the current environment’s variables.
The timeout to wait for the server to shut down gracefully. Default is 5 seconds.
A callback that is invoked for each line of stderr received from the server process.
Examples
HttpClientTransport
Provides a transport over HTTP using Server-Sent Events (SSE) or Streamable HTTP protocol.Constructor
The configuration options for the transport.
The HTTP client instance used for requests. If not provided, a new instance is created.
The logger factory for creating loggers used for diagnostic output.
true to dispose of httpClient when the transport is disposed; false if the caller is retaining ownership.HttpClientTransportOptions
Configuration options for HTTP transport.The base address of the server for SSE or Streamable HTTP connections. Must be an absolute HTTP or HTTPS URI.
The transport mode to use for the connection. Default is
HttpTransportMode.AutoDetect, which attempts Streamable HTTP first and falls back to SSE.A transport identifier used for logging purposes.
Timeout used to establish the initial connection to the SSE server. Default is 30 seconds.
Custom HTTP headers to include in requests to the SSE server.
A session identifier that should be reused when connecting to a Streamable HTTP server. Allows reconnecting to an existing session.
Indicates whether this transport endpoint is responsible for ending the session on dispose. Default is
true.The authorization provider to use for OAuth authentication.
The maximum number of consecutive reconnection attempts when an SSE stream is disconnected. Default is 5.
The default interval at which the client attempts reconnection after an SSE stream is disconnected. Default is 1 second.
HttpTransportMode Enum
Examples
Transport Selection Guide
Use StdioClientTransport When:
- Running a server as a child process
- Developing locally with servers in different languages (Node.js, Python, .NET)
- Need to pass environment variables or configure working directory
- Server doesn’t require network communication
- Want to capture and process server stderr output
Use HttpClientTransport When:
- Connecting to a remote MCP server over HTTP/HTTPS
- Server is already running and accessible via URL
- Need OAuth authentication
- Require custom HTTP headers
- Want to resume sessions (with Streamable HTTP mode)
- Building web or cloud-based applications
Common Patterns
Error Handling
Logging
See Also
- McpClient - Client class using transports
- Authentication - OAuth authentication for HTTP transports
- MCP Specification - Transports - Official transport specification