Labsco
aayushmdesai logo

mcp-dotnet-diagnostics

from aayushmdesai

MCP server for .NET runtime diagnostics โ€” memory, GC, threads, and more.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

CI mcp-dotnet-diagnostics MCP server

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

Health check demo

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 is ArrayPool<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.


Tools

ToolWhat it returnsReach for it when...
get_process_infoName, PID, uptime, .NET version, OSStarting any investigation โ€” confirms the process is reachable
get_memory_statsGC heap, LOH size, alloc rate, Gen0/1/2 counts, fragmentationMemory is high or growing
get_gc_eventsPer-collection timeline โ€” generation, reason, timestampGC pauses are affecting latency
get_thread_statsThreadPool count, queue depth, completed items, lock contentionRequests are slow or backing up
get_event_countersAll 27 System.Runtime metrics in one snapshotYou want a broad health overview
get_environment_infoRuntime config, filtered env vars (no secrets)Debugging configuration issues
list_countersRaw EventCounter names and current valuesDiscovering what's available on an unfamiliar process

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.


Tests

dotnet test src/McpDotnetDiagnostics.Tests

34 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:


License

MIT