Skip to main content
Glama
semlayer MCP server

semlayer MCP server

run_sql

Read-onlyIdempotent

Executes one read-only SELECT against the session warehouse, validates the SQL first, and returns capped rows with warnings, truncation status, and assumptions.

Instructions

Run ONE read-only SELECT against the session's warehouse.

    `check_sql` runs first and an error means the SQL is NOT executed --
    a query that sums cancelled orders runs perfectly well, so "it ran"
    was never the standard. Warnings do not block, and come back with the
    rows because they are about whether the number means what the user
    thinks.

    Rows are capped and there is a ten-minute time limit; the cap, the
    limit and whether rows were truncated are all stated in the result,
    so you can tell the user what actually applied. Nothing is written,
    nothing is persisted, and your SQL is never rewritten: a required
    filter is reported, never silently applied.

    Refused while an inference is running -- one connection is not shared
    between the two. Ask again when `status` says `ready`.

    The result carries `assumptions` -- the unconfirmed claims the answer
    rests on. Answer the user in words first, then render those under it.
    

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 statement, in the dialect of the session's warehouse. It is run exactly as written.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.1
    • addedInput schema / properties / sql / description
      Added value: +"One SELECT statement, in the dialect of the session's warehouse. It is run exactly as written."
  2. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations cover the safety profile (readOnly, idempotent, non-destructive), and the description adds substantial context beyond them: row caps, a ten-minute limit, truncation reporting, no persistence, no SQL rewriting, required filters reported rather than applied, and an inference-lock refusal. It also explains the consequence of check_sql failure with a concrete example of why 'it ran' is not the standard.

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?

The constraint is front-loaded in the first line and each paragraph covers a distinct concern (validation, limits, locking, result fields). However, the 'cancelled orders' illustration and some indirect phrasing cost tokens without adding callable information.

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?

For a one-parameter execution tool with an output schema, the description covers everything an agent needs: validation sequencing, hard limits, failure modes, and the post-call obligation to relay assumptions in prose. No behaviorally relevant gap remains.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the single sql parameter is already documented as 'One SELECT statement... run exactly as written.' The description reinforces the one-statement, exactly-as-written contract but adds little syntactic or formatting meaning the schema does not already carry.

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?

States a specific verb and resource with scope: 'Run ONE read-only SELECT against the session's warehouse.' The single-statement and read-only constraints distinguish it from generic execution tools, and the sibling check_sql is explicitly framed as a separate validation step.

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

Usage Guidelines5/5

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

Gives explicit when/when-not conditions: blocked when check_sql errors, warnings allowed through, and refused while an inference is running — with a concrete recovery path ('Ask again when status says ready'). It names the related siblings (check_sql, status) and the condition selecting each.

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