Run and debug C# MCP servers locally. Covers IDE configuration, MCP Inspector testing, GitHub Copilot Agent Mode integration, logging setup, and troubleshooting. USE FOR: running MCP servers locally with dotnet run, configuring VS Code or Visual Studio for MCP debugging, testing tools with MCP Inspector, testing with GitHub Copilot Agent Mode, diagnosing tool registration issues, setting up mcp.json configuration, debugging MCP protocol messages, configuring logging for stdio and HTTP servers. DO NOT USE FOR: creating new MCP servers (use mcp-csharp-create), writing automated tests (use mcp-csharp-test), publishing or deploying to production (use mcp-csharp-publish).
Ships in dotnet-ai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Run, debug, and interactively test C# MCP servers. Covers local execution, IDE debugging with breakpoints, MCP Inspector for protocol-level testing, and GitHub Copilot Agent Mode integration.
mcp.json or .mcp.json configurationmcp-csharp-create firstmcp-csharp-testmcp-csharp-publish| Input | Required | Description |
|---|---|---|
| Project path | Yes | Path to the .csproj file or project directory |
| Transport type | Recommended | stdio or http — detect from .csproj if not specified |
| IDE | Recommended | VS Code or Visual Studio — detect from environment if not specified |
Agent behavior: Detect transport type by checking the .csproj for a PackageReference to ModelContextProtocol.AspNetCore. If present → HTTP, otherwise → stdio.
stdio transport:
cd <ProjectDir>
dotnet run
The process starts and waits for JSON-RPC messages on stdin. No output on stdout means it's working correctly.
HTTP transport:
cd <ProjectDir>
dotnet run
# Server listens on http://localhost:3001 (or configured port)
Detect the IDE and transport, then create the appropriate config file.
For VS Code — create .vscode/mcp.json:
stdio:
{
"servers": {
"<ProjectName>": {
"type": "stdio",
"command": "dotnet",
"args": ["run", "--project", "<path/to/ProjectFile.csproj>"]
}
}
}
HTTP:
{
"servers": {
"<ProjectName>": {
"type": "http",
"url": "http://localhost:3001"
}
}
}
For Visual Studio — create .mcp.json at solution root (same JSON structure).
For detailed IDE-specific configuration (launch.json, environment variables, secrets), see references/ide-config.md.
The MCP Inspector provides a UI for testing tools, viewing schemas, and inspecting protocol messages.
stdio server:
npx @modelcontextprotocol/inspector dotnet run --project <path/to/ProjectFile.csproj>
HTTP server:
dotnet runnpx @modelcontextprotocol/inspectorhttp://localhost:3001For detailed Inspector capabilities, usage, and troubleshooting, see references/mcp-inspector.md.
If tools don't appear — troubleshoot tool discovery:
Rebuild first — stale builds are the #1 cause:
dotnet build
Then restart the MCP server (click Stop → Start in VS Code, or restart dotnet run).
Check attributes and registration:
[McpServerToolType] on the class and [McpServerTool] on each public methodstatic or instance (instance types need DI registration).WithTools<T>() or .WithToolsFromAssembly() in Program.csCheck mcp.json points to the correct project path
If still not appearing, reference the tool explicitly: Using #tool_name, do X
launch.json — see references/ide-config.md)Critical: Build in Debug configuration. Breakpoints won't hit in Release builds.
When a tool works standalone but fails through MCP, work through these checks:
npx @modelcontextprotocol/inspector dotnet run --project <path>Console.WriteLine() or logging to stdout corrupts the JSON-RPC protocol. Redirect all output to stderr (see Step 6).Program.cs.builder.Logging.AddFile("mcp-debug.log"); // or use Serilog/NLog
Critical for stdio transport: Any output to stdout (including Console.WriteLine) corrupts the MCP JSON-RPC protocol and causes garbled responses or crashes. All logging and diagnostic output must go to stderr.
stdio transport — log to stderr only:
builder.Logging.AddConsole(options =>
options.LogToStandardErrorThreshold = LogLevel.Trace);
HTTP transport — For HTTP transport logging configuration, see references/ide-config.md.
In tool methods — inject ILogger<T> via constructor and use logger.LogDebug() / logger.LogError(). Logging through ILogger respects the stderr configuration above.
dotnet run| Pitfall | Solution |
|---|---|
| Tools not appearing or stale after changes | Rebuild first: dotnet build, then restart the server. If still missing, verify [McpServerToolType] on class, [McpServerTool] on methods, and WithTools<T>() or WithToolsFromAssembly() in Program.cs |
| stdio server produces garbled output | Console.WriteLine() or logging is writing to stdout. All output must go to stderr. Set LogToStandardErrorThreshold = LogLevel.Trace on the console logger |
| HTTP server returns 404 at MCP endpoint | Missing app.MapMcp() in Program.cs |
| Breakpoints not hit | Building in Release mode. Rebuild in Debug: dotnet build -c Debug, then restart |
| Environment variables not passed to server | Add "env" section to mcp.json. For secrets in VS Code, use "${input:var_id}" syntax |
| MCP Inspector can't connect to HTTP server | Server not running, or wrong port. Check dotnet run output for the listening URL |
mcp-csharp-create — Create a new MCP server projectmcp-csharp-test — Automated tests and evaluationsmcp-csharp-publish — NuGet, Docker, Azure deploymentWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/dotnet-ai:mcp-csharp-debugfrom dotnet-ai
npx claudepluginhub weiflycc-cmd/skills --plugin dotnet-ai5 skills in this plugin
/mcp-csharp-createCreate MCP servers using the C# SDK and .NET project templates. Covers scaffolding, tool/prompt/resource implementation, and transport configuration for stdio and HTTP. USE FOR: creating new MCP server projects, scaffolding with dotnet new mcpserver, adding MCP tools/prompts/resources, choosing stdio vs HTTP transport, configuring MCP hosting in Program.cs, setting up ASP.NET Core MCP endpoints with MapMcp. DO NOT USE FOR: debugging or running existing servers (use mcp-csharp-debug), writing tests (use mcp-csharp-test), publishing or deploying (use mcp-csharp-publish), building MCP clients, non-.NET MCP servers.
/mcp-csharp-publishPublish and deploy C# MCP servers. Covers NuGet packaging for stdio servers, Docker containerization for HTTP servers, Azure Container Apps and App Service deployment, and publishing to the official MCP Registry. USE FOR: packaging stdio MCP servers as NuGet tools, creating Dockerfiles for HTTP MCP servers, deploying to Azure Container Apps or App Service, publishing to the MCP Registry at registry.modelcontextprotocol.io, configuring server.json for MCP package metadata, setting up CI/CD for MCP server publishing. DO NOT USE FOR: publishing general NuGet libraries (not MCP-specific), general Docker guidance unrelated to MCP, creating new servers (use mcp-csharp-create), debugging (use mcp-csharp-debug), writing tests (use mcp-csharp-test).
/mcp-csharp-testTest C# MCP servers at multiple levels: unit tests for individual tools and integration tests using the MCP client SDK. USE FOR: unit testing MCP tool methods, integration testing with in-memory MCP client/server, end-to-end testing via MCP protocol, testing HTTP MCP servers with WebApplicationFactory, mocking dependencies in tool tests, creating evaluations for MCP servers, writing eval questions, measuring tool quality. DO NOT USE FOR: testing MCP clients (this is server testing only), load or performance testing, testing non-.NET MCP servers, debugging server issues (use mcp-csharp-debug).
/technology-selectionGuides technology selection and implementation of AI and ML features in .NET 8+ applications using ML.NET, Microsoft.Extensions.AI (MEAI), Microsoft Agent Framework (MAF), GitHub Copilot SDK, ONNX Runtime, and OllamaSharp. Covers the full spectrum from classic ML through modern LLM orchestration to local inference. Use when adding classification, regression, clustering, anomaly detection, recommendation, LLM integration (text generation, summarization, reasoning), RAG pipelines with vector search, agentic workflows with tool calling, Copilot extensions, or custom model inference via ONNX Runtime to a .NET project. DO NOT USE FOR projects targeting .NET Framework (requires .NET 8+), the task is pure data engineering or ETL with no ML/AI component, or the project needs a custom deep learning training loop (use Python with PyTorch/TensorFlow, then export to ONNX for .NET inference).