csharp-mcp-server-blazor
C# MCP Server & Blazor WebAssembly Inspector
这是博客文章 使用 Blazor 前端构建 C# MCP 服务器 的配套代码仓库。
本仓库在 .NET 9 上提供了 Model Context Protocol(MCP) 的生产级 C# 实现,并配备了一个交互式 Blazor WebAssembly 工具检查器与协议监视器。
🚀 架构亮点
标准 MCP 协议引擎:通过 Server-Sent Events(
GET /sse)和 JSON-RPC 2.0(POST /messages)实现官方的 Model Context Protocol,支持 Claude Desktop、Cursor、VS Code 以及 Anthropic MCP Inspector CLI 等外部 AI 客户端。原生 C# 工具反射:借助
Microsoft.Extensions.AI(AIFunctionFactory)与System.Text.Json自动生成 JSON 架构,将强类型的 C# 方法公开为可发现的 MCP 工具。交互式 Blazor WASM 检查器:一个面向开发者的 GUI,可检查生成的 JSON 架构、通过自定义参数表单测试工具执行,并实时监视 JSON-RPC 通信日志。
零配置本地开发与受防护的生产环境:本地开发无需任何密钥即可顺畅运行;非 Development 环境强制实施 JWT Bearer 身份验证、速率限制和请求超时。
Related MCP server: sharplens-mcp
📁 解决方案结构
McpServerApp/McpServerApp:承载/sse、/messages和/api/mcp端点的 ASP.NET Core 服务器。McpServerApp/McpServerApp.Client:提供交互式 Inspector UI 的 Blazor WebAssembly 客户端。McpServerApp/McpServerApp.Tests:完整的自动化测试套件(单元测试、通过WebApplicationFactory的集成测试,以及 bUnit UI 组件测试)。e2e/:Playwright 浏览器测试,用于验证工具发现、执行与截图捕获。
🛠️ 快速开始
先决条件
.NET 9.0 SDK(或 .NET 10 预览版)
Node.js 20+(用于 Playwright 浏览器测试)
本地运行
克隆仓库:
git clone https://github.com/cmalpass/csharp-mcp-server-blazor.git cd csharp-mcp-server-blazor/McpServerApp运行应用程序:
dotnet run --project McpServerApp打开浏览器并访问
https://localhost:7150(或终端中显示的端口),探索 MCP Inspector。
🔌 连接外部 AI 客户端
1. Claude Desktop
将以下条目添加到你的 claude_desktop_config.json:
{
"mcpServers": {
"csharp-blazor-server": {
"url": "http://localhost:5000/sse"
}
}
}2. Cursor
转到 设置 > 功能 > MCP,点击 + 添加新 MCP 服务器,选择 SSE,并提供 http://localhost:5000/sse。
3. Anthropic CLI Inspector
npx @modelcontextprotocol/inspector http://localhost:5000/sse🧪 测试
确定性测试套件(.NET)
运行单元测试、集成测试和 bUnit 组件测试:
dotnet test McpServerApp/McpServerApp.sln --configuration Release浏览器 E2E 测试(Playwright)
npm ci
npm run test:e2e这将运行完整的浏览器流程,并将截图证据输出到 docs/evidence/mcp-inspector-execution.png。
📜 许可证
本项目采用 MIT 许可证 授权。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
MCP server connecting AI agents to 100+ apps (Gmail, Slack, Notion, GitHub) via one-click OAuth.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA dual-transport MCP server that exposes your API as tools to LLM clients, supporting both stdio transport for local clients like Claude Desktop and HTTP/SSE transport for remote clients like OpenAI's Responses API.
- AlicenseAqualityAmaintenanceA Model Context Protocol (MCP) server providing 62 AI-optimized tools for .NET/C# semantic code analysis, navigation, refactoring, and code generation using Microsoft Roslyn. Built for AI coding agents - provides compiler-accurate code understanding that AI cannot infer from reading source files alone.6231MIT
- FlicenseAqualityDmaintenanceMinimal MCP server bridging a Roslyn C# language server to AI agents, exposing tools for diagnostics, call hierarchy, and type hierarchy.1
- AlicenseNot gradedqualityAmaintenanceGive your AI assistant superpowers for .NET development! This MCP server connects GitHub Copilot, Claude, and other AI assistants directly to the .NET SDK, enabling them to create projects, manage packages, run builds, and more—all through natural language.31MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cmalpass/csharp-mcp-server-blazor'
If you have feedback or need assistance with the MCP directory API, please join our Discord server