QGIS MCP Server
Enables AI agents to directly drive QGIS: manage layers, edit features, run processing algorithms, render maps, apply styling, author layouts and atlases, perform cross-layer SQL, develop plugins, and manage system operations through 125 MCP tools.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@QGIS MCP Serverbuffer the roads layer by 100 meters and add the result to the map"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
QGIS MCP
Connect QGIS to any AI agent that speaks the Model Context Protocol (MCP), so the agent drives QGIS directly: manage layers, edit features, run processing algorithms, render maps, and more.
125 MCP tools covering layer management, feature editing, processing, rendering, styling, layout & atlas authoring, cross-layer SQL, plugin development, and system management. Compatible with QGIS 3.28–4.x. Model and client agnostic: any MCP client works, among them Claude Code, Codex CLI, Gemini CLI, Qwen Code, Kimi Code CLI, GitHub Copilot CLI, opencode, LM Studio, Claude Desktop, Cursor, VS Code, Windsurf, Zed, and more.
Architecture
AI agent ←→ MCP Server (FastMCP) ←→ TCP socket ←→ QGIS Plugin (QTimer) ←→ PyQGIS APIQGIS Plugin (
qgis_mcp_plugin/) - Runs inside QGIS. Non-blocking TCP socket server that processes JSON commands within QGIS's event loop.MCP Server (
src/qgis_mcp/server.py) - Runs outside QGIS. Exposes QGIS operations as MCP tools via FastMCP.
Related MCP server: QGIS MCP Server
Installation
No clone needed. Requires QGIS 3.28+ and uv.
1. Install the QGIS plugin
In QGIS: Plugins > Manage and Install Plugins > search QGIS MCP > Install.
Restart QGIS and click Start Server in the QGIS MCP dock widget.
2. Connect your coding agent
claude mcp add -s user qgis -- uvx --from https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip qgis-mcp-serverScope reference:
Flag | Stored in | Visible to |
|
| You, this project |
|
| Whole team, this project |
|
| You, every project |
codex mcp add qgis -- uvx --from https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip qgis-mcp-serverOr edit ~/.codex/config.toml directly:
[mcp_servers.qgis]
command = "uvx"
args = ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"]Add to ~/.gemini/settings.json:
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"]
}
}
}Same layout as Gemini CLI. Add to ~/.qwen/settings.json:
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"]
}
}
}Add to ~/.kimi-code/mcp.json (or $KIMI_CODE_HOME/mcp.json). A .kimi-code/mcp.json
in the working directory overrides it for that project.
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"]
}
}
}Kimi has no mcp add subcommand - edit the JSON or use the /mcp-config TUI.
Add to ~/.copilot/mcp-config.json (directory overridable via $COPILOT_HOME):
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"]
}
}
}Add to ~/.lmstudio/mcp.json (%USERPROFILE%\.lmstudio\mcp.json on Windows):
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"]
}
}
}Add to opencode.json at your project root:
{
"mcp": {
"qgis": {
"type": "local",
"command": ["uvx", "--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"],
"enabled": true
}
}
}Hermes stores MCP servers in config.yaml under an mcpServers block. A standalone mcp.json is ignored. You also need a small .bat launcher - running uvx directly inside Hermes causes a venv conflict (ModuleNotFoundError: No module named 'pydantic_core._pydantic_core').
Step 1 - Create %APPDATA%\Hermes\qgis-mcp-launch.bat:
@echo off
REM Clears Hermes's venv vars so uvx uses a clean Python environment.
set VIRTUAL_ENV=
set PYTHONPATH=
set PYTHONHOME=
uvx --from "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip" qgis-mcp-serverStep 2 - Add to %APPDATA%\Hermes\config.yaml:
mcpServers:
qgis:
command: "C:\\Users\\<you>\\AppData\\Roaming\\Hermes\\qgis-mcp-launch.bat"
args: []Replace <you> with your Windows username. Restart Hermes, then verify with:
Call the QGIS ping tool.Tip: The QGIS plugin's Setup & Configurator dialog has a hermes entry in the client dropdown. Select it and click Copy to get the bat file and YAML pre-filled with your local paths.
For the full guide see docs/agent-integration.md.
opencode (which runs Nous/Hermes and other models) is supported directly by the installer:
python install.py --non-interactive --clients opencodeThis writes the correct config block to ~/.config/opencode/config.json
(%APPDATA%\opencode\config.json on Windows).
To configure manually, add to your opencode.json or global opencode config:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"qgis": {
"type": "local",
"command": [
"uvx",
"--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip",
"qgis-mcp-server"
]
}
}
}Any other agent or client that supports the MCP stdio transport can also use this server. Generic config (exact key names vary by client - see your agent's docs):
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": [
"--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip",
"qgis-mcp-server"
]
}
}
}After starting the agent, verify by asking it to call the ping tool - it
should return {"pong": true} when the QGIS plugin is running.
For a full setup guide, troubleshooting steps, and compound-tool mode configuration see
docs/agent-integration.md.
Add to your client's MCP config file:
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": [
"--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip",
"qgis-mcp-server"
]
}
}
}Usage
Start the plugin - In QGIS, click the MCP toolbar button (or
Plugins>QGIS MCP) and click "Start Server"Talk to your agent - The MCP tools appear automatically. Ask the agent to work with your QGIS project.
Example prompt
You have access to QGIS tools. Do the following:
1. Ping to check the connection
2. Create a new project and save it at "/tmp/my_project.qgz"
3. Load the vector layer "world_map.gpkg" available in Qgis ("resources/data/world_map.gpkg")
4. Filter "USA" from the field "adm0_a3"
6. Render the map and show me the result
7. Save the projectUpdating
The plugin (inside QGIS) and the MCP server (outside QGIS) must stay in sync - a newer server sending a command the older plugin doesn't know will return an error. Run diagnose after any update to verify both sides match.
Component | Remote install | Local install ( |
QGIS plugin |
| Same - Plugin Manager picks up the new version from QGIS Hub |
MCP server | uvx caches the downloaded archive - force an update with |
|
To auto-update instead, add --refresh-package qgis-mcp before --from in the configs above: uvx then re-resolves this package from GitHub on every launch. Warning: this requires network at launch - the MCP server fails to start when offline - and adds ~1–3s to startup. The plain configs above use the cached version and work offline.
After updating the plugin, click Stop / Start in the QGIS MCP dock widget (or reload via Plugins > QGIS MCP > Reload Plugin) to load the new code without restarting QGIS.
Tools (125)
Category | Tools |
Project |
|
Layers |
|
Features |
|
Fields |
|
Editing |
|
Styling |
|
Connections |
|
Rendering |
|
Bookmarks & themes |
|
Processing |
|
Session |
|
Analysis |
|
Layouts |
|
Atlas |
|
Query |
|
Layer tree |
|
Plugins |
|
System |
|
All tools are async with human-readable titles and annotations (readOnly, destructive, idempotent). Destructive tools rely on your client's own confirmation gate, which reads the destructive annotation; set QGIS_MCP_AUTO_CONFIRM=0 to have the server elicit a second confirmation as well. Long-running tools report progress via MCP logging.
Compound tool mode
Set QGIS_MCP_TOOL_MODE=compound to reduce the granular tools to 27 grouped tools (every granular command stays reachable), cutting schema overhead per LLM turn. Each compound tool takes an action parameter plus a params object holding that action's parameters:
QGIS_MCP_TOOL_MODE=compound uv run --no-sync src/qgis_mcp/server.py{ "action": "load", "params": { "path": "/data/city.qgz" } }Omit params for actions that take none ({"action": "ping"}).
Groups: system, project, layer, features, selection, editing, connection, style, canvas, render, processing, code, batch, layer_tree, plugins, variables, settings, expression, query, transform, message_log, layer_property, field, analysis, bookmarks, map_themes, active_layer.
What compound mode buys and what it costs, measured on v0.15.2 (the tool listing is 125 tools / 52.8k chars of description and schema):
with the pydantic titles stripped it is 27 tools / 28.2k chars, a 47% cut. The trade-offs are that every call loses
instance=(and the server refuses to start with more than one configured instance), parameters become an untypedparamsobject, and annotations are per group -layerandfeaturesaredestructivefor their read-only actions too.
Tool profiles
QGIS_MCP_TOOL_PROFILE keeps a subset of the granular tools, with none of compound mode's trade-offs (typed parameters, instance=, per-tool annotations):
QGIS_MCP_TOOL_PROFILE=read-only uv run --no-sync src/qgis_mcp/server.pyProfile | Tools | Listing | For |
| 125 | 52.8k chars | everything |
| 44 | 16.1k chars | an agent that only inspects a project |
| 24 | 9.7k chars | read, run Processing, render, |
Profiles apply to granular mode; combining one with QGIS_MCP_TOOL_MODE=compound is refused rather than silently ignored.
Configuration
Environment variable | Default | Description |
|
| Host for socket connection |
|
| Port for socket connection. The QGIS plugin reads it too: set in the environment QGIS is launched from, it overrides the port saved in the plugin's dropdown for that window. |
| (unset) | Address several running QGIS windows from one server. See Multiple QGIS instances. |
| (unset) | Optional shared secret. When set, the plugin rejects any command without a matching token. See Authentication. |
|
| MCP transport: |
|
| Log file path (empty to disable) |
|
| File log level |
|
|
|
|
|
|
| on | Confirmation elicitation on destructive tools ( |
Authentication
By default the socket has no authentication - it binds to localhost only, but any process on the machine that can reach the port can drive QGIS (including execute_code, which runs arbitrary PyQGIS). For shared or multi-user machines, set a shared secret so only callers that know it can connect:
Set
QGIS_MCP_TOKENin the environment QGIS runs in (so the plugin enforces it), then Stop/Start the server in the dock. The QGIS log showsToken authentication ENABLED.Set the same value in the MCP server's environment - add it to the
envblock of your MCP client config:{ "mcpServers": { "qgis": { "command": "uvx", "args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"], "env": { "QGIS_MCP_TOKEN": "your-long-random-secret" } } } }
The token is compared in constant time. When QGIS_MCP_TOKEN is unset (the default), behaviour is unchanged. This raises the bar against other local users/processes; a process running as the same user can still read the token from your config, so it is not a sandbox.
One exception: binding the plugin to a non-loopback address requires a token. Exposing arbitrary PyQGIS execution to the network without authentication is not a state you should be able to reach by accident, so the plugin refuses to start on such an address until QGIS_MCP_TOKEN is set (in QGIS and in the MCP server).
Multiple QGIS instances
One server registration can drive several running QGIS windows. Start each QGIS with the plugin on its own port, then list them in QGIS_MCP_INSTANCES as comma-separated name=port or name=host:port entries.
Set a window's port in the dropdown next to the MCP toolbar button (the arrow beside the logo) before starting the server. That choice is saved per QGIS profile, so two windows on the same profile would both start on it; launch each with its own QGIS_MCP_PORT instead (for example QGIS_MCP_PORT=9877 qgis), which overrides the saved port without changing it. The same applies when another program already listens on 9876 (Blender's MCP add-on does by default).
{
"mcpServers": {
"qgis": {
"command": "uvx",
"args": ["--from", "https://github.com/nkarasiak/qgis-mcp/archive/refs/heads/main.zip", "qgis-mcp-server"],
"env": { "QGIS_MCP_INSTANCES": "default=9876,planning=9877,archive=lab-box:9878" }
}
}
}Every tool takes an optional
instanceargument (get_layers(instance="planning")). Omitting it targets the entry nameddefault, or - when no entry is calleddefault- the first entry listed, soplanning=9877,archive=9878works without renaming anything.list_qgis_instancesreturns the configured names with their host, port, and current reachability. An unknown name is rejected with the list of valid names.Instance names match
[A-Za-z0-9_-]+; entries without a host useQGIS_MCP_HOST(defaultlocalhost).Each instance has its own pooled connection and its own lock, so two QGIS windows can be driven concurrently.
Not supported with
QGIS_MCP_TOOL_MODE=compound. Compound tools carry noinstanceargument, so every call would silently hit one instance; configuring more than one instance in compound mode refuses to start rather than routing writes to the wrong QGIS.When
QGIS_MCP_INSTANCESis unset, exactly one instance nameddefaultis defined fromQGIS_MCP_HOST/QGIS_MCP_PORT- existing setups are unaffected.QGIS_MCP_TOKENis shared across instances: the same secret must be set in every QGIS.
Contributing
git clone https://github.com/nkarasiak/qgis-mcp.git
cd qgis-mcp
python install.py # symlinks plugin + configures your MCP clientinstall.py options: --clients claude-desktop,cursor, --remote (uvx instead of uv run), --profile myprofile, --uninstall.
Known client names: claude-desktop, cursor, vscode, windsurf, zed, claude-code, codex, opencode, hermes, kimi, gemini, qwen, copilot-cli, lmstudio.
Windows (Microsoft Store / MSIX Claude Desktop):
install.pyuses--directoryinstead ofcwdin generated configs. This is required for Store-installed Claude Desktop, which runs MCP servers in an MSIX sandbox that silently dropscwd. If you configure manually, useuv --directory "/path/to/qgis-mcp" run --no-sync src/qgis_mcp/server.py- this works on both MSIX and standalone installs. You can identify a Store install when the config file is under%LOCALAPPDATA%\Packages\Claude_<id>\LocalCache\Roaming\Claude\instead of%APPDATA%\Claude\.
# Unit tests (no QGIS needed - mocked socket)
uv run --no-sync pytest tests/test_mcp_tools.py -v
# Integration tests (requires QGIS plugin running)
uv run --no-sync pytest tests/test_qgis_live.py -vLicense
This project is dual-licensed. Each component is distributed under its own license:
QGIS Plugin (
qgis_mcp_plugin/) - GNU GPL v2 or laterMCP Server (
src/qgis_mcp/) - MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
214 tools for AI agents over one MCP endpoint: image, video, audio, 3D, data, storage, mail, GPUs.
- geoOAuthco.thinair
Geocoding, routing, isochrones, traffic, weather, and place search for AI agents. 19 MCP tools.
Connect any AI agent to 1,000+ apps and 27,000+ actions through one remote MCP server (OAuth).
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseCqualityAmaintenanceAn MCP server that enables AI assistants to directly control QGIS for tasks like layer management, feature editing, and map rendering. It provides a suite of 50 tools to execute processing algorithms and manage GIS projects through natural language commands.125380GPL 2.0
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with QGIS, supporting project management, layer inspection, spatial queries, styling, and map export in both headless and desktop modes.-
- AlicenseAqualityDmaintenanceConnect QGIS to Claude AI through the Model Context Protocol (MCP), enabling Claude to directly control QGIS — manage layers, edit features, run processing algorithms, render maps, and more.1001MIT
- AlicenseNot gradedqualityDmaintenanceConnects AI assistants (Claude, Cursor, etc.) to QGIS 4.x via MCP, enabling natural language-driven GIS workflows through 37+ tools, including data loading, processing, and spatial analysis.GPL 2.0