Skip to main content
MCP server CX Codex

memorylens-mcp — Claude Code MCP server: .NET memory profiling

Takes heap snapshots of a running .NET process over EventPipe and flags likely leaks. Useful when memory climbs and you would rather not install a profiler.

Install into Claude Code · Platform CLI All methods and platforms ↓
claude mcp add memorylens-mcp -- npx -y memorylens-mcp
Open on GitHub

What memorylens-mcp does

The server attaches to a .NET process by pid, forces a collection, then groups the heap by type with counts and sizes. Each snapshot lands as a small JSON file in your temp directory and gets a short id you can refer back to. A rule engine then reads that snapshot and reports findings tied to code you can change.

Ten rules ship with it, ML001 through ML010. They cover event handler leaks, static collections that keep growing, missing Dispose calls, Large Object Heap fragmentation, and wasted allocations on hot paths. A .memorylens.json file in the project root controls this: any rule can be turned off or given a different severity.

The .NET 10 SDK has to be on PATH before anything runs. The npm package holds no server code — it installs the MemoryLens.Mcp global tool and execs it. On Linux and inside containers, attaching to another process's diagnostic endpoint needs a matching UID or SYS_PTRACE; without it you get no snapshot.

What it helps with

  • find which type is holding memory after a service runs for hours
  • compare heap state before and after a load test
  • catch an event handler leak
  • check whether a static collection grows without bound
  • list .NET processes available for profiling

Example prompts for the agent

  • Take a memory snapshot of my running API, PID 12345
  • Capture two snapshots with a delay and compare them
  • Run the rules against the latest snapshot and show me the findings

How to install memorylens-mcp

Platform CLI

claude mcp add memorylens-mcp -- npx -y memorylens-mcp

Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more

Questions about memorylens-mcp

How do I install memorylens-mcp in Claude Code?

Run claude mcp add memorylens-mcp -- npx -y memorylens-mcp.

What does memorylens-mcp do?

It snapshots the heap of a .NET process by pid, compares snapshots, and runs rules that look for leaks and excess allocations.

What do I need before it works?

The .NET 10 SDK must be on PATH, since the npm package only installs and launches the MemoryLens.Mcp global tool. On Linux and in containers, attaching to a process requires a matching UID or SYS_PTRACE.

Similar MCP servers

All MCP servers for Backend and APIs →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor