SuperAPI AI Directory

memorylens-mcp

#️⃣ 🏠 🪟 - On-demand .NET memory profiling with JetBrains dotMemory: detects memory leaks, LOH fragmentation and anti-patterns, and suggests code fixes.

Open website

About this tool

MemoryLens MCP is a memory profiling MCP server for .NET applications, powered by JetBrains dotMemory, that can generate concrete and AI-executable code fix suggestions. Its core feature is on-demand memory profiling, with no separate profiler installation required.

Main capabilities:

  • On-demand .NET memory profiling: by attaching to a running .NET process, capturing heap snapshots, and aggregating the object count and size per type.
  • Detects memory leaks, large object heap (LOH) fragmentation, and anti-patterns, and provides code fix suggestions.
  • Provides before-and-after snapshot comparison to identify objects that grew between two snapshots, thereby discovering memory growth issues.
  • Supports customizing rule behavior through the .memorylens.json file (must be placed in the project root directory).

How it works: MemoryLens collects heap data in-process through EventPipe (the diagnostic channel built into the .NET runtime). No profiler installation is required, no download is required on first use, and no external tools need to be placed in PATH. The snapshot tool attaches to a running .NET process by PID, triggers a garbage collection, and aggregates the heap into per-type counts and sizes. Snapshots are written as small JSON files to a temporary directory and referenced by a short ID. On Linux and in containers, attaching to another process's diagnostic endpoint may require matching UID or SYS_PTRACE permissions.

Usage:

  • npx (works with any MCP client): the npm package itself does not contain the server code, but is a launcher that installs the matching version of the MemoryLens.Mcp .NET global tool and executes it, so the .NET 10 SDK must be in PATH. Subsequent launches skip installation and work offline.
  • VS Code / Visual Studio (via dnx): add to MCP settings (.vscode/mcp.json or VS settings).
  • Claude Code plugin and .NET global tool are also supported.
  • Hosted deployment: available as a hosted deployment on Fronteir AI.
  • Profiling from a container: requires ptrace and the host PID namespace; on Docker Desktop, that namespace is the Linux VM rather than your desktop. Use -v /tmp:/tmp to make list_processes return results (the runtime diagnostic socket is located in the temporary directory), and keep snapshots after --rm (snapshots are written to /tmp/memorylens-snapshots inside the container). Use -v "$PWD:/workspace" only to read .memorylens.json; nothing is written.

Usage examples of available MCP tools:

  • Single snapshot: capture a memory snapshot of a running process to inspect the current memory state. Claude will call snapshot with the target PID, then analyze the returned snapshot ID and present the findings by severity.
  • Before-and-after comparison: detect memory growth by comparing two snapshots with a delay. Claude will call compare_snapshots, use a delaySeconds value (default 10 seconds) to wait between the two captures, and then analyze the difference to identify growing objects.

Requirements and limitations:

  • Requires the .NET 10 SDK, 10.0.4xx feature band (pinned in global.json).
  • Running a filtered subset of tests (such as dotnet test --filter <name>) will exit with exit code 9 and print error: 1, failed: 0. This is triggered by the test project's discovery collapse protection (--minimum-expected-tests) because fewer tests remain after filtering than expected—it is not a test failure, and a full dotnet test run is unaffected.
  • Container profiling requires specific permissions and namespace settings, as detailed in docs/docker.md.
  • Other feature details, pricing models, prices, applicable scenarios, and similar information are not yet available.