Skip to main content
Glama
nkarasiak

QGIS MCP

by nkarasiak

Execute Code

execute_code
Destructive

Run arbitrary PyQGIS code for tasks not covered by other tools, using QgsProject, iface, and core classes. Receive console output and execution time.

Instructions

Execute arbitrary PyQGIS code. Use for operations not covered by other tools. Has access to QgsProject, iface, and core QGIS classes. Returns stdout/stderr and elapsed seconds. timeout: seconds before the script is cancelled (default 55); a script that runs past it comes back with timed_out=True and the output printed so far, and its side effects stand. Raise timeout or split bulk work into several calls; QGIS is unresponsive while a script runs. A single blocking call (time.sleep, GDAL) cannot be interrupted before it returns. A script that raises or times out is a tool error carrying the traceback and output so far.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
timeoutNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.14.0
    • addedInput schema / properties / timeout
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null
      +}
  2. Changed2 schema fields changedv0.5.0
    • removedInput schema / properties / code / title
      Removed value: -"Code"
    • removedInput schema / title
      Removed value: -"execute_codeArguments"
  3. First observedv0.3.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations only include destructiveHint, so the description carries the burden of behavioral disclosure. It reveals access to QgsProject/iface, return values, timeout cancellation semantics, side effects persisting after timeout, QGIS being unresponsive during execution, non-interruptibility of blocking calls, and error behavior—far beyond the annotation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is dense but every sentence carries essential information for safely invoking an arbitrary code executor. It starts with purpose and usage, then timeout behavior, then blocking caveats—no filler or repetition.

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 powerful arbitrary-code tool with no output schema and minimal annotations, the description covers the key things an agent needs: what code can do, what it returns, timeout semantics, side effects, unresponsiveness, and error handling. Nothing essential 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?

With 0% schema description coverage, the description compensates well: 'timeout' is thoroughly explained with default value and timeout outcome, and 'code' is implicitly defined as the PyQGIS code to execute. It could be stronger by explicitly labeling the code parameter, but the meaning is clear from the tool's purpose.

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?

Description states a specific verb ('Execute') and resource ('arbitrary PyQGIS code'), and explicitly frames the tool as the fallback for operations not covered by other tools, which distinguishes it from the many sibling tools. This makes its role clear at a glance.

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

Usage Guidelines5/5

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

It explicitly says 'Use for operations not covered by other tools,' which gives a clear when-to-use condition and implies that when a specific sibling exists, that sibling should be used instead. Additional guidance on raising timeouts or splitting bulk work further clarifies operational usage.

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