
Memorylens Mcp
io.github.MarcelRoozekrans由 GitHub 账号 MarcelRoozekrans 发布v2.1.3更新于 Oct 31, 2026
MCP server for .NET memory profiling — in-process heap snapshots via EventPipe with leak heuristics
概览
本地 MCP 服务器,让助手对 .NET 进程做内存分析:列出进程、抓取堆快照、对比快照并运行泄漏规则。
- 可以做什么
- 列出可供分析的正在运行的 .NET 进程
- 按 PID 抓取目标进程的堆快照,并对比间隔一段时间采集的两份快照
- 对快照运行内置规则引擎,按严重程度返回发现
- 列出可用的分析规则及其元数据
- 适用场景
- 适用于排查正在运行的 .NET 应用的内存增长或疑似泄漏,希望助手采集堆数据并指出可能原因,而无需安装分析器。
- 运行要求
- 以本地 stdio 进程运行;npm 包只是启动器,会安装对应版本的 MemoryLens.Mcp .NET 全局工具,因此 PATH 中需要有 .NET 10 SDK(10.0.4xx 特性带)。也可作为 NuGet 全局工具安装或通过 dnx 运行。在 Linux 和容器中附加进程可能需要相同 UID 或 SYS_PTRACE。未声明账号、密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 Memorylens Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
MemoryLens MCP
[NuGet] [NuGet Downloads] [npm] [Build Status] [codecov] [License]
On-demand .NET memory profiling with concrete, AI-actionable code fix suggestions — no profiler to install.
[memorylens-mcp MCP server]Hosted deployment
A hosted deployment is available on Fronteir AI.
Quick Start
npx (any MCP client)
The npm package ships no server code — it is a launcher that installs the MemoryLens.Mcp .NET
global tool at a matching version and execs it, so the .NET 10 SDK must be on PATH.
Subsequent starts skip the install entirely and work offline.
VS Code / Visual Studio (via dnx)
Add to your MCP settings (.vscode/mcp.json or VS settings):
Claude Code Plugin
The plugin runs the NuGet tool through dnx, so it needs the .NET 10 SDK and nothing else.
.NET Global Tool
Docker
Profiling from a container needs ptrace and the host PID namespace, and on
Docker Desktop that namespace is the Linux VM rather than your desktop — see
docs/docker.md before choosing this route.
-v /tmp:/tmp is what makes list_processes return anything — the runtime's
diagnostic sockets live in the temp directory — and it is also what keeps
snapshots alive after --rm, since they are written to
/tmp/memorylens-snapshots inside the container. -v "$PWD:/workspace" is only
so .memorylens.json is picked up; nothing is written there.
Prerequisites
- .NET 10 SDK, 10.0.4xx feature band (pinned in
global.json)
Running a filtered subset of the tests, e.g. dotnet test --filter <name>, will exit with code 9
and print error: 1, failed: 0. That's the test project's discovery-collapse guard
(--minimum-expected-tests) firing because the filter left fewer tests than expected — it is
not a test failure, and a full dotnet test run is unaffected.
How Collection Works
MemoryLens collects heap data in-process over 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.
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.
On Linux and in containers, attaching to another process's diagnostic endpoint may require matching UID or SYS_PTRACE — see docs/docker.md.
Available MCP Tools
Built-in Rules
Configuration
Create a .memorylens.json file in your project root to customize rule behavior:
Usage Examples
Single Snapshot
Capture a memory snapshot of a running process to inspect current memory state:
Claude will call snapshot with the target PID, then analyze the returned snapshot id and present findings ordered by severity.
Before/After Comparison
Detect memory growth by comparing two snapshots taken with a delay:
Claude 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.
Family
MemoryLens MCP is part of a small family of .NET projects for AI work:
- AI.Sentinel: Security monitoring middleware for
IChatClient: prompt injection, hallucination and PII detection with an audit trail. - Minos.NET: Typed, source-generated decision questions with calibrated answers.
- Rag.NET: A modular retrieval-augmented generation pipeline on Microsoft.Extensions.AI.
- Roslyn CodeLens MCP: Semantic .NET code intelligence for AI agents over MCP.
Built on ZeroAlloc
MemoryLens MCP uses these ZeroAlloc libraries, which are source generators and analyzers with no reflection at runtime:
License
来源:README.md,提交 59babff
工具
0版本历史
2- v2.1.3最新Oct 31, 2026
- v2.1.2Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分