Skip to main content
Glama

save_project

Save QGIS projects to specified or current paths, preserving all layers, settings, and configurations for future use.

Instructions

Save the current project to the given path, or to the current project path if not specified.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo

Implementation Reference

  • MCP tool handler for 'save_project'. Proxies the command to the underlying QGIS socket server via send_command.
    @mcp.tool() def save_project(ctx: Context, path: str = None) -> str: """Save the current project to the given path, or to the current project path if not specified.""" qgis = get_qgis_connection() params = {} if path: params["path"] = path result = qgis.send_command("save_project", params) return json.dumps(result, indent=2)
  • Core QGIS handler implementation for saving the current project using QgsProject.write().
    def save_project(self, path=None, **kwargs): """Save the current project""" project = QgsProject.instance() if not path and not project.fileName(): raise Exception("No project path specified and no current project path") save_path = path if path else project.fileName() if project.write(save_path): return {"saved": save_path} else: raise Exception(f"Failed to save project to {save_path}")
  • Registration of the 'save_project' handler (line 146) in the QGIS MCP socket server'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, }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/syauqi-uqi/qgis_mcp_modify1'

If you have feedback or need assistance with the MCP directory API, please join our Discord server