Skip to main content
Glama

profiler-cpu-query

Read-only

Queries stored CPU profiles by top functions, time window, call tree, or component to diagnose JavaScript hotspots and correlate CPU cost with specific commits.

Instructions

Query Hermes CPU profile data with targeted modes for iterative investigation. Modes:

  • top_functions: Global CPU hotspots ranked by self-time. Optional time_window_ms to filter.

  • time_window: CPU breakdown for time_window_ms (e.g. during a slow commit or hang).

  • call_tree: For a given function_name, show its callees, and its callers with include_callers.

  • component_cpu: For a given component_name, aggregate CPU activity across its stored commits. In top_functions and time_window, self-times are the summed sampling intervals of the samples that landed in the window, so they measure sampled coverage rather than the window's width and do not change if you widen the query. Their tables state how many samples they cover and how much was idle. Each row is one call path, so a function can have several rows and top_n counts rows. Use when investigating JS CPU hotspots or correlating CPU cost with specific components. Returns a markdown table of CPU hotspots, call tree, or per-component CPU breakdown. Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-profiler-analyze) first.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "device_id": "<device_id>",
      "mode": "<mode>"
    },
    "name": "profiler-cpu-query"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeYesQuery mode; see Modes in the tool description.
portNoMetro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. Range: 1 to 65535.
top_nNoNumber of results to return. Default: 15. Must be greater than 0.
device_idYesDevice ID used to record or load the React profile.
react_onlyNotop_functions and time_window: list only React component functions (PascalCase names). Default: false.
function_nameNoFunction name
component_nameNoComponent name
time_window_msNoTime window in ms since profiling started, the same clock profiler-commit-query prints
include_callersNoAlso show callers of the function. Default: false.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed12 schema fields changed
    • changedInput schema / properties / component_name / description
      Previous value: -"Component name for component_cpu mode"New value: +"Component name"
    • changedInput schema / properties / device_id / description
      Previous value: -"Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."New value: +"Device ID used to record or load the React profile."
    • changedInput schema / properties / function_name / description
      Previous value: -"Function name for call_tree mode"New value: +"Function name"
    • changedInput schema / properties / include_callers / description
      Previous value: -"For call_tree mode: also show callers of the function"New value: +"Also show callers of the function. Default: false."
    • changedInput schema / properties / mode / description
      Previous value: -"Query mode: top_functions (global hotspots), time_window (CPU in a time range), call_tree (callers/callees of a function), component_cpu (CPU during a component's commits)"New value: +"Query mode; see Modes in the tool description."
    • changedInput schema / properties / port / description
      Previous value: -"Metro server port. Optional — omit it to use this device's port, 8081 by default. Ignored for Chromium, whose CDP port is encoded in device_id."New value: +"Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. Range: 1 to 65535."
    • addedInput schema / properties / react_only
      Added value: +{
      +  "default": false,
      +  "description": "top_functions and time_window: list only React component functions (PascalCase names). Default: false.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / time_window_ms / description
      Previous value: -"Time window filter for time_window mode (ms since profiling started — the same clock profiler-commit-query prints)"New value: +"Time window in ms since profiling started, the same clock profiler-commit-query prints"
    • changedInput schema / properties / time_window_ms / properties / end / description
      Previous value: -"End of window in ms since profiling started — the same clock profiler-commit-query prints"New value: +"End of window in ms"
    • changedInput schema / properties / time_window_ms / properties / start / description
      Previous value: -"Start of window in ms since profiling started — the same clock profiler-commit-query prints"New value: +"Start of window in ms"
    • changedInput schema / properties / top_n / description
      Previous value: -"Number of results to return (default 15)"New value: +"Number of results to return. Default: 15. Must be greater than 0."
    • removedInput schema / properties / top_n / maximum
      Removed value: -9007199254740991
  2. Changed5 schema fields changedv0.25.0
    • removedInput schema / properties / port / default
      Removed value: -8081
    • changedInput schema / properties / port / description
      Previous value: -"Metro server port"New value: +"Metro server port. Optional — omit it to use this device's port, 8081 by default. Ignored for Chromium, whose CDP port is encoded in device_id."
    • addedInput schema / properties / port / maximum
      Added value: +65535
    • addedInput schema / properties / port / minimum
      Added value: +1
    • changedInput schema / properties / port / type
      Previous value: -"number"New value: +"integer"
  3. Changed4 schema fields changedv0.22.0
    • addedInput schema / properties / device_id / minLength
      Added value: +1
    • changedInput schema / properties / time_window_ms / description
      Previous value: -"Time window filter for time_window mode (ms, performance.now clock)"New value: +"Time window filter for time_window mode (ms since profiling started — the same clock profiler-commit-query prints)"
    • changedInput schema / properties / time_window_ms / properties / end / description
      Previous value: -"End of window in ms (performance.now clock)"New value: +"End of window in ms since profiling started — the same clock profiler-commit-query prints"
    • changedInput schema / properties / time_window_ms / properties / start / description
      Previous value: -"Start of window in ms (performance.now clock)"New value: +"Start of window in ms since profiling started — the same clock profiler-commit-query prints"
  4. First observedv0.15.0

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the readOnlyHint annotation it discloses genuinely non-obvious behavior: self-times are summed sampling intervals that measure sampled coverage and do not scale with window width, tables report sample coverage and idle time, each row is one call path so top_n counts rows rather than functions. It also states the failure condition (no stored profile) and the return format (markdown table).

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

Conciseness4/5

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

Front-loaded purpose sentence followed by a scannable per-mode bullet list, then a dense paragraph of caveats. The caveat paragraph is information-rich but runs together several distinct ideas (window semantics, sample coverage, row granularity, top_n counting), which slightly hurts scannability.

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

Completeness5/5

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

For a 9-parameter tool with a nested time-window object and no output schema, the definition covers mode selection, parameter-to-mode binding, return shape, numeric semantics, and the prerequisite/failure path. Nothing an agent needs in order to call it correctly is missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds cross-parameter semantics the schema does not: which parameters bind to which mode (function_name for call_tree, component_name for component_cpu, include_callers with function_name, time_window_ms only in top_functions/time_window). It also clarifies that top_n counts call-path rows, not distinct functions.

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

Purpose5/5

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

States a specific verb and resource (query Hermes CPU profile data) and enumerates all four modes with what each returns, so an agent can map an investigative intent directly onto a mode. It is clearly distinguishable from profiler-stack-query and profiler-commit-query by being the CPU/sample-based aggregation tool.

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

Usage Guidelines4/5

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

Provides an explicit when-to-use clause ('investigating JS CPU hotspots or correlating CPU cost with specific components'), per-mode selection hints ('e.g. during a slow commit or hang'), and a hard precondition with remediation ('Fails if no CPU profile is stored; run react-profiler-stop ... first'). It never names when to prefer profiler-stack-query or profiler-commit-query instead, so it stops short of full alternative routing.

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