Skip to main content
Glama

java_list_processes

List all running Java processes on the system to identify target JVMs for memory leak investigation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual implementation of java_list_processes. It requires the 'jcmd' binary, runs 'jcmd -l', parses the output via parse_jcmd_processes, filters out the jcmd process itself, and returns an ok_result with process info.
    def java_list_processes() -> dict[str, Any]:
        try:
            require_binary("jcmd", "Install OpenJDK 17+ so jcmd is available.")
            output = ensure_success(run_command(["jcmd", "-l"])).stdout
        except Exception as exc:  # noqa: BLE001
            return _command_failed(exc)
    
        all_processes = parse_jcmd_processes(output)
        processes = [
            process
            for process in all_processes
            if "sun.tools.jcmd.JCmd" not in process["main_class"]
        ]
        if not processes:
            processes = all_processes
        evidence = [f"Discovered {len(processes)} JVM process(es) via jcmd -l."]
        if processes:
            sample = ", ".join(str(proc["pid"]) for proc in processes[:5])
            evidence.append(f"Sample PIDs: {sample}")
    
        return ok_result(
            evidence=evidence,
            metrics={"process_count": len(processes), "processes": processes},
            confidence="low",
            next_recommended_action="Choose a target PID and run java_class_histogram + java_gc_snapshot.",
        )
  • The MCP tool registration using @mcp.tool() decorator in build_server(), which delegates to tools.java_list_processes().
    @mcp.tool()
    def java_list_processes() -> dict[str, Any]:
        return tools.java_list_processes()
  • The parse_jcmd_processes helper function that parses the output of 'jcmd -l' into a list of process dicts with pid, main_class, args, and display fields.
    def parse_jcmd_processes(text: str) -> list[dict[str, Any]]:
        processes: list[dict[str, Any]] = []
        for line in text.splitlines():
            match = PROCESS_LINE.match(line)
            if not match:
                continue
            pid = int(match.group(1))
            main_class = match.group(2)
            args = (match.group(3) or "").strip()
            processes.append(
                {
                    "pid": pid,
                    "main_class": main_class,
                    "args": args,
                    "display": f"{pid} {main_class} {args}".strip(),
                }
            )
        return processes
  • The _artifact_dir() helper used by tools for output paths (not directly used by java_list_processes but defined in the same file).
    def _artifact_dir() -> Path:
        import tempfile
    
        default = str(Path(tempfile.gettempdir()) / "heap-seance")
        target = Path(os.environ.get("HEAP_SEANCE_ARTIFACT_DIR", default))
        target.mkdir(parents=True, exist_ok=True)
        return target
  • Import of java_list_processes in workflow.py for use in the _pick_pid function and elsewhere.
    from .tools import (
        java_async_alloc_profile,
        java_class_histogram,
        java_gc_snapshot,
        java_heap_dump,
        java_jfr_start,
        java_jfr_summary,
        java_list_processes,
        java_mat_suspects,
    )
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