Table of Contents

Class McpServiceExtensions

Namespace
Mythosia.AI.Mcp
Assembly
Mythosia.AI.Mcp.dll

Extension methods that integrate MCP servers with AIService.

public static class McpServiceExtensions
Inheritance
McpServiceExtensions
Inherited Members

Methods

WithMcpServerAsync(AIService, IMcpTransport, Func<string, bool>?, string?, CancellationToken)

Connects to an MCP server using a pre-built transport, discovers its tools, and registers them on this service.

public static Task<McpConnection> WithMcpServerAsync(this AIService service, IMcpTransport transport, Func<string, bool>? toolFilter = null, string? namePrefix = null, CancellationToken cancellationToken = default)

Parameters

service AIService

The AI service to register tools on.

transport IMcpTransport

A ready-to-use MCP transport.

toolFilter Func<string, bool>

Optional filter โ€” return true for tool names to include.

namePrefix string

Optional prefix to prepend to each tool name.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<McpConnection>

The initialized McpConnection. Caller must dispose it when done.

WithMcpServerAsync(AIService, string, string?, Func<string, bool>?, string?, string?, Dictionary<string, string>?, CancellationToken)

Connects to an MCP server via stdio transport, discovers its tools, and registers them as FunctionDefinitions on this service. Dispose the returned McpConnection to shut down the server process.

public static Task<McpConnection> WithMcpServerAsync(this AIService service, string command, string? args = null, Func<string, bool>? toolFilter = null, string? namePrefix = null, string? workingDirectory = null, Dictionary<string, string>? environmentVariables = null, CancellationToken cancellationToken = default)

Parameters

service AIService

The AI service to register tools on.

command string

The executable to launch (e.g., "npx", "python", "node").

args string

Arguments to pass to the executable.

toolFilter Func<string, bool>

Optional filter โ€” return true for tool names to include.

namePrefix string

Optional prefix to prepend to each tool name.

workingDirectory string

Optional working directory for the server process.

environmentVariables Dictionary<string, string>

Optional environment variables for the server process.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<McpConnection>

The initialized McpConnection. Caller must dispose it when done.