Skip to main content
Glama

table_sql

Read-only

Execute a read-only SQL query against the workspace data tables.

The query runs inside the workspace's PostgreSQL schema, so you can reference table names directly (e.g., SELECT * FROM invoices).

Supports JOINs, sub-selects, read-only CTEs (WITH ... SELECT), aggregations, and window functions. Only a single SELECT or EXPLAIN SELECT is allowed, and it may only reference this workspace's tables — other schemas, system catalogs and system/admin functions are rejected. Use table_sql_execute for writes.

Results are capped server-side at 1000 rows regardless of the query — use limit (default 50, max 1000) to request fewer, and add your own ORDER BY for a deterministic top-N.

Parameters use $1, $2, etc. placeholders.

Fields are "query", "params" (a JSON string) and "limit". Example: {"query":"SELECT * FROM invoices WHERE status = $1","params":"["open"]","limit":20}

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

Input Schema

NameRequiredDescriptionDefault
limitNoMax rows to return (default 50, max 1000). Ignored for EXPLAIN.
queryYesSQL SELECT query to execute
paramsNoJSON array of parameter values for $1, $2, etc. placeholders

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the readOnlyHint annotation: it discloses the server-side 1000-row cap, the limit default and maximum, the rejection of other schemas/system catalogs/system functions, and the need for explicit ORDER BY for deterministic top-N. These are exactly the operational constraints an agent needs before composing a query.

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-loaded with purpose, then capabilities, restrictions, row caps and an example — a logical order with little waste. The example is worth its space; only the duplicated restatement of the limit default/max slightly pads the text.

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 3-parameter read tool with no output schema, the description covers the boundaries (what SQL is permitted), the result shape (row cap and limit interaction), and parameter binding. Nothing an agent needs to invoke it correctly 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 baseline would be 3, but the description adds a concrete usage pattern the schema cannot: $1/$2 placeholder binding, that params is a JSON string, and a full worked example object. The limit semantics are restated, which is redundant, but the example carries real 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 ('Execute a read-only SQL query against the workspace data tables') and scopes it to the workspace's PostgreSQL schema. It also names the sibling it is not ('Use table_sql_execute for writes'), letting an agent separate read SQL from write SQL without opening a 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?

Explicitly routes write operations to table_sql_execute and enumerates what is allowed (single SELECT or EXPLAIN SELECT, JOINs, CTEs, window functions). It does not mention when an agent should prefer the simpler siblings such as table_query or table_list over raw SQL, which is the one remaining routing gap.

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.