Skip to main content
Glama
sql-lens-mcp

sql-lens-mcp

by varkart

execute_query

Run SQL against a configured connection and get paginated tabular, JSON, or raw results. Page through large result sets with offset and maxRows, and reuse the last result via CSV or JSON resources.

Instructions

Execute a SQL query. Results are paginated: at most maxRows rows are returned per call. When the response reports hasMore, call again with offset=nextOffset to fetch the next page. Each page re-executes the query (offset pagination), so paging an expensive query repeats its cost. The most recent result per connection is also exposed as query-result://{connectionId}/csv and query-result://{connectionId}/json resources.

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": {
      "connectionId": "<connectionId>",
      "sql": "<sql>"
    },
    "name": "execute_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL query
formatNoOutput format
offsetNoRows to skip before returning results (default 0); use nextOffset from a truncated response to fetch the next page
maxRowsNoMax rows to return per page
timeoutNoQuery timeout in ms
connectionIdYesConnection ID

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.0

TDQS

B3.2/5.0
Behavior3/5

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

With no annotations, the description carries the behavioral burden. It usefully discloses pagination, hasMore/nextOffset behavior, repeated execution cost when paging, and query-result resources, but it omits whether SQL can mutate data, permission requirements, timeout behavior, and error handling.

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 description is front-loaded with purpose and then covers pagination and result resources efficiently. Every sentence is relevant, though the pagination explanation is slightly dense.

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

Completeness3/5

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

For a six-parameter SQL execution tool with no annotations and no output schema, the description covers the critical paging behavior well but leaves important gaps around write/destructive potential, permissions, and timeout semantics.

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 the schema already explains all six parameters. The description reinforces maxRows and offset/nextOffset usage and adds the important cost caveat about re-executing queries, but it does not add meaning for format, timeout, or connectionId beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: 'Execute a SQL query.' That is clear and actionable, but it does not distinguish this tool from siblings such as explain_query or nl_query.

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

Usage Guidelines2/5

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

It gives detailed pagination mechanics, but it does not say when to use execute_query versus alternatives like nl_query, explain_query, or sample_rows, nor does it provide any exclusions or prerequisites.

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