Cover image
Try Now
2025-03-14

允许LLMS使用QGIS桌面的模型上下文协议(MCP)

3 years

Works with Finder

9

Github Watches

49

Github Forks

434

Github Stars

QGISMCP - QGIS Model Context Protocol Integration

QGISMCP connects QGIS to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control QGIS. This integration enables prompt assisted project creation, layer loading, code execution and more.

This project is strongly based on the BlenderMCP project by Siddharth Ahuja

Features

  • Two-way communication: Connect Claude AI to QGIS through a socket-based server.
  • Project manipulation: Create, load and save projects in QGIS.
  • Layer manipulation: Add and remove vector or raster layers to a project.
  • Execute processing: Execute processing algorithms (Processing Toolbox).
  • Code execution: Run arbitrary Python code in QGIS from Claude. Very powerful, but also be very cautious using this tool.

Components

The system consists of two main components:

  1. QGIS plugin: A QGIS plugin that creates a socket server within QGIS to receive and execute commands.
  2. MCP Server: A Python server that implements the Model Context Protocol and connects to the QGIS plugin.

Installation

Prerequisites

  • QGIS 3.X (only tested on 3.22)
  • Cloud desktop
  • Python 3.10 or newer
  • uv package manager:

If you're on Mac, please install uv as

brew install uv

On Windows Powershell

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Otherwise installation instructions are on their website: Install uv

⚠️ Do not proceed before installing UV

Download code

Download this repo to your computer. You can clone it with:

git clone git@github.com:jjsantos01/qgis_mcp.git

QGIS plugin

You need to copy the folder qgis_mcp_plugin and its content on your QGIS profile plugins folder.

You can get your profile folder in QGIS going to menu Settings -> User profiles -> Open active profile folder Then, go to Python/plugins and paste the folder qgis_mcp_plugin.

On a Windows machine the plugins folder is usually located at: C:\Users\USER\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins and on MacOS: ~/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins

Then close QGIS and open it again. Go to the menu option Plugins -> Installing and Managing Plugins, select the All tab and search for "QGIS MCP", then mark the QGIS MCP checkbox.

Claude for Desktop Integration

Go to Claude > Settings > Developer > Edit Config > claude_desktop_config.json to include the following:

If you cann't find the "Developers tab" or the claude_desktop_config.json look at this documentation.

{
    "mcpServers": {
        "qgis": {
            "command": "uv",
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/PARENT/REPO/FOLDER/qgis_mcp/src/qgis_mcp",
                "run",
                "qgis_mcp_server.py"
            ]
        }

    }
}

Usage

Starting the Connection

  1. In QGIS, go to plugins -> QGIS MCP-> QGIS MCP plugins menu
  2. Click "Start Server" start server

Using with Claude

Once the config file has been set on Claude, and the server is running on QGIS, you will see a hammer icon with tools for the QGIS MCP.

Claude tools

Tools

  • ping - Simple ping command to check server connectivity
  • get_qgis_info - Get QGIS information about the current installation
  • load_project - Load a QGIS project from the specified path
  • create_new_project - Create a new project and save it
  • get_project_info - Get current project information
  • add_vector_layer - Add a vector layer to the project
  • add_raster_layer - Add a raster layer to the project
  • get_layers - Retrieve all layers in the current project
  • remove_layer - Remove a layer from the project by its ID
  • zoom_to_layer - Zoom to the extent of a specified layer
  • get_layer_features - Retrieve features from a vector layer with an optional limit
  • execute_processing - Execute a processing algorithm with the given parameters
  • save_project - Save the current project to the given path
  • render_map - Render the current map view to an image file
  • execute_code - Execute arbitrary PyQGIS code provided as a string

Example Commands

This is the example I used for the demo:

You have access to the tools to work with QGIS. You will do the following:
	1. Ping to check the connection. If it works, continue with the following steps.
	2. Create a new project and save it at: "C:/Users/USER/GitHub/qgis_mcp/data/cdmx.qgz"
	3. Load the vector layer: ""C:/Users/USER/GitHub/qgis_mcp/data/cdmx/mgpc_2019.shp" and name it "Colonias".
	4. Load the raster layer: "C:/Users/USER/GitHub/qgis_mcp/data/09014.tif" and name it "BJ"
	5. Zoom to the "BJ" layer.
	6. Execute the centroid algorithm on the "Colonias" layer. Skip the geometry check. Save the output to "colonias_centroids.geojson".
	7. Execute code to create a choropleth map using the "POB2010" field in the "Colonias" layer. Use the quantile classification method with 5 classes and the Spectral color ramp.
	8. Render the map to "C:/Users/USER/GitHub/qgis_mcp/data/cdmx.png"
	9. Save the project.

相关推荐

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • Beria Joey
  • 你的职业规划师,不走弯路就问我。Sponsor:小红书“ ItsJoe就出行 ”

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

  • GLips
  • MCP服务器向像光标这样的AI编码代理提供FIGMA布局信息

  • idosal
  • 结束幻觉! GITMCP是任何GitHub项目的免费,开源的远程MCP服务器

    Reviews

    3 (1)
    Avatar
    user_yeRMytDx
    2025-04-17

    As a dedicated user of the mcp application, I must say that qgis_mcp from jjsantos01 is a game-changer. The seamless integration with QGIS and the comprehensive set of tools it offers has significantly enhanced my workflow. The project's detail and reliability stand out, making it indispensable for anyone serious about geographic analysis. Highly recommend!