Dotnet MCP Server

MCP server for .NET coverage: run tests, parse Cobertura, find uncovered branches, append tests.

Local serverstdio

What is the Dotnet MCP server?

Dotnet MCP server is a locally run integration for AI assistants that speak the Model Context Protocol. MCP server for .NET coverage: run tests, parse Cobertura, find uncovered branches, append tests.

What you get

An MCP (Model Context Protocol) server that gives AI assistants — Claude Code, Gemini CLI, and others — direct access to .NET test-coverage tooling. Run dotnet test, parse Cobertura XML, identify uncovered branches, diff coverage between runs, and append test code — all over stdio.

What the assistant can call

Once Dotnet is connected, these are the calls the assistant has available:

  • GetSourceFiles — Discover .cs files from a file, folder, or .csproj project. Returns file metadata (lines, method count) and smart batches grouped by lineBudget
  • RunTestsWithCoverage — Run dotnet test with XPlat Code Coverage, generate a JSON summary via reportgenerator. Returns paths to Summary.json and coverage.cobertura.xml
  • GetCoverageSummary — Parse Summary.json into structured class/method coverage data sorted worst-first by branch coverage. Optional belowTarget/topN/methodsPerClass
  • GetFileCoverage — Get coverage for a single source file from Cobertura XML. Returns allMeetTarget (true when all classes meet the configured targetRate for both line
  • GetUncoveredBranches — Find uncovered branch conditions for methods matching a given name. Returns all matching methods with partial name support. Supports sessionId
  • GetCoverageDiff — Compare current Cobertura XML against baseline. Shows method-level changes including new and removed methods. Supports sessionId for concurrent
  • AppendTestCode — Insert or append C# test code into a test file. Supports anchor-based insertion with whitespace-tolerant fallback matching. Uses atomic writes to
  • CleanupSession — Remove session state files and TestResults/coveragereport directories. Pass sessionId to scope, or omit to clean artifacts older than maxAgeMinutes
  • Cursor — The Cursor tool exposed by this server

Configuration and credentials

You will need one environment variable: COVERAGE_MCP_ALLOWED_ROOT. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

  • .NET 9.0 SDK (or later)https://dotnet.microsoft.com/download - reportgenerator global tool — the server shells out to it to render coverage reports (installed in the Install step below) - An MCP-compatible client (Claude Code, Gemini CLI, etc.) - COVERAGE_MCP_ALLOWED_ROOT — recommended. Set to your repository root to restrict

Setting it up

Setup follows the usual MCP pattern — install or clone the server, register it in your client's configuration file, restart the client.

Choosing this one

This sits in the developer tooling group, where several servers overlap in what they claim to do but differ sharply once you actually set them up. Dotnet's toolset — GetSourceFiles, RunTestsWithCoverage, GetCoverageSummary and 6 more — is a fair guide to whether it matches your workflow. It is maintained by Hyeonu-Cha; worth a glance at recent repository activity before you build anything load-bearing on it.

This entry was verified against Dotnet's own documentation before publication; SyncDev keeps the directory reviewed rather than auto-generated.

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • With 9 tools registered it takes up a noticeable share of the context window; turn it off in projects that never touch Dotnet.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the dotnet mcp server does with a few real requests.

Available tools

ToolWhat it does
GetSourceFilesDiscover .cs files from a file, folder, or .csproj project. Returns file metadata (lines, method count) and smart batches grouped by lineBudget.
RunTestsWithCoverageRun dotnet test with XPlat Code Coverage, generate a JSON summary via reportgenerator. Returns paths to Summary.json and coverage.cobertura.xml. Supports forceRestore and sessionId for concurrent isolation.
GetCoverageSummaryParse Summary.json into structured class/method coverage data sorted worst-first by branch coverage. Optional belowTarget/topN/methodsPerClass filters trim the response to what still needs work.
GetFileCoverageGet coverage for a single source file from Cobertura XML. Returns allMeetTarget (true when all classes meet the configured targetRate for both line and branch coverage; default 0.8). Supports sessionId.
GetUncoveredBranchesFind uncovered branch conditions for methods matching a given name. Returns all matching methods with partial name support. Supports sessionId.
GetCoverageDiffCompare current Cobertura XML against baseline. Shows method-level changes including new and removed methods. Supports sessionId for concurrent isolation.
AppendTestCodeInsert or append C# test code into a test file. Supports anchor-based insertion with whitespace-tolerant fallback matching. Uses atomic writes to prevent file corruption.
CleanupSessionRemove session state files and TestResults/coveragereport directories. Pass sessionId to scope, or omit to clean artifacts older than maxAgeMinutes (default 120).
CursorThe Cursor tool exposed by this server.

Configuration

  • .NET 9.0 SDK (or later)https://dotnet.microsoft.com/download - reportgenerator global tool — the server shells out to it to render coverage reports (installed in the Install step below) - An MCP-compatible client (Claude Code, Gemini CLI, etc.) - COVERAGE_MCP_ALLOWED_ROOT — recommended. Set to your repository root to restrict
VariableDescriptionRequired
COVERAGE_MCP_ALLOWED_ROOTConfiguration value read at startup.Optional

Example prompts to try

  • Use Dotnet to GetSourceFiles.
  • Use Dotnet to RunTestsWithCoverage.
  • Use Dotnet to GetCoverageSummary.

Frequently asked questions

It connects Dotnet to MCP-compatible AI assistants such as Claude and Cursor, exposing 9 tools (GetSourceFiles, RunTestsWithCoverage, GetCoverageSummary, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Dotnet directly.