{
  "markdown": "[![GitHub Sponsors](https://img.shields.io/github/sponsors/MarcelRoozekrans?style=flat&logo=githubsponsors&color=ea4aaa&label=Sponsor)](https://github.com/sponsors/MarcelRoozekrans)\n\n<p align=\"center\">\n  <img src=\"icon.svg\" width=\"128\" height=\"128\" alt=\"MemoryLens MCP\">\n</p>\n\n<h1 align=\"center\">MemoryLens MCP</h1>\n\n<p align=\"center\">\n  <a href=\"https://www.nuget.org/packages/MemoryLens.Mcp\"><img src=\"https://img.shields.io/nuget/v/MemoryLens.Mcp?style=flat-square&logo=nuget&color=blue\" alt=\"NuGet\"></a>\n  <a href=\"https://www.nuget.org/packages/MemoryLens.Mcp\"><img src=\"https://img.shields.io/nuget/dt/MemoryLens.Mcp?style=flat-square&color=green\" alt=\"NuGet Downloads\"></a>\n  <a href=\"https://www.npmjs.com/package/memorylens-mcp\"><img src=\"https://img.shields.io/npm/v/memorylens-mcp?style=flat-square&logo=npm&color=cb3837\" alt=\"npm\"></a>\n  <a href=\"https://github.com/MarcelRoozekrans/memorylens-mcp/actions\"><img src=\"https://img.shields.io/github/actions/workflow/status/MarcelRoozekrans/memorylens-mcp/ci.yml?branch=main&style=flat-square&logo=github\" alt=\"Build Status\"></a>\n  <a href=\"https://github.com/MarcelRoozekrans/memorylens-mcp/blob/main/LICENSE\"><img src=\"https://img.shields.io/github/license/MarcelRoozekrans/memorylens-mcp?style=flat-square\" alt=\"License\"></a>\n</p>\n\n<p align=\"center\">\n  On-demand .NET memory profiling with concrete, AI-actionable code fix suggestions — no profiler to install.\n</p>\n\n<a href=\"https://glama.ai/mcp/servers/MarcelRoozekrans/memorylens-mcp\">\n  <img width=\"380\" height=\"200\" src=\"https://glama.ai/mcp/servers/MarcelRoozekrans/memorylens-mcp/badge\" alt=\"memorylens-mcp MCP server\" />\n</a>\n\n<!-- mcp-name: io.github.MarcelRoozekrans/memorylens-mcp -->\n\n---\n\n## Hosted deployment\n\nA hosted deployment is available on [Fronteir AI](https://fronteir.ai/mcp/marcelroozekrans-memorylens-mcp).\n\n## Quick Start\n\n### npx (any MCP client)\n\n```json\n{\n  \"mcpServers\": {\n    \"memorylens\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"memorylens-mcp\"]\n    }\n  }\n}\n```\n\nThe npm package ships no server code — it is a launcher that installs the `MemoryLens.Mcp` .NET\nglobal tool at a matching version and execs it, so the **.NET 10 SDK must be on `PATH`**.\nSubsequent starts skip the install entirely and work offline.\n\n### VS Code / Visual Studio (via dnx)\n\nAdd to your MCP settings (`.vscode/mcp.json` or VS settings):\n\n```json\n{\n  \"servers\": {\n    \"memorylens\": {\n      \"type\": \"stdio\",\n      \"command\": \"dnx\",\n      \"args\": [\"MemoryLens.Mcp\", \"--yes\"]\n    }\n  }\n}\n```\n\n### Claude Code Plugin\n\n```bash\nclaude install gh:MarcelRoozekrans/memorylens-mcp\n```\n\n### .NET Global Tool\n\n```bash\ndotnet tool install -g MemoryLens.Mcp\n```\n\n### Docker\n\n```bash\ndocker build -t memorylens-mcp .\ndocker run -i --rm --pid=host --cap-add=SYS_PTRACE \\\n  -v /tmp:/tmp \\\n  -v \"$PWD:/workspace\" memorylens-mcp\n```\n\nProfiling from a container needs `ptrace` and the host PID namespace, and on\nDocker Desktop that namespace is the Linux VM rather than your desktop — see\n[docs/docker.md](docs/docker.md) before choosing this route.\n\n`-v /tmp:/tmp` is what makes `list_processes` return anything — the runtime's\ndiagnostic sockets live in the temp directory — and it is also what keeps\nsnapshots alive after `--rm`, since they are written to\n`/tmp/memorylens-snapshots` inside the container. `-v \"$PWD:/workspace\"` is only\nso `.memorylens.json` is picked up; nothing is written there.\n\n## Prerequisites\n\n- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0), 10.0.4xx feature band (pinned in `global.json`)\n\nRunning a filtered subset of the tests, e.g. `dotnet test --filter <name>`, will exit with code 9\nand print `error: 1, failed: 0`. That's the test project's discovery-collapse guard\n(`--minimum-expected-tests`) firing because the filter left fewer tests than expected — it is\nnot a test failure, and a full `dotnet test` run is unaffected.\n\n## How Collection Works\n\nMemoryLens collects heap data **in-process** over [EventPipe](https://learn.microsoft.com/dotnet/core/diagnostics/eventpipe), the .NET runtime's built-in diagnostics channel. There is no profiler to install, no download on first use, and no external tool on `PATH`.\n\n`snapshot` attaches to a running .NET process by pid, induces a collection, and aggregates the heap into per-type counts and sizes. Snapshots are written as small JSON files under your temp directory and referenced by a short id.\n\nOn Linux and in containers, attaching to another process's diagnostic endpoint may require matching UID or `SYS_PTRACE` — see [docs/docker.md](docs/docker.md).\n\n## Available MCP Tools\n\n| Tool | Description |\n|------|-------------|\n| `list_processes` | Lists running .NET processes available for profiling, discovered from their diagnostic IPC endpoints |\n| `snapshot` | Captures a single memory snapshot of a target process |\n| `compare_snapshots` | Captures two snapshots with configurable delay and compares them |\n| `analyze` | Runs the rule engine against a captured snapshot and returns findings |\n| `get_rules` | Lists all available analysis rules with their metadata |\n\n## Built-in Rules\n\n| ID | Severity | Category | Description |\n|----|----------|----------|-------------|\n| ML001 | critical | leak | Event handler leak detected |\n| ML002 | critical | leak | Static collection growing unbounded |\n| ML003 | high | leak | Disposable object not disposed |\n| ML004 | high | fragmentation | Large Object Heap fragmentation |\n| ML005 | medium | retention | Object retained longer than expected |\n| ML006 | medium | allocation | Excessive allocations in hot path |\n| ML007 | medium | retention | Closure retaining unexpected references |\n| ML008 | low | allocation | Array/list resizing without capacity hint |\n| ML009 | low | pattern | Finalizer without Dispose pattern |\n| ML010 | low | pattern | String interning opportunity |\n\n## Configuration\n\nCreate a `.memorylens.json` file in your project root to customize rule behavior:\n\n```json\n{\n  \"rules\": {\n    \"ML001\": { \"enabled\": true, \"severity\": \"critical\" },\n    \"ML002\": { \"enabled\": true, \"severity\": \"critical\" },\n    \"ML003\": { \"enabled\": true, \"severity\": \"high\" },\n    \"ML004\": { \"enabled\": true, \"severity\": \"high\" },\n    \"ML005\": { \"enabled\": true, \"severity\": \"medium\" },\n    \"ML006\": { \"enabled\": true, \"severity\": \"medium\" },\n    \"ML007\": { \"enabled\": true, \"severity\": \"medium\" },\n    \"ML008\": { \"enabled\": true, \"severity\": \"low\" },\n    \"ML009\": { \"enabled\": true, \"severity\": \"low\" },\n    \"ML010\": { \"enabled\": true, \"severity\": \"low\" }\n  }\n}\n```\n\n## Usage Examples\n\n### Single Snapshot\n\nCapture a memory snapshot of a running process to inspect current memory state:\n\n```\n> /memorylens\n> Take a snapshot of my running API (PID 12345)\n```\n\nClaude will call `snapshot` with the target PID, then `analyze` the returned snapshot id and present findings ordered by severity.\n\n### Before/After Comparison\n\nDetect memory growth by comparing two snapshots taken with a delay:\n\n```\n> /memorylens\n> Check if my app has a memory leak — compare before and after processing 1000 requests\n```\n\nClaude will call `compare_snapshots` with a `delaySeconds` value (default 10 seconds) between the two captures, then analyze the diff to identify objects that grew between snapshots.\n\n## License\n\n[MIT](LICENSE)",
  "bytes": 7295,
  "sha": "a4e4acc5a39cace7f4357599c77eaaebf7ae7a4b60aa074adf006277a9c68ac1",
  "repo_slug": "marcelroozekrans/memorylens-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_marcelroozekrans_memorylens_mc_bad287f1/readme"
}