Skip to main content
Glama

Execute SQL

execute_sql

Execute SQL queries on loaded QGIS layers via a virtual layer. Reference layers by name in FROM or JOIN, and optionally register result as a new layer.

Instructions

SQL across loaded layers via a virtual layer; reference layers by name in FROM/JOIN. as_layer=True registers the result as a new layer (set geometry_field for spatial output); else returns rows inline (max 1000). layers limits sources by layer id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
layersNo
as_layerNo
uid_fieldNo
layer_nameNosql_result
geometry_fieldNo
Behavior2/5

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

With no annotations, the description carries the full burden. It mentions that as_layer creates a new layer and inline returns at most 1000 rows, but does not disclose whether the SQL is limited to SELECT, any destructive potential, or required permissions. The behavioral traits are only partially disclosed.

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 two sentences and gets to the point quickly. However, the second sentence is slightly cluttered with multiple conditionals, reducing readability. Overall, it is appropriately sized for a tool with moderate complexity.

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

Completeness2/5

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

Given 6 parameters and no output schema, the description is incomplete. It does not cover uid_field, return format structure, error handling, or that the tool likely only supports SELECT queries. There are gaps that could lead to agent confusion.

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

Parameters2/5

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

Despite 0% schema coverage, the description only explains as_layer, geometry_field, layers, and layer_name implicitly. It omits explanation for query, uid_field, and layer_name's default value, and does not clarify the query parameter's format or constraints beyond a generic 'SQL'.

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?

The description clearly states the tool executes SQL across loaded layers using a virtual layer, and that layers can be referenced by name in FROM/JOIN. This verb+resource description effectively differentiates it from sibling tools like evaluate_expression or execute_code.

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

Usage Guidelines3/5

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

The description provides guidance on when to use as_layer vs inline mode and mentions the layers parameter to limit sources. However, it does not discuss alternatives or when not to use this tool, leaving comparative usage implicit.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lefcgis/qgis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server