- C# 99.8%
- JavaScript 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
StreamableHttpServerTransport held a reference to the Kestrel SSE response stream via _httpSseWriter for the entire session lifetime. Since the transport is only disposed when the session itself is disposed (via explicit DELETE or idle timeout), clients that disconnect without sending DELETE — which is typical for long-lived SSE connections — left the response stream pinned for the remainder of the idle timeout window. Because the Kestrel HTTP connection (and its associated memory pool buffers, Pipe readers/writers, socket send/receive buffers) is only collectible once all references to the response stream are released, this pinned ~20MiB of unmanaged memory per disconnected session until cleanup. Under steady connect/disconnect churn (e.g., IDE availability probes) this accumulated into sustained memory growth that eventually OOMKilled the container. Fix: release _httpSseWriter from within HandleGetRequestAsync's finally block so the reference is dropped as soon as the GET request exits, not just when the session is disposed. SendMessageAsync handles the now-nullable field via the existing _getHttpResponseCompleted gate, and any server-to-client messages sent after disconnect are still captured by the event store writer for replay via Last-Event-ID. Add a unit test that verifies _httpSseWriter is null once HandleGetRequestAsync returns. Relates to #766. |
||
| .config | ||
| .devcontainer | ||
| .github | ||
| docs | ||
| samples | ||
| src | ||
| tests | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| Directory.Build.props | ||
| 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 | ||
MCP C# SDK
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
This SDK consists of three main packages:
-
ModelContextProtocol.Core
- For projects that only need to use the client or low-level server APIs and want the minimum number of dependencies.
-
ModelContextProtocol
- 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
- The library for HTTP-based MCP servers. References
ModelContextProtocol.
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.