QGISMCP

Integrations

  • Allows direct interaction with and control of QGIS GIS software, enabling project creation/manipulation, layer loading/management, processing algorithm execution, and running arbitrary PyQGIS code for geospatial data visualization and analysis.

QGISMCP - QGIS モデルコンテキストプロトコル統合

QGISMCPは、モデルコンテキストプロトコル(MCP)を介してQGISClaude AIに接続し、ClaudeがQGISを直接操作して制御できるようにします。この統合により、迅速なプロジェクト作成、レイヤーの読み込み、コード実行などの支援が可能になります。

このプロジェクトは、Siddharth AhujaによるBlenderMCPプロジェクトに基づいています。

特徴

  • 双方向通信: ソケットベースのサーバーを介して Claude AI を QGIS に接続します。
  • プロジェクト操作: QGIS でプロジェクトを作成、読み込み、保存します。
  • レイヤー操作: プロジェクトにベクター レイヤーまたはラスター レイヤーを追加および削除します。
  • 処理の実行: 処理アルゴリズムを実行します ( Processing Toolbox )。
  • コード実行:Claude氏によるQGISで任意のPythonコードを実行できます。非常に強力なツールですが、使用には細心の注意が必要です。

コンポーネント

このシステムは、次の 2 つの主要コンポーネントで構成されています。

  1. QGIS プラグイン: コマンドを受信して実行するために QGIS 内にソケット サーバーを作成する QGIS プラグイン。
  2. MCP サーバー: モデル コンテキスト プロトコルを実装し、QGIS プラグインに接続する Python サーバー。

インストール

前提条件

  • QGIS 3.X (3.22 でのみテスト済み)
  • クラウドデスクトップ
  • Python 3.10以降
  • uv パッケージマネージャー:

Macをお使いの場合は、uvをインストールしてください。

brew install uv

Windows PowerShellの場合

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

それ以外の場合、インストール手順はウェブサイトに掲載されています: Install uv

⚠️UVをインストールする前に続行しないでください

コードをダウンロード

このリポジトリをコンピュータにダウンロードしてください。以下のコマンドでクローンできます。

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

QGISプラグイン

フォルダーqgis_mcp_pluginとその内容を QGIS プロファイル プラグイン フォルダーにコピーする必要があります。

QGIS でプロファイル フォルダーを取得するには、メニューのSettings -> User profiles -> Open active profile folderに移動します。次に、 Python/pluginsに移動して、フォルダーqgis_mcp_pluginを貼り付けます。

Windows マシンでは、プラグイン フォルダは通常、次の場所にあります: C:\Users\USER\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins 、MacOS では次の場所にあります: ~/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins

QGISを一度閉じて、もう一度開きます。メニューオプションPlugins 」→ Installing and Managing Pluginsに移動し、「 Allタブを選択して「QGIS MCP」を検索し、「QGIS MCP」のチェックボックスをオンにします。

デスクトップ統合のクロード

Claude > Settings > Developer > Edit Config > claude_desktop_config.jsonに移動して、以下を追加します。

「開発者タブ」またはclaude_desktop_config.jsonが見つからない場合は、このドキュメントを参照してください。

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

使用法

接続の開始

  1. QGISで、 plugins -> QGIS MCP -> QGIS MCPに移動します。
  2. 「サーバーを開始」をクリックします

クロードと一緒に使う

Claude で設定ファイルが設定され、サーバーが QGIS で実行されると、QGIS MCP のツールが表示されたハンマー アイコンが表示されます。

ツール

  • ping - サーバーの接続を確認するためのシンプルなpingコマンド
  • get_qgis_info - 現在のインストールに関するQGIS情報を取得します
  • load_project - 指定されたパスからQGISプロジェクトをロードします
  • create_new_project - 新しいプロジェクトを作成して保存する
  • get_project_info - 現在のプロジェクト情報を取得する
  • add_vector_layer - プロジェクトにベクターレイヤーを追加する
  • add_raster_layer - プロジェクトにラスターレイヤーを追加する
  • get_layers - 現在のプロジェクト内のすべてのレイヤーを取得します
  • remove_layer - ID でプロジェクトからレイヤーを削除します
  • zoom_to_layer - 指定されたレイヤーの範囲にズームします
  • get_layer_features - オプションの制限付きでベクターレイヤーからフィーチャを取得します
  • execute_processing - 指定されたパラメータで処理アルゴリズムを実行する
  • save_project - 現在のプロジェクトを指定されたパスに保存します
  • render_map - 現在のマップビューを画像ファイルにレンダリングします
  • execute_code - 文字列として提供された任意のPyQGISコードを実行する

コマンド例

これはデモに使用した例です:

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.
-
security - not tested
F
license - not found
-
quality - not tested

モデル コンテキスト プロトコルを介して QGIS を Claude AI に接続し、AI 支援によるプロジェクトの作成、レイヤーの操作、処理アルゴリズムの実行、QGIS 内での Python コードの実行を可能にします。

  1. Features
    1. Components
      1. Installation
        1. Prerequisites
        2. Download code
        3. QGIS plugin
        4. Claude for Desktop Integration
      2. Usage
        1. Starting the Connection
        2. Using with Claude
        3. Example Commands
      ID: s4qv0wycq6