execute_sql
Execute SQL queries on the user's Amazon seller data to retrieve THEIR specific business metrics.
WORKFLOW BEFORE EXECUTING SQL:
ALWAYS use search_context_files FIRST to check for ready-to-use query patterns The context files contain a cookbook with 31+ tested queries for common seller questions
If no pattern exists, use get_table_info or DESCRIBE to verify schema
Then write and execute SQL
VENUE_ID FILTERING:
Most tables should be filtered by venue_id
If the user specifies a venue, use that
Otherwise, call get_org_info ONCE per session to get the defaultVenueId
Don't call get_org_info repeatedly if you already have the venue_id
SCHEMA VERIFICATION:
Before querying a table for the FIRST TIME, use get_table_info or DESCRIBE to verify column names
NEVER guess column names - always verify them first
Once you've seen a table's schema in this conversation, you don't need to check again
Use this tool when users ask about their personal data:
"What's MY [metric]?" (e.g., "What's my ACoS?")
"Show me my [data]" (e.g., "Show me my inventory")
"How much did I [action]?" (e.g., "How much did I spend on ads?")
Any question requiring their actual numbers from the database
Key tables available:
fba_inventory: Current FBA stock levels, condition, fulfillable quantity
sl_daily_sku_profit: Daily profit by SKU (revenue, costs, margins, units sold)
campaign_performance: Campaign metrics (spend, sales, impressions, clicks)
product_ad_performance: Product-level ad metrics
order_items: Order line items with pricing and quantities
search_query_performance: Search Query Performance (SQP) keyword data, weekly
Use SHOW TABLES to discover all tables. Remember: search_context_files has 31+ ready-to-use query patterns - use them before writing SQL from scratch!
NOTE: For live campaign state (current bids, current status), use the ads tools (list_sp_campaigns, list_sp_keywords) instead — the Data Hub is synced periodically and may not reflect changes made in the last few hours.
IMPORTANT: Always backtick reserved keywords: condition, key, rank, order, status
SEARCH QUERY PERFORMANCE (SQP): the search_query_performance (weekly) and
search_query_performance_by_month views, filtered on venue_id like the others.
SQP is enabled per brand on request, so an EMPTY RESULT usually means
SQP was never enabled for the account — NOT that the seller has no search data.
Never report "you have no search query data" from an empty result alone: search
context files for "search query performance" to diagnose it and to get the wording
for directing the seller to support.
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": "execute_sql"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL query to execute (SELECT, SET, SHOW, DESCRIBE, DESC, and EXPLAIN statements only) |