mcp-dotnet-diagnostics

mcp-dotnet-diagnostics

Live .NET runtime diagnostics for AI assistants. Ask Claude to diagnose memory leaks, GC pressure, LOH fragmentation, and thread starvation in any running .NET process — no code changes required.

Category
访问服务器

README

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

Tool What it returns Reach for it when...
get_process_info Name, PID, uptime, .NET version, OS Starting any investigation — confirms the process is reachable
get_memory_stats GC heap, LOH size, alloc rate, Gen0/1/2 counts, fragmentation Memory is high or growing
get_gc_events Per-collection timeline — generation, reason, timestamp GC pauses are affecting latency
get_thread_stats ThreadPool count, queue depth, completed items, lock contention Requests are slow or backing up
get_event_counters All 27 System.Runtime metrics in one snapshot You want a broad health overview
get_environment_info Runtime config, filtered env vars (no secrets) Debugging configuration issues
list_counters 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-diagnostics

Requires .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 TMPDIR step 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 ps

Then 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.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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选