execute_processing
Run QGIS processing algorithms with specified parameters to perform geospatial analysis and data manipulation tasks.
Instructions
Execute a processing algorithm with the given parameters.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| algorithm | Yes | ||
| parameters | Yes |
Implementation Reference
- src/qgis_mcp/qgis_mcp_server.py:230-235 (handler)The primary MCP tool handler for 'execute_processing'. This function is decorated with @mcp.tool() and proxies the processing request to the underlying QGIS socket server.def execute_processing(ctx: Context, algorithm: str, parameters: dict) -> str: """Execute a processing algorithm with the given parameters.""" qgis = get_qgis_connection() result = qgis.send_command("execute_processing", {"algorithm": algorithm, "parameters": parameters}) return json.dumps(result, indent=2)
- The core implementation in the QGIS plugin that executes the actual QGIS processing algorithm using processing.run().def execute_processing(self, algorithm, parameters, **kwargs): """Execute a processing algorithm""" try: import processing result = processing.run(algorithm, parameters) return { "algorithm": algorithm, "result": {k: str(v) for k, v in result.items()} # Convert values to strings for JSON } except Exception as e: raise Exception(f"Processing error: {str(e)}")
- qgis_mcp_plugin/qgis_mcp_plugin.py:133-149 (registration)Internal registration of the execute_processing handler in the QGIS plugin's command handlers dictionary.handlers = { "ping": self.ping, "get_qgis_info": self.get_qgis_info, "load_project": self.load_project, "get_project_info": self.get_project_info, "execute_code": self.execute_code, "add_vector_layer": self.add_vector_layer, "add_raster_layer": self.add_raster_layer, "get_layers": self.get_layers, "remove_layer": self.remove_layer, "zoom_to_layer": self.zoom_to_layer, "get_layer_features": self.get_layer_features, "execute_processing": self.execute_processing, "save_project": self.save_project, "render_map": self.render_map, "create_new_project": self.create_new_project, }