Skip to main content
Glama

execute_sql

Read-onlyIdempotent

Run custom PerfettoSQL queries on a loaded trace to perform aggregations, joins, or access base tables. Returns columnar JSON results, capped at 5000 rows.

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
columns_onlyNoReturn only column names and row-count metadata; omit row values.
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.
include_row_countNoInclude decoded row-count metadata with a row-returning shaped response.
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.
max_string_lenNoOptional per-string-cell character cap applied to returned rows only. Accepts both numbers and numeric strings. Must be > 0 when set.
sqlYesSQL query to execute (PerfettoSQL syntax).
summaryNoReturn column names, row-count metadata, and a small sample of rows. Defaults to 10 sample rows unless `head` or `limit` is provided.
Behavior5/5

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

Beyond the annotations (readOnlyHint, etc.), the description reveals critical behavioral details: results are capped at 5000 rows, blob cells render as hex, strings may be redacted, requires prior load_trace, and distinguishes empty rows from SQL errors. 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 front-loaded with the core purpose and usage guidance, followed by parameter details and edge cases. While thorough, it is slightly longer than necessary; however, every sentence serves a purpose and no redundant information is present.

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 the absence of an output schema, the description fully covers return format (columnar JSON, row cap, blob hex, redaction, empty vs error), prerequisites (load_trace), and references for further detail. It leaves no critical gap for tool invocation.

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

Parameters5/5

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

Schema coverage is 100%, yet the description adds substantial value: it explains that output shaping parameters only affect the returned data, not the SQL; clarifies blob rendering; details the error distinction; and provides reference documentation links for column names and syntax.

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 opens with a specific verb and resource: 'Run a PerfettoSQL query against the loaded trace and return rows as columnar JSON.' It explicitly distinguishes itself from sibling tools by stating it's for composing analyses not covered by dedicated chrome_* tools, making the purpose unambiguous.

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?

The description provides explicit when-to-use and when-not-to-use guidance, including concrete examples like 'Don't use for: questions the dedicated chrome_* tools answer' and 'Don't hand-roll slice scans with LIKE.' It also suggests using stdlib modules for better performance.

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