SuperAPIAI Directory

DotnetFastMCP

github.com · AI developer platforms

DotnetFastMCP is a lightweight .NET framework based on ASP.NET Core for building Model Context Protocol (MCP) servers. It adds enterprise-grade security, governance, and observability capabilities on top of the base MCP protocol, including OAuth 2.0/OIDC authentication, per-tool enforced multi-factor authentication (MFA), OpenTelemetry metrics and distributed tracing, and zero-configuration health checks. The framework provides a concise attribute-based API (such as [McpTool], [McpResource], [McpPrompt]), supports automatic component discovery, JSON-RPC 2.0 compliance, flexible parameter binding, and comes with a type-safe .NET client library supporting Stdio and SSE transports. It also integrates 8 LLM providers, a universal media loader, automatic dependency injection registration, and parameter description attributes, helping developers run MCP tools in production environments with less boilerplate code.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

DotnetFastMCP is a lightweight framework for .NET developers for building Model Context Protocol (MCP) servers. Its core positioning is to supplement the base MCP protocol with enterprise-grade security, governance, and observability capabilities for production environments. The base protocol itself is relatively simple, but running MCP tools in production environments typically requires OAuth 2.0/OIDC authentication, per-tool multi-factor authentication (MFA), distributed tracing, and health monitoring. DotnetFastMCP handles these requirements on ASP.NET Core through an attribute-based API and provides a native .NET client library to consume MCP servers.

Main capabilities include:

  • Attribute-based API: Use [McpTool], [McpResource], [McpPrompt] to declare tools, resources, and prompt templates, with reflective automatic component discovery.
  • Protocol compliance: Full JSON-RPC 2.0 compliance, support for array and named parameter binding, built-in error handling and logging.
  • Authentication and authorization: Support for 6 OAuth providers (Azure AD, Google, GitHub, Auth0, Okta, AWS Cognito), built-in OAuth proxy and dynamic client registration (DCR), automatic JWT token validation and JWKS caching, support for [Authorize] fine-grained authorization, claims-based access, and per-tool enforced MFA.
  • Observability: Enable OpenTelemetry with one line of code, automatically track 5 metrics including tool calls, latency, errors, prompt requests, and resource reads, and connect to Prometheus, Application Insights, Grafana, Jaeger, or any OTLP backend.
  • Health checks: Enable the built-in health endpoint GET /mcp/health with one line of code, support custom checks, parallel execution, and timeouts, return 200/207/503 status codes, and adapt to Kubernetes and Docker probes.
  • Client library: Type-safe .NET client McpClient, supporting Stdio and SSE transports, providing notification events and the CallToolAsync<T> invocation API.
  • LLM integration: A unified ILLMProvider interface supports Ollama, OpenAI, Azure Op8 providers including enAI, Anthropic Claude, Google Gemini, Cohere, Hugging Face, and Deepseek, with streaming output support and integration of HttpClientFactory and Polly retry policies.
  • Multimodal and media loading: McpMediaLoader can load media from remote HTTP/HTTPS, local files, file:// URIs, and RFC 2397 data URIs, supports magic-number MIME type sniffing, and provides McpContent factory methods (Json, ImageFromBytes, ImageFromStreamAsync, ImageFromUriAsync, ResourceText, ResourceBlob, Composite, etc.).
  • Automatic dependency injection: non-static tool, resource, and prompt classes discovered via WithComponentsFrom() are automatically registered as Transient services, while custom Singleton/Scoped lifetimes are preserved.
  • Parameter descriptions: use [McpDescription] to annotate method parameters; descriptions are written into the inputSchema of the JSON Schema, while framework-injected types (McpContext, CancellationToken, ClaimsPrincipal, IMcpSession) are automatically filtered out.
  • Dual targeting: the same package provides net8.0 and net10.0 binaries, compatible with existing .NET 8 applications.

Usage: install via the NuGet package manager, or clone the repository. After defining components, the server can run in HTTP mode (default http://localhost:5000)或 Stdio mode. The OAuth sample server exposes endpoints such as /mcp, /oauth/authorize, /oauth/token, and /.well-known/oauth-authorization-server. The project includes a PowerShell-based integration test suite that can publish BasicServer and run test scripts.

Use cases: building MCP servers with authentication, authorization, MFA, observability, and health checks in a .NET production environment; needing a type-safe client to consume MCP services; needing unified access to multiple LLM providers; enterprise-grade AI agent servers that need to handle multimodal media content.

Limitations: the material does not provide specific pricing, cost, or platform compatibility details; some features (such as MFA, health checks, and OpenTelemetry) are optionally enabled and incur no additional overhead when not enabled.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools