Skip to main content
Glama

java_mat_suspects

Analyze a heap dump to identify memory leak suspects using Eclipse MAT. Provides structured verdicts to guide investigation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
heap_dump_fileYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool registration for java_mat_suspects via @mcp.tool() decorator, delegating to tools.java_mat_suspects
    @mcp.tool()
    def java_mat_suspects(heap_dump_file: str) -> dict[str, Any]:
        return tools.java_mat_suspects(heap_dump_file=heap_dump_file)
  • Core handler implementation: runs Eclipse MAT CLI (ParseHeapDump.sh) with the 'suspects' report, parses output, collects report files, and returns evidence/metrics.
    def java_mat_suspects(heap_dump_file: str) -> dict[str, Any]:
        heap_path = Path(heap_dump_file)
        if not heap_path.exists():
            return error_result(
                f"Heap dump file not found: {heap_dump_file}",
                next_recommended_action="Run java_heap_dump first and pass its artifact path.",
            )
    
        try:
            mat_bin = os.environ.get("MAT_BIN")
            if mat_bin:
                mat_exec = mat_bin
            else:
                mat_exec = require_any_binary(
                    ["ParseHeapDump.sh", "ParseHeapDump.bat", "mat"],
                    "Install Eclipse MAT CLI and set MAT_BIN if binary is not in PATH.",
                )
    
            mat_env: dict[str, str] | None = None
            java_home = os.environ.get("JAVA_HOME")
            if java_home:
                path_sep = ";" if os.name == "nt" else ":"
                java_bin = os.path.join(java_home, "bin")
                mat_env = {
                    "JAVA_HOME": java_home,
                    "PATH": java_bin + path_sep + os.environ.get("PATH", ""),
                }
    
            result = run_command(
                [mat_exec, str(heap_path), "org.eclipse.mat.api:suspects"],
                timeout_s=1200,
                env=mat_env,
            )
    
            if result.returncode != 0:
                raise CommandExecutionError(
                    f"MAT suspects analysis failed with code {result.returncode}. stderr: {result.stderr.strip()[:1000]}"
                )
    
            parsed = parse_mat_suspects_output(result.stdout + "\n" + result.stderr)
        except ToolingMissingError as exc:
            return _missing_tool(str(exc))
        except Exception as exc:  # noqa: BLE001
            return _command_failed(exc)
    
        # MAT writes reports next to the heap dump — scan for them
        report_paths = list(parsed["report_paths"])
        heap_stem = heap_path.stem
        heap_dir = heap_path.parent
        for pattern in (f"{heap_stem}_Leak_Suspects.zip", f"{heap_stem}*Leak*.html"):
            for found in heap_dir.glob(pattern):
                path_str = str(found)
                if path_str not in report_paths:
                    report_paths.append(path_str)
    
        report_path = report_paths[0] if report_paths else None
        confidence = "high" if parsed["suspect_lines"] or report_paths else "medium"
    
        evidence = [f"MAT suspects analysis completed for {heap_path}."]
        evidence.extend(parsed["suspect_lines"][:5])
        if report_paths:
            evidence.append(f"Report(s): {', '.join(report_paths[:3])}")
    
        return ok_result(
            evidence=evidence,
            metrics={
                "suspect_line_count": len(parsed["suspect_lines"]),
                "report_paths": report_paths,
            },
            confidence=confidence,
            next_recommended_action="Correlate MAT dominators with class histogram and allocation profile.",
            raw_artifact_path=report_path,
        )
  • Workflow imports java_mat_suspects from tools module for use in automated analysis pipeline
    java_mat_suspects,
  • Workflow calls java_mat_suspects with the raw heap dump artifact path during automated analysis
    mat_result = java_mat_suspects(heap_result["raw_artifact_path"])
  • java_heap_dump tool recommends 'Run java_mat_suspects' as next action, showing the intended workflow linkage
    return ok_result(
        evidence=[f"Heap dump created for PID {pid}: {path}"],
        metrics={"pid": pid, "size_bytes": path.stat().st_size, "live_only": live_only},
        confidence="medium",
        next_recommended_action="Run java_mat_suspects on this heap dump.",
        raw_artifact_path=str(path),
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SegfaultSorcerer/heap-seance'

If you have feedback or need assistance with the MCP directory API, please join our Discord server