Skip to main content
Glama
semlayer MCP server

semlayer MCP server

check_sql

Read-onlyIdempotent

Lint SQL against the semantic layer before execution to catch unknown tables/columns, deprecated tables, missing filters, and unsafe joins that return wrong numbers instead of errors.

Instructions

Lint SQL against the semantic layer BEFORE it runs ANYWHERE.

    Including SQL you intend to execute with a tool that is not
    semlayer's. Deterministic checks: unknown tables/columns, correlated
    references, deprecated tables, missing required filters, fan-out
    aggregates, SCD2 joins without a validity window. These are the
    mistakes that return a NUMBER rather than an error, so an unchecked
    statement can be confidently wrong. Fix every error and warning
    (each finding carries a fix hint), then re-check. Cheap,
    deterministic, and it never touches the warehouse.
    

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": "check_sql"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesThe statement to check, exactly as it would be run.
dialectNoThe SQL dialect the statement is written in, by its sqlglot name: `duckdb`, `snowflake`, `bigquery`, `postgres`. An unknown name is reported as a finding.duckdb

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.1.1
    • addedInput schema / properties / dialect / description
      Added value: +"The SQL dialect the statement is written in, by its sqlglot name: `duckdb`, `snowflake`, `bigquery`, `postgres`. An unknown name is reported as a finding."
    • addedInput schema / properties / sql / description
      Added value: +"The statement to check, exactly as it would be run."
  2. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/5

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

Beyond the readOnly/idempotent annotations, it enumerates the actual check categories (unknown tables/columns, correlated references, deprecated tables, missing required filters, fan-out aggregates, SCD2 joins without validity window) and explains the failure mode that motivates the tool: silent wrong numbers rather than errors. It also discloses that findings carry fix hints and that the check never touches the warehouse.

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 imperative purpose is front-loaded, followed by scope, check list, rationale, and workflow in a sensible order. A few clauses are redundant with the annotations ('deterministic' appears twice, 'never touches the warehouse' restates readOnlyHint), costing a little tightness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the description rightly avoids describing response shape, and the annotations already carry the safety profile. What remains is largely covered by the check enumeration and the iterate-until-clean instruction; only minor operational details like latency or output size limits are absent.

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 description coverage is 100%, so both the sql text and the dialect (including accepted sqlglot names and the unknown-name behavior) are already documented in structured fields. The description adds no dialect-level or formatting guidance beyond that, leaving the schema to do all the parameter work.

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?

Opens with a specific verb and object: 'Lint SQL against the semantic layer', scoped by 'BEFORE it runs ANYWHERE'. It also distinguishes itself from execution siblings by noting it applies to 'SQL you intend to execute with a tool that is not semlayer's', so an agent can tell it apart from run_sql without opening either 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?

The when-to-use condition is explicit and emphasized (run this before executing anywhere, including via foreign tools), and the follow-up workflow is spelled out: fix every error and warning, then re-check. It stops short of naming run_sql as the execution counterpart or stating any case where checking is unnecessary, so it is strong but not a full when/when-not/alternatives matrix.

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