mcpdotnet 0.3.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package mcpdotnet --version 0.3.0.2                
NuGet\Install-Package mcpdotnet -Version 0.3.0.2                
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="mcpdotnet" Version="0.3.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add mcpdotnet --version 0.3.0.2                
#r "nuget: mcpdotnet, 0.3.0.2"                
#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.
// Install mcpdotnet as a Cake Addin
#addin nuget:?package=mcpdotnet&version=0.3.0.2

// Install mcpdotnet as a Cake Tool
#tool nuget:?package=mcpdotnet&version=0.3.0.2                

mcpdotnet

A .NET client implementation of the Model Context Protocol (MCP), enabling .NET applications to connect to and interact with MCP servers.

About MCP

The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). It enables secure integration between LLMs and various data sources and tools.

For more information about MCP:

Status

This project is in early development. While functional, it may undergo significant changes as the protocol and implementation evolve.

Current Limitations

  • Only supports the Tools, Resources, Prompts, Sampling capabilities (Roots not yet implemented)
  • Only stdio transport is currently supported (HTTP/SSE transport coming soon)
  • Client library only - server implementation support may be added in the future
  • Provider-agnostic implementation focused purely on the MCP protocol
  • Applications using this library need to implement their own integration with LLM APIs/clients

The library's current focus is on implementing the core MCP protocol, with the main utility being the ability to launch and connect to MCP servers based on configuration objects.

Features

  • MCP client implementation for .NET applications
  • Support for stdio transport
  • Support for Tool, Resource, Prompt, Sampling capabilities
  • Support for pagination and notifications
  • Async/await pattern throughout
  • Compatible with .NET 8.0 and later

Getting Started

To create a client you need to instantiate a factory with configuration objects:

var options = new McpClientOptions() 
    { ClientInfo = new() { Name = "TestClient", Version = "1.0.0" } };
	
var config = new McpServerConfig
        {
            Id = "everything",
            Name = "Everything",
            TransportType = "stdio",
            TransportOptions = new Dictionary<string, string>
            {
                ["command"] = "npx",
                ["arguments"] = "-y @modelcontextprotocol/server-everything",
            }
        };
		
var factory = new McpClientFactory(
            new[] { config },
            _defaultOptions
        );

You can then retrieve an IMcpClient reference using the id of a server from the configuration, and use ListToolsAsync and CallToolAsync to integrate with your LLM-based code.

var client = await factory.GetClientAsync("everything");
// Get the list of tools, for passing to an LLM
var tools = await client.ListToolsAsync();
// Execute a tool, in practice this would normally be driven by LLM tool invocations
var result = await client.CallToolAsync(
            "echo",
            new Dictionary<string, object>
            {
                ["message"] = "Hello MCP!"
            },
            CancellationToken.None
        );
// echo always returns one and only one text content object
Console.WriteLine(result.Content.FirstOrDefault(c => c.Type == "text").Text);

Note that you should pass CancellationToken objects suitable for your use case, to enable proper error handling, timeouts, etc. This example also does not paginate the tools list, which may be necessary for large tool sets. See the IntegrationTests project for an example of pagination, as well as examples of how to handle Prompts and Resources.

Additional examples and documentation will be added as in the near future.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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
1.0.1.1 44 2/19/2025
1.0.0.1 80 2/8/2025
0.10.0.1 75 2/7/2025
0.9.0.1 63 1/24/2025
0.8.0.1 72 1/19/2025
0.7.0.1 70 1/18/2025
0.6.0.1 83 1/12/2025
0.5.0.1 55 1/9/2025
0.3.0.2 99 1/5/2025
0.3.0.1 85 1/5/2025
0.2.0-alpha1 84 1/4/2025
0.1.0-alpha1 100 1/3/2025