Skip to main content
Glama

java_jfr_start

Start a Java Flight Recorder recording on a specified process to collect profiling data for memory leak analysis. Configure profile, duration, and output file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYes
profileNoprofile
duration_sNo
out_fileNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of java_jfr_start. It requires the 'jcmd' binary, builds a JFR.start command targeting the given PID with profile, duration, and output file, runs it, and returns an ok_result with the artifact path on success or a warn/error result on failure.
    def java_jfr_start(
        pid: int,
        profile: str = "profile",
        duration_s: int = 30,
        out_file: str | None = None,
    ) -> dict[str, Any]:
        try:
            require_binary("jcmd", "Install OpenJDK 17+ so jcmd is available.")
            path = Path(out_file) if out_file else _artifact_dir() / f"jfr-{pid}-{_timestamp()}.jfr"
            path.parent.mkdir(parents=True, exist_ok=True)
    
            output = ensure_success(
                run_command(
                    [
                        "jcmd",
                        str(pid),
                        "JFR.start",
                        "name=HeapSeance",
                        f"settings={profile}",
                        f"duration={max(5, duration_s)}s",
                        f"filename={str(path)}",
                    ],
                    timeout_s=max(60, duration_s + 15),
                )
            ).stdout
        except Exception as exc:  # noqa: BLE001
            return _command_failed(exc)
    
        if not path.exists():
            return warn_result(
                evidence=[
                    f"JFR command executed but expected output file was not found at {path}.",
                    output.strip()[:800],
                ],
                metrics={"pid": pid, "requested_file": str(path)},
                confidence="low",
                next_recommended_action="Check JFR permissions and rerun java_jfr_start with an explicit writable out_file.",
            )
    
        return ok_result(
            evidence=[f"Recorded JFR capture for PID {pid} at {path}.", output.strip()[:800]],
            metrics={"pid": pid, "duration_s": duration_s, "profile": profile},
            confidence="medium",
            next_recommended_action="Run java_jfr_summary on the generated recording.",
            raw_artifact_path=str(path),
        )
  • MCP tool registration via @mcp.tool() decorator on a thin wrapper that delegates to tools.java_jfr_start.
    @mcp.tool()
    def java_jfr_start(
        pid: int,
        profile: str = "profile",
        duration_s: int = 30,
        out_file: str | None = None,
    ) -> dict[str, Any]:
        return tools.java_jfr_start(
            pid=pid,
            profile=profile,
            duration_s=duration_s,
            out_file=out_file,
        )
  • Input schema: pid (int, required), profile (str, default 'profile'), duration_s (int, default 30), out_file (str | None, optional). Output is a dict with status, evidence, metrics, confidence, next_recommended_action, raw_artifact_path.
    def java_jfr_start(
        pid: int,
        profile: str = "profile",
        duration_s: int = 30,
        out_file: str | None = None,
    ) -> dict[str, Any]:
  • Import of java_jfr_start in workflow.py for use in the deep analysis workflow.
        java_jfr_start,
        java_jfr_summary,
        java_list_processes,
        java_mat_suspects,
    )
  • Usage of java_jfr_start within the workflow's deep analysis mode with pid, profile='profile', duration_s=45.
    jfr_result = java_jfr_start(pid=resolved_pid, profile="profile", duration_s=45)
    if jfr_result["status"] == "ok":
        report["artifacts"]["jfr"] = jfr_result["raw_artifact_path"]
        jfr_summary = java_jfr_summary(jfr_result["raw_artifact_path"])
        if jfr_summary["status"] == "ok":
            jfr_signal = jfr_support_signal(jfr_summary["metrics"], monotonic)
            report["signals"]["jfr_support"] = jfr_signal
        else:
            report["evidence"].append(
                "JFR recording unreadable (possibly old JFR v0.9 format from Java 8). "
                "Continuing with histogram + GC + MAT evidence."
            )
    else:
        report["evidence"].append(
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