Sandbox
@modelcontextprotocol/csharp-sdk

C# SDK for MCP clients and servers

This SDK helps .NET builders implement and consume Model Context Protocol servers and clients. It is split into packages for low-level protocol work, hosting and dependency injection, ASP.NET Core servers, interactive MCP apps, and asynchronous task handling.

4,521 stars804 forksC#Updated 7d ago
Who it's for

Builders who are adding MCP support to .NET apps, services, or libraries.

What it delivers

You can build MCP clients and servers in C# with the right package for your transport and hosting needs.

What it does

Core protocol package

`ModelContextProtocol.Core` provides client and low-level server APIs with minimal dependencies.

Hosting and dependency injection package

`ModelContextProtocol` adds hosting and DI extensions for most MCP projects.

ASP.NET Core support

`ModelContextProtocol.AspNetCore` provides HTTP-based MCP server support.

Apps extension

`ModelContextProtocol.Extensions.Apps` supports interactive UI applications that render inside MCP hosts.

Tasks extension

`ModelContextProtocol.Extensions.Tasks` supports long-running tool calls with status polling and input requests.

Samples and test apps

The `samples` and `tests` folders show quickstarts, weather servers, OAuth, SSE, AOT, and conformance setups.

README

MCP C# SDK

NuGet version

The official C# SDK for the Model Context Protocol, enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers. Please visit the API documentation for more details on available functionality.

Packages

The SDK packages are:

  • ModelContextProtocol.Core NuGet version - For projects that only need to use the client or low-level server APIs and want the minimum number of dependencies.

  • ModelContextProtocol NuGet version - The main package with hosting and dependency injection extensions. References ModelContextProtocol.Core. This is the right fit for most projects that don't need HTTP server capabilities.

  • ModelContextProtocol.AspNetCore NuGet version - The library for HTTP-based MCP servers. References ModelContextProtocol.

  • ModelContextProtocol.Extensions.Apps NuGet version - MCP Apps extension for building interactive UI applications that render inside MCP hosts.

  • ModelContextProtocol.Extensions.Tasks NuGet version - MCP Tasks extension for running long-running tool invocations asynchronously with status polling and input requests.

Getting Started

To get started, see the Getting Started guide in the conceptual documentation for installation instructions, package-selection guidance, and complete examples for both clients and servers.

You can also browse the samples directory and the API documentation for more details on available functionality.

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:

Cross-Application Access (Identity Assertion Authorization Grant flow)

The SDK provides support for the Identity Assertion Authorization Grant flow via IdentityAssertionGrantProvider. See the Cross-Application Access section in the transport docs for full usage details.

License

This project is licensed under the Apache License 2.0.

Files in the repo

Repository payload27 top-level entries
  • .config
  • .devcontainer
  • .github
  • docs
  • samples
  • scripts
  • src
  • tests
  • .editorconfig
  • .gitattributes
  • .gitignore
  • CONTRIBUTING.md
  • Directory.Build.props
  • Directory.Build.targets
  • Directory.Packages.props
  • global.json
  • LICENSE
  • logo.png
  • Makefile
  • ModelContextProtocol.slnx
  • nuget.config
  • Open.snk
  • package-lock.json
  • package.json
  • README.md
  • SECURITY.md
  • THIRD-PARTY-NOTICES.txt

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k