Skip to main content
Glama
nkarasiak

QGIS MCP

by nkarasiak

Field Calculator

field_calculator

Add a missing field and populate it with a QGIS expression per feature, updating values in place. Returns updated and failed counts, preserving old values on error.

Instructions

Add (if missing) + populate a field from a QGIS expression, per feature, in-place. field_type: string|int|double|bool|date|datetime (default double). Example: expression='$area', field_name='area'. $area/$length use the project's ellipsoid and units (reported back as 'measurement'), not necessarily m2/m; the area()/length() functions are planimetric in the layer CRS (measurement.planimetric_units, squared for area()); length() of a string counts characters and reports no units. Returns updated and failed counts; failed features keep their old value and first_error says why. Refused while the layer has an open edit session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lengthNo
layer_idYes
precisionNo
expressionYes
field_nameYes
field_typeNodouble

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.5.0

TDQS

A4/5.0
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It discloses in-place modification, partial failure (failed features keep old value), return counts, and the refusal during edit sessions. It also explains unit semantics for $area vs area() and length(), which is valuable. It does not mention authorization or reversibility, but the safety-critical aspects are covered.

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 information-dense but not overly long. It front-loads the purpose, then provides an example and key nuances. Each sentence adds value. It could be more structured (e.g., bullet points) but is acceptable.

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?

The description explains return values (updated/failed counts), failure behavior, and unit semantics. However, it does not clarify whether existing field values are overwritten or if the field is created only when missing (the phrase 'Add (if missing)' is ambiguous). It also omits precision and length parameter details. Without an output schema, these gaps matter.

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 coverage is 0%, so the description must explain all parameters. It covers field_type (with allowed values and default), expression, and field_name (via example). However, layer_id is not explained (though likely obvious), and precision and length are entirely omitted. This leaves some parameters undocumented.

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 adds and populates a field from a QGIS expression per feature, in-place. It distinguishes itself from siblings like add_field (which only adds a field) and evaluate_expression (which only evaluates without writing). The verb 'add' and 'populate' with resource 'field' is specific.

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 provides an example and explains when to use it (to compute a field from an expression). It implicitly differentiates from add_field and evaluate_expression by stating it adds and populates. It also notes a key constraint: refused during an open edit session. However, it does not explicitly say when not to use it or name alternative tools.

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