Skip to main content
Glama

execute_sql

Read-onlyIdempotent

Execute custom PerfettoSQL queries against a loaded trace to perform aggregations, joins, or analyses not covered by dedicated tools.

Instructions

Run a PerfettoSQL query against the loaded trace and return rows as columnar JSON. Read-only against trace data; SQLite operates in-memory per session. Aggregates are strongly preferred over raw row data; results are capped at 5000 rows.

Use when: composing analyses not covered by the dedicated tools — custom aggregations, joins across stdlib modules, or queries against base tables (slice, thread, process, sched).

Don't use for: questions the dedicated chrome_* tools answer — they return the same data with the JOIN shape already correct. Don't hand-roll slice scans with LIKE '%x%' patterns when a stdlib module covers the data; INCLUDE PERFETTO MODULE chrome.tasks is faster and the joins are pre-baked.

Parameters: sql is a single PerfettoSQL statement (the INCLUDE PERFETTO MODULE foo; and SELECT ... can be in the same call). Optional output shaping (head/limit, columns_only, summary, include_row_count, max_string_len) only changes what this tool returns; it does not rewrite the SQL. Blob cells render as blob:hex:<hex>. String results may be redacted by the server privacy policy before they are returned, preserving diagnostic structure while masking sensitive URL/header/cookie/path values. Requires load_trace to have run first.

Empty rows means the query matched nothing — distinct from a SQL error, which is returned as an error string with a hint pointing at the most likely cause (missing module, missing column, missing table).

Reference docs (fetch when you need exact column names or function signatures): https://perfetto.dev/docs/analysis/stdlib-docs (24 stdlib packages — chrome / android / sched / slices / linux / wattson / v8 / ...; use per-package anchors like #package-chrome), https://perfetto.dev/docs/analysis/perfetto-sql-syntax (syntax).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to execute (PerfettoSQL syntax).
headNoAgent-friendly alias for `limit`: return only the first N decoded rows. This trims returned rows only; it does not rewrite the SQL. Mutually exclusive with `limit`. Accepts both numbers and numeric strings.
limitNoOptional output row cap. This trims returned rows only; it does not rewrite or limit the SQL that trace_processor executes. Mutually exclusive with `head`. Accepts both numbers and numeric strings.
summaryNoReturn column names, row-count metadata, and a small sample of rows. Defaults to 10 sample rows unless `head` or `limit` is provided.
trace_idNoOptional trace id returned by `load_trace`. Omit to use the active trace.
columns_onlyNoReturn only column names and row-count metadata; omit row values.
max_string_lenNoOptional per-string-cell character cap applied to returned rows only. Accepts both numbers and numeric strings. Must be > 0 when set.
include_row_countNoInclude decoded row-count metadata with a row-returning shaped response.
Behavior5/5

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

Annotations already declare the tool as read-only, idempotent, and non-destructive. The description adds important behavioral details: aggregates preferred over raw rows, 5000 row cap, blob rendering as hex, string redaction by server privacy policy, and error handling with hints. No contradiction with annotations.

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?

The description is comprehensive but well-structured: core action first, then usage guidelines, then parameter details, error handling, and references. It is front-loaded with the essential purpose. While long, each sentence adds necessary information for an agent to use the tool correctly.

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?

Given 8 parameters, no output schema, and the tool's complexity (query language, error modes, privacy redaction), the description covers all key behaviors, constraints, and edge cases. It also provides links to external documentation for details on SQL syntax and stdlib modules.

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 parameters are already documented. The description adds value by explaining that `head`/`limit` only trim output, not rewrite SQL; that `sql` can include `INCLUDE PERFETTO MODULE`; and that `summary` defaults to 10 samples. This exceeds the baseline expectation.

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?

The description clearly states the tool runs a PerfettoSQL query against a loaded trace and returns rows as columnar JSON. It distinguishes itself from sibling tools by explicitly noting that dedicated `chrome_*` tools exist for specific analyses and should be used instead.

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

Usage Guidelines5/5

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

Provides explicit guidance on when to use (composing custom analyses not covered by dedicated tools) and when not to use (for questions answered by `chrome_*` tools or when stdlib modules suffice). Names alternatives like `chrome_*` tools and stdlib modules.

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/tooluse-labs/perfetto-mcp-rs'

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