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,
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description must disclose behaviors. It mentions saving to a path but omits details like overwrite behavior, error handling, or whether the project remains open. Critical gaps remain.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no redundancy, and directly to the point. Every word contributes to clarifying the functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one optional parameter, the description covers the primary use case. However, it lacks details on error cases, file format, or success feedback, leaving some incompleteness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description explains the single parameter 'path' effectively: it is optional, and the tool falls back to the current project path. This adds meaningful context beyond the schema (which only has type and default).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (save) and resource (current project), and distinguishes from siblings like load_project and create_new_project by focusing on saving an existing project.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use versus alternatives (e.g., save vs. export) or prerequisites. The description implies the optional path but does not clarify when to specify it versus using the default.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.