Mythosia.AI.Mcp 0.0.1-preview

This is a prerelease version of Mythosia.AI.Mcp.
dotnet add package Mythosia.AI.Mcp --version 0.0.1-preview
                    
NuGet\Install-Package Mythosia.AI.Mcp -Version 0.0.1-preview
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mythosia.AI.Mcp" Version="0.0.1-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mythosia.AI.Mcp" Version="0.0.1-preview" />
                    
Directory.Packages.props
<PackageReference Include="Mythosia.AI.Mcp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Mythosia.AI.Mcp --version 0.0.1-preview
                    
#r "nuget: Mythosia.AI.Mcp, 0.0.1-preview"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Mythosia.AI.Mcp@0.0.1-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Mythosia.AI.Mcp&version=0.0.1-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Mythosia.AI.Mcp&version=0.0.1-preview&prerelease
                    
Install as a Cake Tool

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 discoverytools/list is called on connect; each tool becomes a FunctionDefinition
  • Provider-agnostic — MCP tools work with OpenAI, Anthropic, Google, xAI, DeepSeek, Perplexity
  • Composable — mix MCP tools with [AiFunction] local functions and FunctionBuilder definitions
  • Lifecycle managementIAsyncDisposable pattern; await using shuts 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
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.