dotnet-coverage-mcp gives an AI assistant direct access to .NET test-coverage tooling β running tests, parsing Cobertura XML, finding uncovered branches, and diffing coverage between runs, all over stdio.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
One-click editor setup isnβt available for this listing yet β we donβt have a confirmed install command, and weβd rather show nothing than point your editor at the wrong package or host. Follow the projectβs own setup instructions, linked above.
Inspect callable tools, capabilities, and parameters exposed to AI agents by Dotnet Coverage MCP.
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.
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.
This server lets an AI assistant run unit tests, collect coverage data, and analyse results β all without leaving the chat. Instead of manually running dotnet test and parsing reports, the AI can call the server's tools directly to:
The server starts as a console process and communicates over stdio using the MCP protocol. An MCP-compatible client (Claude Code, Gemini CLI, etc.) launches the process and calls its tools as if they were functions.
| Tool | Description |
|---|---|
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. Supports forceRestore and sessionId for concurrent isolation. |
GetCoverageSummary | Parse 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. |
GetFileCoverage | Get 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. |
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 isolation. |
AppendTestCode | Insert 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. |
CleanupSession | Remove session state files and TestResults/coveragereport directories. Pass sessionId to scope, or omit to clean artifacts older than maxAgeMinutes (default 120). |
For projects with many source files, the recommended workflow is:
GetSourceFiles on a folder or .csproj to get all files and smart batchesRunTestsWithCoverage with a broad filter (e.g., *) to collect coverage across all filesGetFileCoverage for each file in the current batch (instant XML parsing, no test re-run)GetUncoveredBranches for eachAppendTestCode to add test methodsGetCoverageDiff to verify improvementThis minimises dotnet test invocations (the main bottleneck) while still tracking per-file progress.
Multiple AI agents can run in parallel by passing a sessionId to each tool call, which isolates their coverage artifacts:
RunTestsWithCoverage creates TestResults-{hash}/ and coveragereport-{hash}/ per session, preventing one agent from deleting another's XML mid-parse.mcp-coverage/.coverage-state-{hash}, so ResolveCoberturaPath resolves to the correct XML for each sessionGetCoverageDiff stores baselines as .coverage-prev-{hash}.xml per sessionLimitation β build outputs are not session-scoped.
sessionIdisolates coverage artifacts, not the .NET build.dotnet testcompiles the target project into its sharedobj/andbin/, which are not per-session, so two agents runningRunTestsWithCoverageagainst the same test project at the same time collide on those outputs and fail withbuildError(e.g.CS2012: the file is being used by another process). Run parallel agents against different test projects, or on separate working copies of the repo. Multiple agents on one project are fine as long as theirdotnet testbuilds don't overlap.
Without sessionId, tools use shared defaults β safe for single-agent use.
.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 every tool's filesystem access to that subtree. Any path passed by the client outside this root is rejected with pathNotAllowed. When unset, the server logs a warning once and accepts any path (backward-compatible, but not recommended for shared environments).
Install the server as a global .NET tool from NuGet:
The server depends on the reportgenerator global tool to render coverage reports β install it too:
After install, the dotnet-coverage-mcp command is on your PATH.
The server will start and wait for MCP messages over stdin/stdout.
After installing the global tool (dotnet tool install --global dotnet-coverage-mcp),
register the server with your MCP client. Set COVERAGE_MCP_ALLOWED_ROOT to the
repository you want the server to operate on.
Add to claude_desktop_config.json (Settings β Developer β Edit Config):
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per-project):
Add to .vscode/mcp.json:
To run from source instead of the global tool, use dotnet run:
Or point directly at the compiled executable:
GetSourceFiles| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | Path to a .cs file, folder, or .csproj project |
lineBudget | int | No | Max total lines per batch (default: 300). Small files are grouped together; large files get their own batch. |
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/dotnet-coverage-mcp)<a href="https://allmcps.com/mcp/dotnet-coverage-mcp"><img src="https://allmcps.com/api/badge/dotnet-coverage-mcp?style=directory" alt="Dotnet Coverage MCP on AllMCPs" /></a>