Table of Contents

Method ForStdio

Namespace
LMKit.Mcp.Client
Assembly
LM-Kit.NET.dll

ForStdio(string, string)

Creates an MCP client for a stdio-based MCP server.

public static McpClient ForStdio(string command, string arguments = null)

Parameters

command string

The command to execute (e.g., "npx", "python", "uvx").

arguments string

Command-line arguments.

Returns

McpClient

A new McpClient configured for stdio transport.

Examples

// Filesystem MCP server
using var client = McpClient.ForStdio("npx", "@modelcontextprotocol/server-filesystem /tmp");

// Python MCP server
using var client = McpClient.ForStdio("python", "-m my_mcp_server");

// UV-based Python server
using var client = McpClient.ForStdio("uvx", "mcp-server-git");

Exceptions

ArgumentException

Thrown when command is null or whitespace.

ForStdio(StdioTransportOptions)

Creates an MCP client for a stdio-based MCP server with detailed options.

public static McpClient ForStdio(StdioTransportOptions options)

Parameters

options StdioTransportOptions

The stdio transport configuration options.

Returns

McpClient

A new McpClient configured for stdio transport.

Examples

var options = new StdioTransportOptions
{
    Command = "python",
    Arguments = "-m my_mcp_server",
    WorkingDirectory = "/path/to/server",
    Environment = new Dictionary<string, string>
    {
        ["API_KEY"] = "your-key",
        ["DEBUG"] = "true"
    },
    StderrHandler = line => Console.WriteLine($"[Server] {line}")
};

using var client = McpClient.ForStdio(options);

Exceptions

ArgumentNullException

Thrown when options is null.