How nkarasiak/qgis-mcp works
QGIS MCP lets an AI agent operate a live QGIS project through MCP tools. The principal path is agent request → MCP server/client → TCP transport → QGIS plugin dispatcher → domain handler → PyQGIS, with results returning over the connection. The plugin exposes layer, feature, processing, rendering, styling, layout, connection, project, session, and system operations. The README documents the overall architecture and capabilities; source excerpts and the index support implementation links, but do not expose every handler’s internal calls.
Main entry points: qgis_mcp_plugin/server.py Socket Server · qgis_mcp/server.py MCP Server · client.py Socket Client · layers.py Layer Management
Components 20
MCP Interface
- MCP Server
src/qgis_mcp/server.py - Compound Tools
src/qgis_mcp/compound_tools.py
Socket Transport
- Socket Client
src/qgis_mcp/client.py - Client Protocol
src/qgis_mcp/protocol.py - Socket Server
qgis_mcp_plugin/server.py - Wire Framing
qgis_mcp_plugin/wire.py
QGIS Plugin
- QGIS Plugin
qgis_mcp_plugin/plugin.py - Command Registry
qgis_mcp_plugin/registry.py
QGIS Operations
- Layer Management
qgis_mcp_plugin/handlers/layers.py - Feature Editing
qgis_mcp_plugin/handlers/features.py - Processing
qgis_mcp_plugin/handlers/processing.py - Canvas Rendering
qgis_mcp_plugin/handlers/canvas.py - Styling
qgis_mcp_plugin/handlers/style.py - Layout Authoring
qgis_mcp_plugin/handlers/layout.py - Data Connections
qgis_mcp_plugin/handlers/connections.py - Project Management
qgis_mcp_plugin/handlers/project.py - Session History
qgis_mcp_plugin/handlers/session.py - System Management
qgis_mcp_plugin/handlers/system.py
Other components
- AI Agent
- PyQGIS API
Connections 28
- AI Agent → MCP Server: requests tools
README.md - MCP Server → Socket Client: uses client
src/qgis_mcp/server.py - Socket Client → Socket Server: sends commands
README.md - Socket Client → Client Protocol: uses framing
src/qgis_mcp/client.py - Socket Server → Wire Framing: frames messages
qgis_mcp_plugin/server.py - QGIS Plugin → Socket Server: starts server
qgis_mcp_plugin/plugin.py - Socket Server → Command Registry: checks commands
qgis_mcp_plugin/server.py - Socket Server → Layer Management: dispatches commands
- Socket Server → Feature Editing: dispatches commands
- Socket Server → Processing: dispatches commands
- Socket Server → Canvas Rendering: dispatches commands
- Socket Server → Styling: dispatches commands
- Socket Server → Layout Authoring: dispatches commands
- Socket Server → Data Connections: dispatches commands
- Socket Server → Project Management: dispatches commands
- Socket Server → Session History: dispatches commands
- Socket Server → System Management: dispatches commands
- MCP Server → Compound Tools: uses tools
src/qgis_mcp/server.py - Layer Management → PyQGIS API: operates on
README.md - Feature Editing → PyQGIS API: edits features
qgis_mcp_plugin/handlers/features.py - Processing → PyQGIS API: runs algorithms
README.md - Canvas Rendering → PyQGIS API: renders maps
README.md - Styling → PyQGIS API: styles layers
README.md - Layout Authoring → PyQGIS API: authors layouts
README.md - Data Connections → PyQGIS API: accesses sources
- Project Management → PyQGIS API: manages project
- Session History → PyQGIS API: restores state
qgis_mcp_plugin/handlers/session.py - System Management → PyQGIS API: manages system