Skip to main content
Glama

Add Layout Legend

add_layout_legend

Place a legend on a QGIS print layout and link it to a map item, with optional size, position, title, and layer filtering to show only the layers you choose.

Instructions

Add a legend to a print layout, linked to a map item (defaults to the first map item). Position/size in mm. Optional layer_ids restricts the legend to specific layers.

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": {
      "layout_name": "<layout_name>"
    },
    "name": "add_layout_legend"
  }
}

Input Schema

NameRequiredDescriptionDefault
xNo
yNo
titleNoLegend
widthNo
heightNo
layer_idsNo
layout_nameYes
map_item_idNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It usefully discloses two behavioral details: coordinate/size units are millimetres and the map_item_id defaults to the first map item. It omits mutation consequences, error behavior when layout_name or map items are missing, and whether an element identifier is returned.

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?

Three short sentences, front-loaded with the action and parent, then defaults, then units, then the optional filter. No redundant restatement of the name, and nothing could be removed without losing information.

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 an 8-parameter mutation with no annotations, no output schema, and zero schema description coverage, the description covers the most important semantics but is still thin. An agent lacks confirmation of success/return behavior and preconditions, though it could invoke the tool correctly.

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 0% across 8 parameters, so the description must compensate. It clarifies units for x/y/width/height, the defaulting behavior of map_item_id, and the filtering semantics of layer_ids, but leaves title, defaults for position/size, and the required layout_name unexplained.

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?

States a specific verb and resource ('Add a legend to a print layout') and names the parent object, which distinguishes it from the other layout-element tools like add_layout_label and add_layout_scalebar. It does not explicitly contrast with siblings, but the resource is unambiguous.

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?

Provides relevant calling context: the legend links to a map item and defaults to the first map item, and layer_ids optionally restricts which layers are shown. It does not say when to prefer this over another tool or what preconditions (e.g. an existing layout, a map item present) must hold.

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