Skip to main content
Glama

Query contract events with SQL

sql
Read-only

Query decoded EVM contract event history with read-only statements to retrieve indexed logs and provenance across live and sealed data.

Instructions

Query this EVM contract's decoded event history (indexed by nuthatch) with read-only SQL, over the live tip and sealed history. Each event is a view named {alias}__{event} (e.g. "usdc__transfer") with block_number, log_index, tx_hash, address + the event's params. Call schema first. SELECT/WITH only. Returns a compact table (data rows are the lines beginning |; chain data cannot start a line) + a provenance stamp; capped at limit rows (default 200), and the node caps limit itself (50,000 unless its operator changed it).

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": {
      "query": "<query>"
    },
    "name": "sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNoMax rows to return (default 200; the node may cap it lower than you ask).
queryYesA SELECT or WITH query.
at_timeNoAnswer as of this time, unix seconds UTC, placed as `at` places it.
at_blockNoAnswer over the facts as they stood at this block. Authored entities are not available then.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv5.23.0
    • addedInput schema / properties / at_block
      Added value: +{
      +  "description": "Answer over the facts as they stood at this block. Authored entities are not available then.",
      +  "type": "integer"
      +}
    • addedInput schema / properties / at_time
      Added value: +{
      +  "description": "Answer as of this time, unix seconds UTC, placed as `at` places it.",
      +  "type": "integer"
      +}
  2. First observedv5.21.0

TDQS

A4.4/5.0
Behavior5/5

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

Beyond readOnlyHint/openWorldHint, it discloses the row cap mechanics (default 200, node-side cap of 50,000 unless operator-changed), the coverage scope (live tip plus sealed history), and the return shape (compact table where data lines start with `|`, plus a provenance stamp). These are operational traits an agent could not infer from annotations alone.

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 with the core action and view-naming convention before constraints and return format. It is dense and slightly run-on in the closing sentence about the table format, but nearly every clause carries usable information.

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?

With no output schema, the description takes on the burden of explaining the return format, and it does so (pipe-prefixed data lines, provenance stamp, row caps). Combined with the prerequisite pointer to `schema` and the read-only constraint, an agent has enough to call this correctly.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all four parameters and the baseline is 3. The description restates the `limit` default and node cap but adds no meaning for `at_time` or `at_block`, whose schema text ("placed as `at` places it") remains the only guidance.

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 the contract's decoded event history with read-only SQL, including the view naming convention `{alias}__{event}`. An agent can distinguish this from siblings like `schema`, `tables`, and `table` without opening any schema.

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?

Gives a concrete prerequisite ("Call `schema` first") and a hard constraint (SELECT/WITH only), which sets clear context for invocation. It stops short of explicitly naming when to prefer `table` or `at` over ad-hoc SQL, so the alternative-selection guidance is implied rather than stated.

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