Skip to main content
Glama

run_sql

Read-onlyIdempotent

Raw SELECT SQL (ClickHouse) on tables: joins, ranking inside a group, shares, your own arithmetic. Available tables:

  • ads_olap: Amazon Ads analytics - daily performance data with campaigns, targets, search terms, and metrics.

  • product_catalog: Product catalog — current pricing, availability, BSR, ad eligibility per ASIN.

  • product_changes: Product change log — price movements, stock flips, BSR shifts, eligibility updates. Every time-series scan needs a literal lower date bound on its time column (ads_olap time_window_date, product_changes changed_at); a closed literal range meets it. product_catalog is a current snapshot and is exempt. ads_olap time_window_month is 1-12 and time_window_week is a week number; neither includes the year. Buckets: toStartOfMonth(time_window_date), toYYYYMM(time_window_date), or toStartOfWeek(time_window_date, 1) (Monday). ads_olap time_granularity is 'daily', 'weekly' or 'monthly'; omitted means daily. Account ids are injected by the server from target and are not WHERE predicates. Money metrics are sums. Ratio form is nullIf(x,0) or if(x=0,null,x). Money is the account's native currency (get_session_context(section="accounts") currency_code). Column schema and enums are returned by describe(kind='tables').

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

Input Schema

NameRequiredDescriptionDefault
sqlYesSELECT query against enabled tables (e.g., ads_olap). Every time-series table scan must include its physical date column with a literal lower bound or closed range.
roundNoDecimals, default 2.
formatNoDefault compact {columns,rows}; tsv smallest.
targetNoFrom get_session_context targets: kind:account[:unit]; a list for tables of several kinds.
columnsNo
max_rowsNoMaximum rows. Absent: the credential tier's default (100 MCP, 500 API key, 1,000 first-party). Caps are 500, 5,000, and 50,000. Larger values are clamped silently, not rejected. Responses are also bounded by a byte budget.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A3.9/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, closed-world), and the description adds genuinely non-obvious behavior: account ids are injected server-side from 'target' and must not appear in WHERE, omitted time_granularity defaults to daily, money metrics are accounted as sums, and money is in the account's native currency resolvable via get_session_context. These are operational facts an agent could not derive from the annotations or schema and that would cause wrong queries if unknown.

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

Conciseness3/5

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

The lead sentence is well front-loaded and the table list is scannable, but the remainder is a semicolon-chained run-on mixing date-bound rules, bucket functions, granularity defaults, currency, and ratio idioms without headings. Nearly every clause carries information, yet the flat structure makes it harder to parse than its content warrants.

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

Completeness4/5

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

There is no output schema, so the description needs to carry query-construction knowledge for a complex, high-degree-of-freedom tool — and it does: table inventory, time-series bound requirement, bucketing helpers, granularity default, and currency semantics. Gaps remain around result shape/truncation behavior and how this relates to the sibling query/report tools, so it is strong but not exhaustive.

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 83%, so the baseline is 3; the description earns above that by explaining that 'target' determines account scoping automatically and that account ids are not predicates, and by tying currency to the account rather than the query. It adds nothing for round, columns, or format, which are left to the schema.

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

Purpose4/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 — 'Raw SELECT SQL (ClickHouse) on tables' — and enumerates the three queryable tables with a one-line purpose for each. It never references the sibling 'query' or 'get_report', so an agent must infer which of these it should reach for, which keeps it out of 5 territory.

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

Usage Guidelines3/5

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

The stated guidance is about how to write SQL correctly (literal lower date bound on time-series scans, exempting product_catalog, bucket expressions, ratio form) rather than when to choose this tool over the alternatives. There is no exclusion or trigger condition such as 'use this for custom aggregation; use get_report for prebuilt reports', so usage is implied by capability rather than directed.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources