Skip to content

StdioMcpTransport

Namespace: Vercel.AI.Mcp

public sealed class StdioMcpTransport : IMcpTransport, IDisposable

MCP over a child process using newline-delimited JSON-RPC messages.

Inheritance: object

Implements: IMcpTransport, IDisposable

View source

public int ProcessId { get; }

Child process id.

Value: int

View source

public StreamReader? StandardError { get; }

The child’s stderr, when RedirectStandardError is true.

Value: StreamReader

View source

CallAsync(string, JsonElement, CancellationToken)

Section titled “CallAsync(string, JsonElement, CancellationToken)”
public Task<JsonElement> CallAsync(string method, JsonElement parameters, CancellationToken cancellationToken)

Calls <code class=“paramref”>method</code> and returns the JSON-RPC result.

Parameters

Name Type Description
method string
parameters JsonElement
cancellationToken CancellationToken

Returns: Task<JsonElement>

View source

public static ProcessStartInfo CreateStartInfo(StdioMcpOptions options)

Builds the process start info. The environment is replaced by Boolean%7d), so the child does not inherit every variable of this process.

Parameters

Name Type Description
options StdioMcpOptions

Returns: ProcessStartInfo

View source

public void Dispose()

Kills the child process, if one was started.

View source

public static StdioMcpTransport Start(string fileName, IReadOnlyList<string>? arguments = null)

Starts <code class=“paramref”>fileName</code> and speaks MCP on its stdin and stdout.

Parameters

Name Type Description
fileName string
arguments IReadOnlyList<string>

Returns: StdioMcpTransport

View source

public static StdioMcpTransport Start(StdioMcpOptions options)

Starts the server described by <code class=“paramref”>options</code>.

Parameters

Name Type Description
options StdioMcpOptions

Returns: StdioMcpTransport

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product