Mcp Mat

io.github.codelipenghui由 GitHub 账号 codelipenghui 发布v0.1.0更新于 Oct 24, 2026

Headless Eclipse MAT MCP server for Java heap dump analysis

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

无界面的 Eclipse MAT MCP 服务器,让助手分析 Java 堆转储:运行报告、OQL 查询和内置 MAT 命令。

可以做什么
检查 MAT 与 Java 运行时是否可用,以及堆转储是否已有索引产物,并获取 OQL 解析指引和支持的写法。运行预定义 MAT 报告,如泄漏嫌疑和系统概览。执行 OQL 查询并直接返回结果。运行内置 MAT 分析命令,涵盖支配树、GC 根路径、直方图、泄漏检测、线程、集合、引用、终结器、保留集、最大占用对象、字符串和堆概览。导出堆转储,并针对基线转储运行对比报告。
适用场景
适合从堆转储排查 Java 内存问题:查找泄漏、支配树、GC 根路径、线程与集合分析,或对比两份转储。面向已安装 Eclipse MAT 并持有 .hprof 文件的开发者和运维人员。
运行要求
以本地 Node.js 进程运行(npm 包 mcp-mat,或从源码构建)。需要 Java 运行时(JAVA_PATH,默认 java)和 Eclipse MAT 安装(MAT_HOME 或 MAT_LAUNCHER)。可选设置包括 MAT_XMX_MB(默认 4096)、MAT_TIMEOUT_SEC(默认 1800)以及 /tmp 下的工作目录。仅限桌面端。
安装前请注意
分析会以本地 Java 进程运行 MAT,默认堆较大(MAT_XMX_MB 为 4096)、默认超时较长(MAT_TIMEOUT_SEC 为 1800),大转储可能占用大量内存和时间。堆转储含敏感应用数据,MAT 默认将配置、工作区和调试日志写入本地目录;MAT_PRIVACY_MODE 与日志目录设置可控制保留内容。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Mcp Mat,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-mat

Headless MCP server for Eclipse MAT using direct java -jar org.eclipse.equinox.launcher_*.jar execution.

Features

  • mat_healthcheck — Validate MAT launcher and Java runtime availability
  • mat_parse_report — Run predefined MAT reports (leak suspects, system overview, etc.)
  • mat_oql_query — Execute OQL queries and return inline results
  • mat_run_command — Execute 56 built-in MAT analysis commands (histogram, dominator_tree, path2gc, thread_overview, etc.)
  • mat_index_status — Check whether MAT index artifacts exist for a heap dump
  • mat_oql_spec — Return OQL parser guidance and supported patterns

Supported Commands (mat_run_command)

Dominator tree analysis

dominator_tree, show_dominator_tree, immediate_dominators, big_drops_in_dominator_tree

Path to GC roots

path2gc, merge_shortest_paths, gc_roots

Histogram & object listing

histogram, delta_histogram*, list_objects, group_by_value, duplicate_classes

Leak detection

leakhunter, leakhunter2, find_leaks, find_leaks2, reference_leak

Thread analysis

thread_overview, thread_details, thread_stack

Collection analysis

collection_fill_ratio, collections_grouped_by_size, array_fill_ratio, arrays_grouped_by_size, hash_entries, map_collision_ratio, extract_list_values, hash_set_values, primitive_arrays_with_a_constant_value

Reference analysis

references_statistics, weak_references_statistics, soft_references_statistics, phantom_references_statistics, finalizer_references_statistics

Finalizer analysis

finalizer_overview, finalizer_thread, finalizer_queue, finalizer_in_processing, finalizer_thread_locals

Retained set

show_retained_set, customized_retained_set

Component & top consumers

component_report, component_report_top, top_consumers, top_consumers_html, pie_biggest_objects

String & memory waste

find_strings, waste_in_char_arrays

Heap info & misc

heap_dump_overview, unreachable_objects, system_properties, class_references, comparison_report*

Eclipse/OSGi specific

bundle_registry, leaking_bundles

Export

export_hprof

* Requires a baseline heap dump (second .hprof file).

OQL mode notes

  • This server normalizes client OQL input and wraps it for MAT parse-app command mode.
  • You can send OQL with or without outer quotes.
  • For class ranking and top consumers, prefer mat_parse_report with org.eclipse.mat.api:overview and parse Class_Histogram*.txt.
  • For object inspection, use simple field-level OQL patterns (INSTANCEOF, OBJECTS 0x...).

Environment

All environment variables are optional:

  • MAT_HOME
  • MAT_LAUNCHER
  • JAVA_PATH (default java)
  • MAT_XMX_MB (default 4096)
  • MAT_TIMEOUT_SEC (default 1800)
  • MAT_CONFIG_DIR (default /tmp/mat-config)
  • MAT_DATA_DIR (default /tmp/mat-workspace)
  • MAT_DEBUG (default false)
  • MAT_DEBUG_LOG_DIR (default /tmp/mcp-mat-logs)
  • MAT_PRIVACY_MODE (default false)
  • MAT_OQL_MAX_BYTES (default 16384)
  • MAT_RESULT_PREVIEW_LINES (default 20)
  • MAT_STDIO_TAIL_CHARS (default 4000)

Run

bash
npm installnpm run buildMAT_HOME=/path/to/mat node dist/src/server.js

Test

bash
npm test

Install via npx

No build step required. Install directly from npm:

Claude Code

Add to ~/.claude/settings.json or project .claude/settings.json:

json
{  "mcpServers": {    "mat": {      "command": "npx",      "args": ["-y", "mcp-mat"],      "env": {        "MAT_HOME": "/Applications/MemoryAnalyzer.app/Contents/Eclipse"      }    }  }}

Codex

bash
codex mcp add \  --env MAT_HOME=/Applications/MemoryAnalyzer.app/Contents/Eclipse \  mat \  npx -y mcp-mat

Install in Claude Code (from source)

Add the MCP server to Claude Code settings (~/.claude/settings.json or project .claude/settings.json):

json
{  "mcpServers": {    "mat": {      "command": "node",      "args": ["/path/to/mcp-mat/dist/src/server.js"],      "env": {        "MAT_HOME": "/Applications/MemoryAnalyzer.app/Contents/Eclipse"      }    }  }}

Install in Codex (from source)

Build first:

bash
cd /path/to/mcp-matnpm installnpm run build

Add MCP server to Codex:

bash
codex mcp add \  --env MAT_HOME=/Applications/MemoryAnalyzer.app/Contents/Eclipse \  mat \  node /path/to/mcp-mat/dist/src/server.js

Verify:

bash
codex mcp listcodex mcp get mat --json

If you need to update the entry:

bash
codex mcp remove mat# then run codex mcp add ... again

Equivalent ~/.codex/config.toml entry:

toml
[mcp_servers.mat]command = "node"args = ["/path/to/mcp-mat/dist/src/server.js"]
[mcp_servers.mat.env]MAT_HOME = "/Applications/MemoryAnalyzer.app/Contents/Eclipse"

来源:README.md,提交 681cc67

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分