Skip to main content
Glama

Run a Read-Only SQL Query

link_query
Read-onlyIdempotent

Runs one read-only SQL query across datasets, for analysis the per-dataset filters cannot express, such as joining education, Census, immigration, or health figures to a lookup table or to each other on shared geography (immigration, county-level Census, and health data share county_fips; Census and health tract data share tract_geoid). The dialect is DuckDB SQL (https://duckdb.org/docs/sql/introduction). Allowed: one SELECT (or WITH ... SELECT) that names only the tables link_tables lists, by their table names (FROM education.attendance a JOIN dimensions.districts d ON a.district_code = d.district_code; without an alias a table is referenced by its bare name, 'attendance'); no DDL, DML, COPY, ATTACH, INSTALL, PRAGMA, SET, or CALL, and no read_parquet(), other file readers, or file paths. Joins use the keys from describe_dimension's link_keys (districts.district_census_id reaches Census data through the crosswalk; it is a school-district code, not a county FIPS code, and a district is not the same as a county). Results are capped by rows, bytes, and time; truncated says a cap was hit, and grouping or a tighter WHERE fits more. NULL means suppressed, not zero. A rejected query returns an error naming the token or table at fault, with the closest table names.

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

Input Schema

NameRequiredDescriptionDefault
sqlYesOne DuckDB SELECT statement over link_tables' table names, e.g. 'SELECT ... FROM education.attendance'.
limitNoMost rows to return (default 100, at most 500).

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changed
    • addedInput schema / properties / limit / description
      Added value: +"Most rows to return (default 100, at most 500)."
    • addedInput schema / properties / limit / maximum
      Added value: +500
    • addedInput schema / properties / limit / minimum
      Added value: +1
    • addedInput schema / properties / sql / description
      Added value: +"One DuckDB SELECT statement over link_tables' table names, e.g. 'SELECT ... FROM education.attendance'."
  2. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), yet the description adds substantial context beyond them: exact allowed statement forms, a forbidden-operation list, result caps on rows/bytes/time, the `truncated` flag, NULL-as-suppressed semantics, and error behavior naming the offending token. This is the kind of behavioral detail annotations cannot carry.

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?

Purpose is front-loaded and every sentence carries constraint information an agent needs to avoid a rejected query. It is dense and long, but the length is justified by the safety surface of a SQL tool; the district-vs-county parenthetical is the only marginally expendable bit.

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 high-complexity arbitrary-SQL tool with an output schema, the description covers dialect, allowed/forbidden syntax, table and join-key sourcing, result caps, truncation signaling, NULL semantics, and error shape. 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 100%, so both params are documented structurally, but the description adds real meaning: the DuckDB dialect, how tables must be referenced (schema.table, alias vs bare name), and the constraint that only link_tables' tables are allowed. The `limit` interaction with caps is implied but not spelled out per-value.

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 ('Runs one read-only SQL query across datasets') and immediately scopes it against the sibling query path ('for analysis the per-dataset filters cannot express'). An agent can distinguish it from query_dataset, aggregate, and get_dimension without opening any 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?

Clear when-to-use context: cross-dataset joins on shared geography that per-dataset filters cannot express. It routes the agent to link_tables for allowed tables and describe_dimension for link_keys, but never explicitly names the simpler sibling (query_dataset/aggregate) as the alternative for non-join cases.

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