Skip to main content
Glama

qgis-mcp

Servidor MCP que controla QGIS para generar mapas temáticos sobre el shape (polígono) de un proyecto. Las capas aparecen en el lienzo de QGIS a medida que se agregan, y cada mapa queda como diseño de impresión en el Administrador de diseños, listo para retocar. Además se exporta en PDF/PNG y las capas recortadas se guardan en un GeoPackage.

Cliente MCP  ──stdio──▶  servidor qgis-mcp  ──socket 127.0.0.1:9876──▶  complemento QGIS MCP (dentro de QGIS)

El mismo paquete es el servidor y el complemento de QGIS. Si no quieres abrir QGIS, QGIS_MCP_MODE=headless ejecuta todo con PyQGIS sin ventana y guarda un .qgz junto a cada mapa.

Capas que sabe dibujar

Clave

Capa

Estilo por defecto

Recorte por defecto

ubicacion

Ubicación (país, departamentos, municipios)

un color, etiquetas por municipio

ninguno, el mapa se ajusta a la capa

rios

Ríos

línea azul, etiqueta curva

al shape

zonas_vida

Zonas de Vida (Holdridge)

por categoría

al shape

vias_acceso

Vías de Acceso

por tipo de vía

al shape

cuencas

Cuencas Hidrográficas

por cuenca

al shape

cuerpos_agua

Cuerpos de Agua

relleno azul

al shape

areas_protegidas

Áreas Protegidas

por categoría de manejo

al shape

temperatura_thornthwaite

Temperatura (Thornthwaite)

por clase

al shape

precipitacion_media

Precipitación Media Anual

rangos (Jenks) o ráster en 5 clases

al shape

humedad_thornthwaite

Humedad (Thornthwaite)

por clase

al shape

indice_humedad

Índice de Humedad

rangos o ráster

al shape

taxonomia_suelos

Taxonomía de Suelos

por orden

al shape

uso_suelo

Uso de Suelo

por categoría

al shape

comunidades

Comunidades

punto negro con nombre

al marco del mapa

volcanes

Volcanes de la región

triángulo rojo con nombre

ninguno, margen regional amplio

El campo para clasificar y el de etiquetas se detectan solos (por ejemplo ZONA_VIDA, CUENCA, ORDEN, USO, NOMBRE); se pueden indicar con field y label_field. El área del proyecto siempre se dibuja encima como contorno rojo.

Cada hoja lleva título, leyenda (solo con lo visible), norte, barra de escala, escala numérica, cuadrícula de coordenadas y una nota con proyecto, sistema de referencia, fuentes y fecha.

Mapa de ejemplo generado con los datos sintéticos de las pruebas

Related MCP server: qgis-mcp

Herramientas

Herramienta

Qué hace

ping

Comprueba que QGIS y el complemento responden

list_layer_types

Lista las 15 capas, sus campos esperados y recortes por defecto

inspect_dataset

Muestra CRS, geometría, campos y valores de ejemplo de un archivo

set_project_area

Define el shape del proyecto (y opcionalmente el CRS de salida, p. ej. EPSG:32615)

add_layer

Agrega o reemplaza una capa temática a partir de un archivo vectorial o ráster

remove_layer, reset_map, get_map_state

Administran el mapa en construcción

generate_map

Una hoja con varias capas (PDF, PNG, JPG o TIF según la extensión), abierta en el diseñador de QGIS

generate_map_series

Una hoja por capa: Mapa de Zonas de Vida, Mapa de Cuencas, etc., cada una como diseño en QGIS

En QGIS, set_project_area agrega el área como contorno rojo y encuadra el mapa; add_layer coloca cada capa con su estilo en el grupo Capas temáticas según el orden de dibujo; cada mapa generado crea un grupo oculto Mapa: título con las capas recortadas y un diseño con el mismo título (generar de nuevo el mismo título lo reemplaza).

Ejemplo de conversación: "Usa C:/proyecto/area.shp como área del proyecto, agrega zonas de vida, cuencas, ríos y volcanes de C:/datos/, y genera la serie de mapas en A3 con ríos como referencia en cada hoja."

Instalación

Necesitas QGIS 3.28 o superior (probado con 3.34).

1. Complemento de QGIS

Desde una copia de este repositorio, con cualquier Python 3.10+:

pip install -e .
qgis-mcp-install-plugin            # o: python -m qgis_mcp.install_plugin --profile otro_perfil

Esto copia el paquete a la carpeta de complementos del perfil (default):

  • Windows: %APPDATA%\QGIS\QGIS3\profiles\default\python\plugins\qgis_mcp

  • macOS: ~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qgis_mcp

  • Linux: ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis_mcp

Reinicia QGIS y activa QGIS MCP en Complementos ▸ Administrar e instalar complementos. El servidor del complemento se inicia solo (botón QGIS MCP en la barra de herramientas para detenerlo; QGIS_MCP_AUTOSTART=0 lo desactiva al abrir).

2. Servidor MCP

El servidor solo necesita Python 3.10+ y el paquete mcp; habla con QGIS por el socket. En Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "qgis": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Esaban17/qgis-mcp", "qgis-mcp"]
    }
  }
}

Variables opcionales: QGIS_MCP_HOST, QGIS_MCP_PORT (por defecto 9876, también la lee el complemento) y QGIS_MCP_TIMEOUT en segundos (por defecto 600).

Modo sin QGIS abierto

Con "env": {"QGIS_MCP_MODE": "headless"} el servidor usa PyQGIS directamente, así que debe ejecutarse con el Python de QGIS: en Linux un entorno creado con python3 -m venv --system-site-packages sobre python3-qgis; en Windows C:\Program Files\QGIS 3.34.4\bin\python-qgis.bat -m qgis_mcp; en macOS el Python de QGIS.app con QGIS_PREFIX_PATH=/Applications/QGIS.app/Contents/MacOS.

Desarrollo

.venv/bin/pip install -e '.[test]'
.venv/bin/python -m pytest

Las pruebas crean datos sintéticos de las 15 capas alrededor de un proyecto ficticio en Guatemala (tests/sample_data.py) y generan mapas reales con QGIS. tests/test_plugin.py levanta el complemento sobre el proyecto de QGIS y le habla por el socket. Sin PyQGIS, solo se ejecutan las pruebas del catálogo y del servidor.

Available Tools

10 tools
add_layerA

Add (or replace) a thematic layer, styled from the catalog.

In QGIS it appears in the "Capas temáticas" group, in drawing order.

Args: layer_type: Key from list_layer_types, e.g. "zonas_vida", "rios", "volcanes". path: Vector or raster file with the data. field: Attribute used to classify colors (auto-detected when omitted). label_field: Attribute used for labels (auto-detected when omitted). clip: "shape" cuts to the project polygon, "extent" to the map frame, "none" keeps the layer whole. Defaults depend on the layer type. title: Legend title (defaults to the catalog title). subset: Optional attribute filter in QGIS expression syntax.

Inputs: path (required), layer_type (required), clip, field, +3 more.

generate_mapA

Render one map sheet (PDF/PNG/JPG/TIF chosen by extension) over the project shape.

Includes title, legend, north arrow, scale bar, coordinate grid and notes. Clipped layers are saved to a GeoPackage next to the output. In QGIS the sheet is added to the Layout Manager (and opened when open_layout is true) so it can be edited there; headless, a .qgz project is saved next to it.

Args: output_path: Where to write the map, e.g. "C:/salidas/mapa_general.pdf". layers: Layer types to include (all added layers when omitted). page_size: A4, A3, A2, LETTER, LEGAL or TABLOID. extent: "project" zooms to the project shape, "layers" to all layers. margin_percent: Space around the project shape, in % of its size. sources: Data sources credited in the notes box. basemap: Background under the layers: "satelite" (Esri World Imagery), "google" (Google Satellite) or "osm" (OpenStreetMap). Needs internet; credited in the notes.

Inputs: output_path (required), dpi, grid, title, +10 more.

generate_map_seriesB

Render one map per thematic layer (e.g. Mapa de Zonas de Vida, Mapa de Cuencas...).

In QGIS each sheet is also added to the Layout Manager.

Args: output_dir: Folder for the maps (numbered by drawing order). layers: Layer types to map (all added layers when omitted). context_layers: Layers repeated on every sheet for reference, e.g. ["rios", "vias_acceso"]. basemap: "satelite", "google" or "osm" background on every sheet (needs internet).

Inputs: output_dir (required), dpi, format, layers, +5 more.

get_map_stateB

Show the project shape, output CRS and the layers added so far.

Inputs: no named parameters.

inspect_datasetB

Describe a vector or raster file: CRS, extent, geometry, fields and sample values.

Inputs: path (required).

list_layer_typesA

List the thematic layers this server can style (key, title, default fields).

Inputs: no named parameters. Returns: result

pingA

Check that QGIS answers and report its version.

Inputs: no named parameters.

remove_layerC

Remove a thematic layer from the map.

Inputs: layer_type (required).

reset_mapB

Forget the project shape and every layer added so far.

Inputs: no named parameters.

set_project_areaA

Set the project shape (polygon layer) every map is built on.

In QGIS it is added on top as a red outline and the canvas zooms to it.

Args: path: Polygon file (.shp, .gpkg, .geojson...). name: Project name shown on the map (defaults to the file name). crs: Output CRS such as "EPSG:32615"; defaults to the shape's CRS. subset: Optional attribute filter, e.g. ""CODIGO" = 'P-01'".

Inputs: path (required), crs, name, subset.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 10 tools

    Disambiguation4/5

    Most tools target clearly distinct actions (add, remove, inspect, generate). However, add_layer and set_project_area both add data layers to the project, and reset_map vs remove_layer could be confused by an agent skimming descriptions.

    Naming Consistency5/5

    All tool names use snake_case and follow a predictable verb_noun pattern (e.g., list_layer_types, inspect_dataset, set_project_area, add_layer, generate_map). The only outlier is 'ping', which is a standard health-check name and does not break consistency.

    Tool Count5/5

    10 tools is well-scoped for a QGIS map-generation server. Each tool serves a clear purpose, and the set avoids both bloat and missing essentials.

    Completeness4/5

    The surface covers the main lifecycle: inspect data, set project area, add/remove layers, check state, and generate single or series maps. Minor gaps include no dedicated tool to update an existing layer's style or reorder layers after creation, though add_layer can replace layers.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Connects QGIS to any MCP-speaking AI agent, exposing 125 tools that let the agent manage layers, edit features, run processing algorithms, render and style maps, author layouts and atlases, query across layers with SQL, and administer the QGIS session. Works with any MCP client and QGIS 3.28–4.x.
      GPL 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables clients to create, query and edit QGIS projects and vector data in an isolated, new headless PyQGIS process, exporting GeoJSON/GeoPackage, saving and reopening editable QGZ bundles, and rendering PNG maps through typed MCP tools. All operations are workspace-relative with strict path and geometry validation, and never attach to or modify a running QGIS desktop session.
      MIT