run_sql
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)orif(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
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SELECT 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. | |
| round | No | Decimals, default 2. | |
| format | No | Default compact {columns,rows}; tsv smallest. | |
| target | No | From get_session_context targets: kind:account[:unit]; a list for tables of several kinds. | |
| columns | No | ||
| max_rows | No | Maximum 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. |