This repository contains the official C# SDK for the Model Context Protocol, enabling .NET applications to implement and interact with MCP clients and servers. It facilitates secure integration between LLMs
This is the official C# SDK for the Model Context Protocol (MCP), enabling .NET applications to interact with MCP clients and servers. Refer to the API documentation for details.
[!NOTE]
This project is in preview; breaking changes can be introduced without prior notice.
MCP standardizes how applications provide context to Large Language Models (LLMs), enabling secure integration between LLMs and data sources.
Install the package from NuGet: dotnet add package ModelContextProtocol --prerelease
Use McpClientFactory.CreateAsync
to instantiate and connect an IMcpClient
. Interact with it to enumerate tools and invoke them. The SDK supports connecting to any MCP server. Tools can be exposed as AIFunction
instances for use with IChatClient
s.
Create an MCP server and register tools using AddMcpServer
, WithStdioServerTransport
, and WithToolsFromAssembly
. Tools can inject IMcpServer
and other dependencies. Fine-grained control over server configuration is available.
This library builds upon the mcpdotnet project.
This project is licensed under the MIT License.
modelcontextprotocol/csharp-sdk
March 10, 2025
March 28, 2025
C#