Skip to main content
Glama
nkarasiak

QGIS MCP

by nkarasiak

Execute SQL

execute_sql

Run SQL queries across loaded QGIS layers, referencing layers by name in FROM/JOIN. Return rows inline or register results as a new layer for spatial output.

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, capped by limit (default 1000, negative for all) with a truncated flag. layers limits sources by layer id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
queryYes
layersNo
as_layerNo
uid_fieldNo
layer_nameNosql_result
geometry_fieldNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.14.1
    • addedInput schema / properties / limit
      Added value: +{
      +  "default": 1000,
      +  "type": "integer"
      +}
  2. Addedv0.5.0

TDQS

A3.8/5.0
Behavior3/5

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

No annotations are provided, so the description carries the transparency burden. It discloses side-effectful behavior when as_layer=True, limit/truncation semantics, and the layers filter. However, it never explicitly states whether only SELECT-like queries are allowed, what happens on errors, or whether source layers remain unmodified—important for a tool named execute_sql.

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 dense but efficient: it front-loads the core purpose, then packs output-mode, limit, and layer-scoping semantics into a compact paragraph. Every sentence adds useful information, though the semicolon-heavy structure is slightly less scannable than a short list would be.

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?

Given 7 parameters, no annotations, and no output schema, the description covers the most important behavior and parameters but misses uid_field and layer_name, and does not fully specify the inline return format. This is adequate for basic use but leaves gaps for an agent needing complete calling 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?

The schema has zero property descriptions, so the prose must compensate. It explains query scope, as_layer, limit, layers, and geometry_field, but leaves uid_field and layer_name undefined and does not describe the expected row/result structure beyond the truncated flag.

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 states a concrete verb and resource: running SQL over loaded layers via a virtual layer, and clarifies that layers are referenced by name in FROM/JOIN. This clearly differentiates the tool from database-oriented siblings like execute_connection_sql and from field_calculator/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 Guidelines4/5

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

The description establishes a clear context: use this when querying loaded project layers rather than external connections. It also outlines the two primary output modes (inline rows vs as_layer). However, it does not explicitly name alternatives or state when not to use this tool, so it stops short of full routing guidance.

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

Deploy Server

Other Tools