Table of Contents

Class McpConnection

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

Manages a connection to an MCP server. Handles initialization handshake, tool discovery, and tool invocation over a given transport.

public sealed class McpConnection : IAsyncDisposable
Inheritance
McpConnection
Implements
Inherited Members

Constructors

McpConnection(IMcpTransport)

public McpConnection(IMcpTransport transport)

Parameters

transport IMcpTransport

Properties

ServerName

The server name reported during initialization.

public string? ServerName { get; }

Property Value

string

ServerVersion

The server version reported during initialization.

public string? ServerVersion { get; }

Property Value

string

Tools

Tools discovered from the MCP server after InitializeAsync(CancellationToken).

public IReadOnlyList<McpToolInfo> Tools { get; }

Property Value

IReadOnlyList<McpToolInfo>

Methods

CallToolAsync(string, Dictionary<string, object>?, CancellationToken)

Calls a tool on the MCP server with the given arguments.

public Task<string> CallToolAsync(string toolName, Dictionary<string, object>? arguments = null, CancellationToken cancellationToken = default)

Parameters

toolName string
arguments Dictionary<string, object>
cancellationToken CancellationToken

Returns

Task<string>

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

InitializeAsync(CancellationToken)

Performs the MCP initialize handshake and discovers available tools.

public Task InitializeAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

RefreshToolsAsync(CancellationToken)

Re-fetches the tool list from the server.

public Task RefreshToolsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task