Mythosia.AI.Mcp
0.0.1-preview
dotnet add package Mythosia.AI.Mcp --version 0.0.1-preview
NuGet\Install-Package Mythosia.AI.Mcp -Version 0.0.1-preview
<PackageReference Include="Mythosia.AI.Mcp" Version="0.0.1-preview" />
<PackageVersion Include="Mythosia.AI.Mcp" Version="0.0.1-preview" />
<PackageReference Include="Mythosia.AI.Mcp" />
paket add Mythosia.AI.Mcp --version 0.0.1-preview
#r "nuget: Mythosia.AI.Mcp, 0.0.1-preview"
#:package Mythosia.AI.Mcp@0.0.1-preview
#addin nuget:?package=Mythosia.AI.Mcp&version=0.0.1-preview&prerelease
#tool nuget:?package=Mythosia.AI.Mcp&version=0.0.1-preview&prerelease
Mythosia.AI.Mcp
MCP (Model Context Protocol) client integration for Mythosia.AI.
Connect to any MCP server and automatically register its tools as FunctionDefinitions — usable by all AI providers (OpenAI, Anthropic, Google, xAI, DeepSeek, etc.).
Installation
dotnet add package Mythosia.AI.Mcp
Quick Start
using Mythosia.AI.Mcp;
using Mythosia.AI.Services.OpenAI;
var service = new OpenAIService(apiKey, httpClient);
// Connect to an MCP server (stdio transport)
await using var mcp = await service.WithMcpServerAsync(
"npx", "-y @modelcontextprotocol/server-filesystem /workspace");
// AI now has access to all MCP tools automatically
var answer = await service.GetCompletionAsync("List all files in /workspace");
Features
- Automatic tool discovery —
tools/listis called on connect; each tool becomes aFunctionDefinition - Provider-agnostic — MCP tools work with OpenAI, Anthropic, Google, xAI, DeepSeek, Perplexity
- Composable — mix MCP tools with
[AiFunction]local functions andFunctionBuilderdefinitions - Lifecycle management —
IAsyncDisposablepattern;await usingshuts down the server cleanly - Tool filtering — include only the tools you need with a name filter
- Name prefixing — avoid tool name collisions when connecting multiple MCP servers
Usage
Stdio Transport (most common)
// Basic — command + args
await using var mcp = await service.WithMcpServerAsync(
"npx", "-y @modelcontextprotocol/server-filesystem /workspace");
// With environment variables
await using var mcp = await service.WithMcpServerAsync(
"python", "-m my_mcp_server",
environmentVariables: new Dictionary<string, string>
{
["API_KEY"] = "sk-..."
});
Tool Filtering
// Only include specific tools
await using var mcp = await service.WithMcpServerAsync(
"npx", "-y @modelcontextprotocol/server-github",
toolFilter: name => name is "search_repositories" or "get_file_contents");
Multiple MCP Servers
// Connect to multiple servers — use namePrefix to avoid collisions
await using var fs = await service.WithMcpServerAsync(
"npx", "-y @modelcontextprotocol/server-filesystem /workspace",
namePrefix: "fs_");
await using var gh = await service.WithMcpServerAsync(
"npx", "-y @modelcontextprotocol/server-github",
namePrefix: "gh_");
// AI sees tools like: fs_read_file, fs_write_file, gh_search_repositories, etc.
Custom Transport
using Mythosia.AI.Mcp.Transports;
// Use any IMcpTransport implementation
var transport = new StdioTransport("node", "my-server.js");
await using var mcp = await service.WithMcpServerAsync(transport);
Direct McpConnection Usage
// For lower-level control without AIService integration
var transport = new StdioTransport("npx", "-y @modelcontextprotocol/server-filesystem /tmp");
var connection = new McpConnection(transport);
await connection.InitializeAsync();
// Inspect discovered tools
foreach (var tool in connection.Tools)
Console.WriteLine($"{tool.Name}: {tool.Description}");
// Call a tool directly
var result = await connection.CallToolAsync("read_file",
new Dictionary<string, object> { ["path"] = "/tmp/hello.txt" });
// Convert to FunctionDefinitions manually
var functions = McpToolAdapter.ToFunctionDefinitions(connection);
Architecture
Mythosia.AI.Abstractions ← FunctionDefinition, FunctionParameters
↑
Mythosia.AI ← AIService, provider implementations
↑
Mythosia.AI.Mcp ← McpConnection, StdioTransport, McpToolAdapter
MCP tools are converted to FunctionDefinition at connection time. The existing function calling infrastructure (ReAct loop, tool execution) handles the rest — no changes needed in the core package.
Supported MCP Protocol Features
| Feature | Status |
|---|---|
tools/list (tool discovery) |
Supported |
tools/call (tool execution) |
Supported |
| Stdio transport | Supported |
| SSE transport | Planned |
| Streamable HTTP transport | Planned |
resources/* |
Planned |
prompts/* |
Planned |
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Mythosia.AI (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1-preview | 25 | 4/4/2026 |
v0.0.1-preview: Initial preview — McpConnection, StdioTransport, automatic MCP tool-to-FunctionDefinition bridging, AIService.WithMcpServerAsync() extension method.