Skip to main content
Glama

Run SQL

run_sql
Read-only

Run one PostgreSQL SELECT over this company's copy and answer its rows, to explore the data and to write a report's sql block. Each source is a schema named by list_connections' sql_schema (simpro, xero, verizon_connect, the_fleet_office, deputy, moveware, dialpad, elmo, employment_hero, emailed_reports), holding one view per resource named and shaped as describe_resources lists it, plus data, the whole document as the source sent it (jsonb: data->>'Name', data#>>'{Customer,ID}'). Name the sources read with connection_ids; the first one's schema is also the default, so jobs reads simpro.jobs. Joins, CTEs, window functions and every read-only function work. period_start() and period_end() answer a report block's period. Tax file numbers, bank details and birth dates are removed from every document. Nothing can be written, and a query runs at most 15s. Dates a source sent as text compare as text: date_issued >= '2026-07-01'. At most 200 rows answer at once, and truncated true means more remain: read on with ORDER BY and OFFSET in the SQL, and count or total with COUNT(*), SUM and GROUP BY rather than reading every row.

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
sqlYesOne SELECT (or WITH ... SELECT), no semicolons between statements.
limitNoRows to answer. Default and most 200.
connection_idsNoThe sources it reads. Omit when the company has one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations: read-only enforcement ('Nothing can be written'), a 15s execution ceiling, a 200-row answer cap with a truncated flag, PII stripping (tax file numbers, bank details, birth dates), and the text-vs-date comparison trap. Those are exactly the constraints an agent must know before composing a query and are not expressed anywhere in the annotation set.

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-loads the purpose in the first clause and sequences schema model, parameters, constraints, then pagination advice. It is dense and slightly overloaded with parenthetical examples and a ten-item schema list, and the 200-row cap is stated twice (in prose and via limit), but essentially no sentence is filler.

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 carries the return-value burden itself and does so: it explains that rows are returned, that at most 200 answer at once, and what truncated=true means. Combined with the read-only and timeout disclosures, an agent has everything needed to call it correctly.

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 already 100%, but the description adds real semantics: connection_ids selects the readable schemas and the first one sets the default schema (`jobs` resolves to simpro.jobs), and limit interacts with the 200-row cap and truncated flag. It does not add format guidance for the sql string beyond the schema's own 'one SELECT, no semicolons' note.

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?

Names a specific verb and resource ('Run one PostgreSQL SELECT over this company's copy') and states two concrete purposes: exploring data and authoring a report's sql block. It also anchors itself against sibling tools by pointing at list_connections' sql_schema and describe_resources for the schema/model it operates on, so an agent can place it without opening the 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 clear when-to-use context (data exploration, report sql block) and prescribes tactics: use COUNT(*)/SUM/GROUP BY rather than reading every row, and paginate with ORDER BY + OFFSET when truncated. It does not explicitly say when to prefer a simpler sibling such as search_records or get_record instead, which keeps it from a 5.

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