Skip to main content
Glama
peaka-mcp-server

peaka-mcp-server

Official
by peakacom

peaka_execute_sql_query

Read-only

Run Trino SQL queries against a Peaka project to retrieve results as columns and rows, with errors showing the failing line and column for fixes.

Instructions

Runs the given SQL on Peaka. The SQL is Trino: catalog.schema.table names as listed; DATE '2025-01-31' and INTERVAL '30' DAY literals; integer division truncates (CAST to DOUBLE for ratios); NOT EXISTS instead of NOT IN when NULLs are possible; aggregate in SQL. A failing query returns Trino's message with its line and column: fix that part and run again. Full rules: the peaka_sql_query_rule_set resource.

BEFORE RUNNING THIS TOOL:
  1: Find the tables with peaka_list_project_tables (one line a table, with its cache state), then read the chosen tables' columns with peaka_get_project_metadata and tables=[...] in one call. If the project is too large to list, list one schema or use peaka_search_relevant_tables.
  2: Check how the tables are read in that list: each schema's header says SaaS source or database, and a SaaS table marked [cached] is read from the cache; peaka_list_tables gives it per schema too
  3: A SaaS table not marked [cached] is read live, and a live read may return only its first page of records: say the result may be incomplete, and, if caching tools are available, offer to cache the table. Do not start a cache without the user's yes.
  The answer is { columns, rows, returnedRows, totalRows }; a large result is cut (truncated: true, with a note): aggregate or narrow in SQL instead of reading rows.
  4: A database table (e.g. Oracle) is always read live and in full: caching does not make its answer more complete. If a query on it fails or is slow, fix or narrow the SQL, or report the error; do not try to cache it.

If you do not already know the projectId for the current task, call peaka_list_projects first and ask the user which project to use. Remember the chosen projectId for subsequent calls in this conversation.

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

Input Schema

NameRequiredDescriptionDefault
queryYes
projectIdYesThe Peaka project ID to run against.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.11.0

TDQS

A4.2/5.0
Behavior5/5

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

Annotations only cover safety (readOnly, openWorld, non-destructive); the description adds what the annotations cannot: the return shape {columns, rows, returnedRows, totalRows}, truncation behavior with a truncation flag, the exact form of a failure (Trino's message with line and column), and the live-vs-cached read semantics per table kind. This is substantial context beyond the structured fields.

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 purpose is front-loaded and most sentences carry real information, but the return-shape paragraph is wedged between numbered steps 3 and 4, breaking the list's logic. Some detail is also cross-referenced twice (cache state via both the table list and peaka_list_tables), adding length without new guidance.

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 and only two parameters, the definition supplies everything an agent needs: the discovery prerequisite chain, project resolution when projectId is unknown, cache versus live read consequences, result truncation, and the failure/recovery loop. Nothing material for correct invocation is missing.

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 50% and the undescribed parameter is `query`, so the description must carry it — and it does, via concrete dialect rules (catalog.schema.table naming, DATE and INTERVAL literals, integer division truncation with CAST to DOUBLE, NOT EXISTS vs NOT IN). It still omits basics such as multi-statement handling or whether DDL is permitted.

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 opening sentence states a specific verb and resource ("Runs the given SQL on Peaka") and immediately pins the dialect to Trino. It does not, however, distinguish this tool from the very similar sibling peaka_execute_query, so an agent must infer which executor to pick.

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?

The BEFORE RUNNING block gives explicit sequencing (list tables, then read metadata in one call), names the fallback alternative when a project is too large (peaka_search_relevant_tables), and states a clear when-not plus consent requirement for caching ("Do not start a cache without the user's yes"). What it never addresses is when to choose this tool over peaka_execute_query or peaka_create_query.

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