GitShow/modelcontextprotocol/csharp-sdk
modelcontextprotocol

csharp-sdk

The official C# SDK for Model Context Protocol servers and clients. Maintained in collaboration with Microsoft.

by modelcontextprotocol
csharpdotnetmcpmcp-clientmcp-servermodelcontextprotocol
Star on GitHubForkWebsite

C#

4.5k stars794 forks90 contributorsActive · 4d agoSince 2025v2.2.0

Meet the team

See all 90 on GitHub →
CopilotBot
Copilot152 contributions
stephentoub
stephentoub121 contributions
dependabot[bot]Bot
dependabot[bot]100 contributions
halter73
halter7391 contributions
jeffhandley
jeffhandley68 contributions
eiriktsarpalis
eiriktsarpalis50 contributions
PederHP
PederHP40 contributions
PranavSenthilnathan
PranavSenthilnathan17 contributions

Languages

View on GitHub →
C#99.8%
JavaScript0.2%
Makefile0%

Commit activity

Last 12 weeks · 116 commits

Full graph →

Community health

5 of 6 standards met

Community profile →
87
✓README✓License✓Contributing✓Code of Conduct○Issue Template✓PR Template

Recent PRs & issues

Active · Last activity 4d ago
See all on GitHub →
jstar0
test(oauth): extend metadata discovery probe timeoutOpenPR

Summary Fixes #1806 by keeping OAuth metadata discovery from being cancelled by the five-second probe timeout in slow in-memory CI environments. When the protected MCP endpoint returns , metadata discovery runs under the same probe cancellation token. A slow TLS/duplex-pipe handshake can therefore cancel before it finishes, producing a misleading metadata-discovery assertion failure. Changes Add a test-only helper that uses the shared 60-second test budget for . Route the ASP.NET Core OAuth tests through that helper. Apply the same probe budget to the standalone conformance client used by OAuth scenarios. Production client defaults and OAuth behavior are unchanged. Verification — 3 passed\n- — 98 passed\n- — passed\n\nThe net8.0/net9.0 variants were not runnable on this workstation because those runtimes are not installed; they remain covered by the repository CI matrix.

jstar0 · 2d ago
AkbarDizaji
Flaky on windows-latest: OAuth metadata fetch times out in in-memory tests (same class as #1701, not covered by #1702)OpenIssue

Describe the bug Several OAuth tests occasionally fail on the legs of Build and Test. If that occurs, the method gets a during a slow TLS handshake using the in-memory duplex pipe, wraps that into the "Failed to find .well-known/..." message, and assertion expectations about that message fail on the injected text – that is, the error manifests itself as a confusing assertion failure instead of a timeout. It appears to be similar to #1701 from the OAuth side of things. #1702 increased the probe timeout in the in-memory tests, but the OAuth metadata path has a similar timeout which was not added and is still failing after that merge. Tests affected so far: To Reproduce Intermittent, not deterministic reproduction possible. It is reproduced by running Build and Tests of leg multiple times. The following two incidents are on August 9, right after merging PR #1702, for two consecutive commits of the same branch which are identical but different in comments and tests: 1. - windows-latest, Debug - job - 2. - windows-latest, Release - [job](https:// Expected behavior Tests need to be deterministic. In case the timeout happens during fetching of the metadata, the issue should be thrown as a timeout and not as an assertion failure on an error message that’s not related to it at all. Logs From the Release run

AkbarDizaji · 2d ago
jstar0
Cancel background task runners on server disposalOpenPR

Summary Background Tasks runners used cancellation sources independent of the owning server and discarded their Task handles. As a result, server disposal could finish before a runner was cancelled, including when the runner registered during disposal. Changes Add a general server-lifetime cancellation and registration seam for extension infrastructure, with an unregistration handle so completed work is not retained. Cancel the lifetime at the start of stateful server disposal, close registration after request handlers drain, and await the remaining runners. Let each Tasks runner state own cancellation and completion awaiting, while long-lived MRTR handlers remain linked to the server lifetime and completed registrations are removed. Keep stateless HTTP request servers non-owning so Tasks can continue across independent requests. Add deterministic coverage for cancellation, awaiting, late registration, and the stateless ownership boundary. The change does not alter protocol messages, task-store contracts, polling, or explicit tasks/cancel behavior. Verification The current lifetime-registration focus passed on net10.0, net9.0, and net8.0 (5 tests on each framework). The merged net10.0 lifecycle and Tasks execution-mode focus passed 61 tests. The full Core suite passed with 2328 passed and 5 skipped; the analyzer suite passed with 57 passed. The Release solution build completed with 0 warnings and 0 errors, package validation produced all packages, and DocFX completed with 0 warnings and 0 errors. Closes #1707

jstar0 · 2d ago

Recent fixes

View closed PRs →
bbartels
Support https+http scheme for .NET Aspire service discoveryMergedPR

Summary Add support for URI scheme to enable .NET Aspire service discovery ## Motivation and Context When using .NET Aspire service discovery, endpoints are configured with composite schemes like . The current validation rejects these URLs because it only allows exact or schemes. This change allows the service discovery scheme pattern so the MCP client can work seamlessly with Aspire-based applications. ## How Has This Been Tested? Tested locally with a .NET Aspire application using service discovery to connect to an MCP gateway. Verified that: Standard and URLs continue to work URLs are now accepted Invalid schemes are still rejected ## Breaking Changes None. This is an additive change that allows an additional valid scheme pattern. ## Types of changes [ ] Bug fix (non-breaking change which fixes an issue) [x] New feature (non-breaking change which adds functionality) [ ] Breaking change (fix or feature that would cause existing functionality to change) [ ] Documentation update ## Checklist [x] I have read the MCP Documentation [x] My code follows the repository's style guidelines [ ] New and existing tests pass locally [x] I have added appropriate error handling [x] I have added or updated documentation as needed ## Additional context .NET Aspire uses composite URI schemes for service discovery: means "resolve via service discovery, connect using HTTPS" The suffix indicates looking up HTTP endpoints in the configuration Reference: https://learn.microsoft.com/en-us/dotnet/aspire/service-discovery/overview

bbartels · 3d ago
halter73
Add MCP003 analyzer: warn when WithHttpTransport doesn't set StatelessMergedPR

Add a Roslyn DiagnosticAnalyzer (MCP003) that warns when WithHttpTransport is called without explicitly setting HttpServerTransportOptions.Stateless. This protects users from breaking changes if the default changes from stateful to stateless in the future. The analyzer detects: No delegate passed: .WithHttpTransport() Null literal: .WithHttpTransport(null) Lambda without Stateless assignment Method groups and delegate variables (cannot trace)

halter73 · 3d ago
Structured data for AI agents

Repository: modelcontextprotocol/csharp-sdk. Description: The official C# SDK for Model Context Protocol servers and clients. Maintained in collaboration with Microsoft. Stars: 4489, Forks: 794. Primary language: C#. Languages: C# (99.8%), JavaScript (0.2%), Makefile (0%). Homepage: https://csharp.sdk.modelcontextprotocol.io/ Topics: csharp, dotnet, mcp, mcp-client, mcp-server, modelcontextprotocol. Latest release: v2.2.0 (1w ago). Open PRs: 48, open issues: 112. Last activity: 4d ago. Community health: 87%. Top contributors: Copilot, stephentoub, dependabot[bot], halter73, jeffhandley, eiriktsarpalis, PederHP, PranavSenthilnathan, tarekgh, MackinnonBuck and others.

·@ofershap

Replace github.com with gitshow.dev