# mcp-mat

Runs Eclipse MAT reports on a Java heap dump and returns the findings in chat. Useful when an app dies from memory pressure and you would rather not open the MAT desktop app.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 26
- Author: codelipenghui
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/codelipenghui/mcp-mat
- Updated: 2026-03-19
- HTML: https://affpapa.org/en/nevibecode/mcp/mcp-mat

## What it does

The server drives Eclipse MAT headless by calling `java -jar org.eclipse.equinox.launcher_*.jar` directly. Six tools come with it. `mat_healthcheck` confirms the launcher and Java are reachable, `mat_parse_report` fires predefined reports such as leak suspects or system overview, `mat_oql_query` runs OQL and returns rows inline, `mat_run_command` exposes one of 56 built-in analysis commands, `mat_index_status` tells you whether an index already exists for a dump, and `mat_oql_spec` returns guidance on OQL syntax.

The command list under `mat_run_command` covers `histogram`, `dominator_tree`, `path2gc`, `thread_overview`, `leakhunter`, collection and reference reports, `top_consumers`, and `export_hprof`. Four of them — `delta_histogram`, `leakhunter2`, `find_leaks2`, `comparison_report` — need a second `.hprof` file to compare against.

Eclipse MAT itself has to be installed first; point `MAT_HOME` at its directory. Everything else in the environment is optional: `JAVA_PATH` falls back to `java`, `MAT_XMX_MB` to 4096, and the timeout to 1800 seconds. If the MAT launcher is missing or broken, nothing runs, so calling `mat_healthcheck` first is the quick way to find out.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `MAT_HOME`, `JAVA_PATH`, `MAT_XMX_MB` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env MAT_HOME=<MAT_HOME> --env JAVA_PATH=<JAVA_PATH> --env MAT_XMX_MB=<MAT_XMX_MB> --transport stdio mcp-mat -- npx -y mcp-mat
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add mcp-mat --env MAT_HOME=<MAT_HOME> --env JAVA_PATH=<JAVA_PATH> --env MAT_XMX_MB=<MAT_XMX_MB> -- npx -y mcp-mat
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mcp-mat": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-mat"
            ],
            "env": {
                "MAT_HOME": "<MAT_HOME>",
                "JAVA_PATH": "<JAVA_PATH>",
                "MAT_XMX_MB": "<MAT_XMX_MB>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mcp-mat": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "mcp-mat"
            ],
            "env": {
                "MAT_HOME": "<MAT_HOME>",
                "JAVA_PATH": "<JAVA_PATH>",
                "MAT_XMX_MB": "<MAT_XMX_MB>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e MAT_HOME=<MAT_HOME> -e JAVA_PATH=<JAVA_PATH> -e MAT_XMX_MB=<MAT_XMX_MB> mcp-mat npx -y mcp-mat
```
Replace <…> with your own values

## When to use it
- investigate a Java heap dump after an out-of-memory crash
- hunt leaks with leak suspects and path to GC roots
- compare two dumps to see which classes grew
- read a histogram and dominator tree without launching the MAT GUI
- query live objects with OQL from the chat

## Example prompts
- Check whether `heap.hprof` is already indexed and build the index if not
- Run a histogram on `heap.hprof` and list the top classes by instance count
- Show path to GC roots for `com.example.Cache` using mcp-mat

## Similar
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [Oh My Posh Validator](https://affpapa.org/en/nevibecode/mcp/oh-my-posh-validator.md) — MCP server · ★ 23643
- [Keploy](https://affpapa.org/en/nevibecode/mcp/keploy.md) — MCP server · ★ 18727
- [Coder](https://affpapa.org/en/nevibecode/mcp/coder.md) — MCP server · ★ 17160
- [mcp](https://affpapa.org/en/nevibecode/mcp/kubeshark-mcp.md) — MCP server · ★ 12109

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
