mcp-dotnet-diagnostics
mcp-dotnet-diagnostics
Give your AI assistant real-time visibility into your .NET application's runtime health.
Connect this Model Context Protocol server to Claude Desktop and ask plain questions about any running .NET process — memory leaks, GC pressure, thread starvation, allocation hotspots. Claude calls the right tools, reads real runtime data, and tells you what's actually wrong.
What this looks like in practice

You ask:
"Why does my API have high memory usage? PID is 12345."
Claude calls get_process_info to confirm connectivity, then get_memory_stats, then
get_gc_events — and responds:
"Every GC event in the last 5 seconds was a Gen2 collection triggered by
AllocLarge. Something is continuously allocating objects above the 85KB LOH threshold at ~10.5 MB/s. LOH is never compacted by default — fragmentation is at 55% and growing. The fix isArrayPool<byte>.Shared. Rent a buffer, use it, return it."
You don't tell Claude which tools to call. It figures that out from your question.
Related MCP server: ASPNET Core Debugging MCP Server
Tools
Tool | What it returns | Reach for it when... |
| Name, PID, uptime, .NET version, OS | Starting any investigation — confirms the process is reachable |
| GC heap, LOH size, alloc rate, Gen0/1/2 counts, fragmentation | Memory is high or growing |
| Per-collection timeline — generation, reason, timestamp | GC pauses are affecting latency |
| ThreadPool count, queue depth, completed items, lock contention | Requests are slow or backing up |
| All 27 | You want a broad health overview |
| Runtime config, filtered env vars (no secrets) | Debugging configuration issues |
| Raw EventCounter names and current values | Discovering what's available on an unfamiliar process |
Installation
1. Install the tool
dotnet tool install -g mcp-dotnet-diagnosticsRequires .NET 8 SDK or later. Get it here if needed.
2. Add to Claude Desktop
Open ~/Library/Application Support/Claude/claude_desktop_config.json while Claude Desktop
is fully quit (Cmd+Q — not just the window closed), then add:
{
"mcpServers": {
"dotnet-diagnostics": {
"command": "mcp-dotnet-diagnostics",
"env": {
"TMPDIR": "/var/folders/xx/your-tmpdir/T/"
}
}
}
}3. Reopen Claude Desktop
The dotnet-diagnostics connector appears in the tools menu. Ask it about any .NET process.
macOS: the
TMPDIRstep is not optional.The .NET diagnostics protocol finds processes through a Unix socket. On macOS, that socket lives under
$TMPDIR— not/tmp/where the library looks by default. Without this, every tool call returns "process not found."Find yours with:
echo $TMPDIR
Want to contribute or build from source? See CONTRIBUTING.md for how to clone, build, and add new tools.
Usage
Find the PID of your target process:
dotnet-counters psThen ask Claude naturally: "Do a full health check on PID 12345." "Why is memory climbing on PID 12345?" "Any thread starvation in PID 12345?" "What's the GC situation on PID 12345?"
How it works
The server uses Microsoft.Diagnostics.NETCore.Client to attach to any running .NET process
by PID — the same library that powers dotnet-counters, dotnet-trace, and dotnet-dump.
It streams telemetry directly from the CLR over EventPipe, which means you get the same data
as the official .NET CLI tools, available to Claude as structured tool responses.
The tool descriptions are written to guide Claude's investigation sequence. When you report
high memory, Claude calls get_process_info first (connectivity), then get_memory_stats
(heap overview), then get_gc_events (collection details) — because the descriptions say to.
The chaining is implicit, not hardcoded.
Requirements
.NET 8 SDK or later to build; .NET 10 recommended
Claude Desktop or any MCP-compatible client
A running .NET process to inspect (your app, an API, anything)
Tests
dotnet test src/McpDotnetDiagnostics.Tests34 tests across all 7 tools — unit tests against invalid PIDs, integration tests against the
live test runner process (Environment.ProcessId). Runs in ~17 seconds.
Design decisions
Three decisions shaped this project in ways that aren't obvious from the outside:
ADR-001: C# over TypeScript — the diagnostics library is .NET-native; a TypeScript wrapper would mean shelling out
ADR-002: Target process by PID, not self — the MCP server itself is uninteresting; your API is where the real data lives
ADR-003: .NET 10 EventPipe payload extraction — undocumented payload structure change in .NET 10, discovered through runtime inspection
License
MIT
Available Tools
7 toolsget_environment_infoA
Returns runtime environment information for a target .NET process including .NET runtime version, OS details, processor count, memory, and process configuration. Use this when investigating version mismatches, environment-specific bugs, or unexpected runtime behavior. Call get_process_info first to confirm the process is reachable.
Inputs: pid (required).
get_event_countersA
Returns all available EventCounter metrics from a .NET process including CPU usage, memory, GC, threading, exceptions, and JIT stats in a single call. Use this for a broad health overview when you don't know which specific area to investigate. For deeper analysis, follow up with get_memory_stats or get_thread_stats.
Inputs: pid (required), sampleSeconds.
get_gc_eventsA
Returns recent GC events for a target .NET process including collection generation (Gen0/Gen1/Gen2), duration, pause time, and timestamp. Use this when investigating periodic response time spikes, application pauses, memory that grows without releasing, or when get_memory_stats shows high Gen2 collection counts. Call get_memory_stats first to establish whether GC pressure is the root cause before drilling into individual events.
Inputs: pid (required), sampleSeconds.
get_memory_statsA
Returns current .NET memory usage for a target process including total allocated bytes, GC generation collection counts (Gen0/Gen1/Gen2), Large Object Heap size, and memory pressure level. Use this when investigating memory leaks, unexpectedly high memory usage, frequent GC pauses, or slow application performance caused by garbage collection pressure. Call get_process_info first to confirm the process is reachable.
Inputs: pid (required), sampleSeconds.
get_process_infoA
Returns basic information about a running .NET process by PID. Includes process name, uptime, .NET runtime version, OS platform, and CPU core count. Use this as the first step when investigating any .NET application — it confirms the process is reachable and provides baseline context before diving into memory or thread diagnostics.
Inputs: pid (required).
get_thread_statsA
Returns .NET ThreadPool statistics for a target process including worker thread count, available threads, queue length, and completed work items. Use this when investigating slow response times, request timeouts, or deadlocks — high queue length and low available threads indicates thread starvation, which is a common cause of latency spikes in .NET APIs. Call get_memory_stats first — GC pressure is a frequent cause of thread starvation.
Inputs: pid (required), sampleSeconds.
list_countersA
Lists all available EventCounter names and current values from a .NET process. Use this to discover what metrics are available before calling get_memory_stats.
Inputs: pid (required), sampleSeconds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Tools are mostly distinct with clear purposes, but there is some overlap between list_counters, get_event_counters, and the specific tools like get_memory_stats. The descriptions provide guidance on when to use each, reducing ambiguity.
All tool names follow a consistent verb_noun pattern (e.g., get_process_info, list_counters). No mixing of conventions.
7 tools is well-scoped for a diagnostics server. Each tool covers a distinct aspect (process info, environment, memory, threads, GC, counters), without being excessive or insufficient.
The tool set covers key diagnostic areas (environment, memory, threads, GC, event counters). Minor gaps exist: no dedicated CPU or exception analysis tool, but they are included in the broad health overview.
Maintenance
Related MCP Connectors
Exception tracking for .NET. Let your AI coding agent search and triage errors and stack traces.
Errors, logs and AI-call costs for apps on Node.js, Next.js, Cloudflare Workers or the browser. Ask your AI what’s broken, why, and how to fix it, right inside Cursor or Claude.
Live browser debugging for AI assistants — DOM, console, network via MCP.
Monitoring + status pages set up by talking to Claude. Auto-detects 30+ SDKs and your URLs.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server for .NET memory profiling with AI-actionable code fix suggestions, powered by JetBrains dotMemory511MIT
- AlicenseAqualityBmaintenanceMCP server that lets AI agents (Claude, Cursor) debug your .NET / ASP.NET Core app2715MIT
- AlicenseBqualityBmaintenanceEnables AI coding agents to debug .NET applications with breakpoints, stepping, variable inspection, and GUI automation for WPF, WinForms, and Avalonia apps.135157 PyPI8MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to analyze JVM thread dumps and GC logs, detecting deadlocks, lock contention, and GC pressure, without requiring a JVM runtime.740 npm2MIT