### QGIS Workflow Example Commands Source: https://github.com/jjsantos01/qgis_mcp/blob/main/README.md This plain text example details a step-by-step process for using QGIS tools. It covers loading vector and raster data, performing spatial analysis like centroid calculation, creating a choropleth map, and rendering the final output. ```plain 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. ``` -------------------------------- ### Get QGIS Installation Info Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieve metadata about the QGIS installation, including version, profile folder, and the number of loaded plugins. Ensure the client is connected before calling. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() info = client.get_qgis_info() # { # "status": "success", # "result": { # "qgis_version": "3.22.4-Białowieża", # "profile_folder": "/home/user/.local/share/QGIS/QGIS3/profiles/default/", # "plugins_count": 12 # } # } print(info) client.disconnect() ``` -------------------------------- ### Install uv Package Manager (Windows) Source: https://github.com/jjsantos01/qgis_mcp/blob/main/CONTRIBUTING.md Install the uv package manager using PowerShell on Windows. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install uv Package Manager (Mac) Source: https://github.com/jjsantos01/qgis_mcp/blob/main/CONTRIBUTING.md Install the uv package manager using Homebrew on macOS. ```bash brew install uv ``` -------------------------------- ### get_qgis_info Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieves metadata about the QGIS installation, including version, profile folder, and plugin count. ```APIDOC ## Tool: `get_qgis_info` ### Description Returns metadata about the running QGIS installation: version string, active profile folder path, and the count of currently loaded plugins. ### Method `get_qgis_info()` ### Parameters None ### Response Example ```json { "status": "success", "result": { "qgis_version": "3.22.4-Białowieża", "profile_folder": "/home/user/.local/share/QGIS/QGIS3/profiles/default/", "plugins_count": 12 } } ``` ``` -------------------------------- ### Get Current Project Information Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieve a summary of the active QGIS project, including filename, title, CRS, layer count, and details for the first 10 layers. Ensure the client is connected. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() project_info = client.get_project_info() # { # "status": "success", # "result": { # "filename": "/home/user/gis/my_project.qgz", # "title": "", # "layer_count": 2, # "crs": "EPSG:4326", # "layers": [ # {"id": "colonias_abc123", "name": "Colonias", "type": "vector_2", "visible": true}, # {"id": "imagery_xyz456", "name": "BJ", "type": "raster", "visible": true} # ] # } # } print(project_info) client.disconnect() ``` -------------------------------- ### Get All Loaded Layers Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieves a list of all layers currently in the QGIS project. Includes type-specific metadata such as feature count and geometry type for vector layers, and dimensions for raster layers. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() layers = client.get_layers() # { # "status": "success", # "result": [ # { # "id": "municipalities_a1b2c3", # "name": "Municipalities", # "type": "vector_2", # "visible": true, # "feature_count": 1458, # "geometry_type": 2 # }, # { # "id": "dem_d4e5f6", # "name": "DEM", # "type": "raster", # "visible": true, # "width": 2048, # "height": 2048 # } # ] # } print(layers) client.disconnect() ``` -------------------------------- ### Get Vector Layer Features Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieves features from a vector layer, including attributes and WKT geometry. The `limit` parameter controls the maximum number of features returned to manage response size. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() features = client.get_layer_features( layer_id="municipalities_a1b2c3", limit=3 ) # { # "status": "success", # "result": { # "layer_id": "municipalities_a1b2c3", # "feature_count": 1458, # "fields": ["OBJECTID", "NAME", "POP2020", "AREA_KM2"], # "features": [ # { # "id": 0, # "attributes": {"OBJECTID": 1, "NAME": "Benito Juarez", "POP2020": 434153, "AREA_KM2": 26.86}, # "geometry": {"type": 2, "wkt": "Polygon ((...))" } # } # ] # } # } print(features) client.disconnect() ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/jjsantos01/qgis_mcp/blob/main/CONTRIBUTING.md Clone the repository locally and navigate into the project directory. ```bash git clone git@github.com:YOUR-USERNAME/qgis_mcp.git cd qgis_mcp ``` -------------------------------- ### Create New QGIS Project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Create a new blank QGIS project, specify its save path, and write it to disk. If a project is open, it will be cleared first. The path must be absolute and include the filename. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() result = client.send_command("create_new_project", { "path": "/home/user/gis/my_project.qgz" }) # { # "status": "success", # "result": { # "created": "Project created and saved successfully at: /home/user/gis/my_project.qgz", # "layer_count": 0 # } # } print(result) client.disconnect() ``` -------------------------------- ### create_new_project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Creates a new blank QGIS project, sets its save path, and saves it to disk. ```APIDOC ## Tool: `create_new_project` ### Description Creates a blank QGIS project, sets its save path, and immediately writes it to disk. If a project is already open it is cleared first. Accepts a full absolute path including the `.qgz` filename. ### Method `create_new_project(path: str)` ### Parameters #### Path Parameters - **path** (string) - Required - The absolute path including the filename (e.g., `/home/user/gis/my_project.qgz`) where the new project will be saved. ### Response Example ```json { "status": "success", "result": { "created": "Project created and saved successfully at: /home/user/gis/my_project.qgz", "layer_count": 0 } } ``` ``` -------------------------------- ### Configure Claude MCP Servers Source: https://github.com/jjsantos01/qgis_mcp/blob/main/README.md Configure the Claude desktop application to connect to the QGIS MCP server. This JSON configuration specifies how to launch the server using 'uv'. Ensure the '/ABSOLUTE/PATH/TO/PARENT/REPO/FOLDER/' is replaced with the actual absolute path to your cloned repository. ```json { "mcpServers": { "qgis": { "command": "uv", "args": [ "--directory", "/ABSOLUTE/PATH/TO/PARENT/REPO/FOLDER/qgis_mcp/src/qgis_mcp", "run", "qgis_mcp_server.py" ] } } } ``` -------------------------------- ### load_project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Opens an existing QGIS project file and refreshes the map canvas. ```APIDOC ## Tool: `load_project` ### Description Opens an existing `.qgz` or `.qgs` QGIS project from a file path and refreshes the map canvas. Returns the loaded path and the number of layers contained in the project. ### Method `load_project(path: str)` ### Parameters #### Path Parameters - **path** (string) - Required - The absolute path to the QGIS project file (e.g., `/home/user/gis/existing_project.qgz`). ### Response Example ```json { "status": "success", "result": { "loaded": "/home/user/gis/existing_project.qgz", "layer_count": 5 } } ``` ``` -------------------------------- ### Configure Claude Desktop for MCP Server Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Edit the Claude Desktop configuration file to launch the MCP server automatically. Ensure the path to the qgis_mcp source directory is correct. ```json { "mcpServers": { "qgis": { "command": "uv", "args": [ "--directory", "/absolute/path/to/qgis_mcp/src/qgis_mcp", "run", "qgis_mcp_server.py" ] } } } ``` -------------------------------- ### Clone QGIS MCP repository Source: https://github.com/jjsantos01/qgis_mcp/blob/main/README.md Clone the QGIS MCP repository to your local machine using Git. This is the first step in setting up the integration. ```bash git clone git@github.com:jjsantos01/qgis_mcp.git ``` -------------------------------- ### get_project_info Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieves a summary of the currently open QGIS project, including its layers. ```APIDOC ## Tool: `get_project_info` ### Description Returns a summary of the currently open QGIS project, including its filename, title, CRS (as an EPSG authority string), total layer count, and metadata for up to the first 10 layers (id, name, type, visibility). ### Method `get_project_info()` ### Parameters None ### Response Example ```json { "status": "success", "result": { "filename": "/home/user/gis/my_project.qgz", "title": "", "layer_count": 2, "crs": "EPSG:4326", "layers": [ {"id": "colonias_abc123", "name": "Colonias", "type": "vector_2", "visible": true}, {"id": "imagery_xyz456", "name": "BJ", "type": "raster", "visible": true} ] } } ``` ``` -------------------------------- ### Claude Desktop MCP Server Configuration Source: https://github.com/jjsantos01/qgis_mcp/blob/main/CONTRIBUTING.md Configure Claude Desktop to connect to the QGIS MCP server using uv. ```json { "mcpServers": { "qgis": { "command": "uv", "args": [ "--directory", "/ABSOLUTE/PATH/TO/qgis_mcp/src/qgis_mcp", "run", "qgis_mcp_server.py" ] } } } ``` -------------------------------- ### Symlink QGIS Plugin (Windows) Source: https://github.com/jjsantos01/qgis_mcp/blob/main/CONTRIBUTING.md Create a symbolic link from the project's plugin directory to the QGIS plugin directory on Windows using PowerShell. ```powershell $src = "$(pwd)\qgis_mcp_plugin" $dst = "$env:APPDATA\QGIS\QGIS3\profiles\default\python\plugins\qgis_mcp" New-Item -ItemType SymbolicLink -Path $dst -Target $src ``` -------------------------------- ### Load Existing QGIS Project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Open an existing QGIS project file (.qgz or .qgs) and refresh the map canvas. The function returns the loaded path and the number of layers in the project. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() result = client.load_project("/home/user/gis/existing_project.qgz") # { # "status": "success", # "result": { # "loaded": "/home/user/gis/existing_project.qgz", # "layer_count": 5 # } # } print(result) client.disconnect() ``` -------------------------------- ### Symlink QGIS Plugin (Mac) Source: https://github.com/jjsantos01/qgis_mcp/blob/main/CONTRIBUTING.md Create a symbolic link from the project's plugin directory to the QGIS plugin directory on macOS. ```bash ln -s $(pwd)/qgis_mcp_plugin ~/Library/Application\ Support/QGIS/QGIS3/profiles/default/python/plugins/qgis_mcp ``` -------------------------------- ### Ping QGIS MCP Server Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Verify the connection to the QGIS plugin socket server using the 'ping' tool. This is the recommended first step before executing other commands. It returns a simple pong response. ```python # Via MCP server tool (called by Claude) result = ping(ctx) # Returns: '{"status": "success", "result": {"pong": true}}' ``` ```python # Direct socket usage (QgisMCPClient) from qgis_socket_client import QgisMCPClient client = QgisMCPClient(host='localhost', port=9876) if client.connect(): response = client.ping() # {"status": "success", "result": {"pong": true}} print(response) client.disconnect() else: print("Could not connect to QGIS plugin server") ``` -------------------------------- ### Save QGIS Project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Saves the currently open QGIS project. Provide a new path to save to a different location, or call without arguments to save to the existing project file. Ensure the client is connected before use. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() # Save to a new path result = client.save_project("/home/user/gis/my_project_v2.qgz") # {"status": "success", "result": {"saved": "/home/user/gis/my_project_v2.qgz"}} # Save to current project path (no argument) result = client.save_project() # {"status": "success", "result": {"saved": "/home/user/gis/my_project_v2.qgz"}} print(result) client.disconnect() ``` -------------------------------- ### Add Vector Layer to QGIS Project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Loads a vector file into the QGIS project. Supports various OGR-compatible formats. Ensure the file path is correct and the provider is specified if not using the default. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() result = client.add_vector_layer( path="/home/user/data/municipalities.shp", name="Municipalities", provider="ogr" # default, supports shp/gpkg/geojson/etc. ) # { # "status": "success", # "result": { # "id": "municipalities_a1b2c3", # "name": "Municipalities", # "type": "vector_2", # "feature_count": 1458 # } # } print(result) client.disconnect() ``` -------------------------------- ### ping Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Checks the connection to the QGIS plugin socket server. Returns a 'pong' response if successful. ```APIDOC ## Tool: `ping` ### Description Checks that the MCP server can reach the QGIS plugin socket server. Returns a simple pong response and is the recommended first step to verify the end-to-end connection before issuing real commands. ### Method `ping(ctx)` ### Parameters - `ctx`: The context object for the MCP server. ### Response Example ```json { "status": "success", "result": { "pong": true } } ``` ``` -------------------------------- ### Add Raster Layer to QGIS Project Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Loads a raster file into the QGIS project. Supports formats like GeoTIFF and IMG using the GDAL provider. Ensure the file path is correct. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() result = client.add_raster_layer( path="/home/user/data/elevation.tif", name="DEM", provider="gdal" # default ) # { # "status": "success", # "result": { # "id": "dem_d4e5f6", # "name": "DEM", # "type": "raster", # "width": 2048, # "height": 2048 # } # } print(result) client.disconnect() ``` -------------------------------- ### Execute QGIS Processing Algorithm Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Runs any QGIS Processing Toolbox algorithm using its ID and a parameters dictionary. This is used for geoprocessing tasks like calculating centroids or performing spatial analysis. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() # Compute centroids of the Municipalities polygon layer result = client.execute_processing( algorithm="native:centroids", parameters={ "INPUT": "municipalities_a1b2c3", "ALL_PARTS": False, "OUTPUT": "/home/user/data/municipalities_centroids.geojson" } ) # { # "status": "success", # "result": { # "algorithm": "native:centroids", # "result": {"OUTPUT": "/home/user/data/municipalities_centroids.geojson"} # } # } ``` -------------------------------- ### execute_processing Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Runs a QGIS Processing Toolbox algorithm by its ID, passing a dictionary of parameters. This allows for complex geoprocessing tasks to be automated. ```APIDOC ## Tool: `execute_processing` Runs any algorithm available in the QGIS Processing Toolbox by its algorithm ID, passing a parameters dictionary. Output paths, layer references, and algorithm-specific options are all passed in `parameters`. ### Parameters - **algorithm** (string) - Required - The ID of the QGIS processing algorithm to run. - **parameters** (object) - Required - A dictionary containing the parameters for the algorithm. This includes input layers, output paths, and algorithm-specific options. ``` -------------------------------- ### Render Map Canvas to Image Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Renders the current QGIS map canvas to a PNG image. Use `zoom_to_layer` beforehand to set the extent. Specify the output path, width, and height for the rendered image. Requires an active client connection. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() # Zoom to layer extent first, then render client.zoom_to_layer("municipalities_a1b2c3") result = client.render_map( path="/home/user/output/map.png", width=1920, height=1080 ) # { # "status": "success", # "result": { # "rendered": true, # "path": "/home/user/output/map.png", # "width": 1920, # "height": 1080 # } # } print(result) client.disconnect() ``` -------------------------------- ### get_layers Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieves a list of all layers currently loaded in the QGIS project. Includes type-specific metadata for each layer. ```APIDOC ## Tool: `get_layers` Returns a list of all layers currently loaded in the project, including type-specific metadata: feature count and geometry type for vector layers, pixel dimensions for raster layers. ### Returns - A list of layer objects, each containing: - **id** (string) - The unique identifier for the layer. - **name** (string) - The display name of the layer. - **type** (string) - The type of the layer (e.g., 'vector_2', 'raster'). - **visible** (boolean) - Whether the layer is currently visible. - **feature_count** (integer) - (Vector layers only) The number of features. - **geometry_type** (integer) - (Vector layers only) The geometry type code. - **width** (integer) - (Raster layers only) The width of the raster in pixels. - **height** (integer) - (Raster layers only) The height of the raster in pixels. ``` -------------------------------- ### Send Raw Command via Socket Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Interacts directly with the QGIS plugin socket server using JSON protocol. This function sends a command type and parameters, then receives and parses the JSON response. Useful for low-level control or custom commands. ```python import socket import json def send_raw_command(command_type: str, params: dict = None, host='localhost', port=9876): """Send a raw command to the QGIS plugin socket server.""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((host, port)) command = {"type": command_type, "params": params or {}} sock.sendall(json.dumps(command).encode('utf-8')) response_data = b'' while True: chunk = sock.recv(4096) if not chunk: break response_data += chunk try: json.loads(response_data.decode('utf-8')) break # complete JSON received except json.JSONDecodeError: continue sock.close() return json.loads(response_data.decode('utf-8')) # Example: ping print(send_raw_command("ping")) # {"status": "success", "result": {"pong": true}} # Example: get layers print(send_raw_command("get_layers")) # Example: run processing print(send_raw_command("execute_processing", { "algorithm": "native:dissolve", "parameters": { "INPUT": "municipalities_a1b2c3", "FIELD": ["REGION"], "OUTPUT": "/home/user/data/regions.gpkg" } })) ``` -------------------------------- ### Execute Native Buffer Processing Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Applies a buffer operation to a vector layer using a native QGIS processing algorithm. Specify input layer, buffer distance, segments, end cap style, join style, miter limit, dissolve option, and output path. ```python buffer_result = client.execute_processing( algorithm="native:buffer", parameters={ "INPUT": "municipalities_a1b2c3", "DISTANCE": 1000, "SEGMENTS": 5, "END_CAP_STYLE": 0, "JOIN_STYLE": 0, "MITER_LIMIT": 2, "DISSOLVE": False, "OUTPUT": "/home/user/data/municipalities_buffer.gpkg" } ) print(buffer_result) ``` -------------------------------- ### Execute Arbitrary PyQGIS Code Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Executes a string of PyQGIS code within the QGIS environment, providing access to core QGIS classes. Stdout and stderr are captured. Use with caution due to its unrestricted nature. Handles both successful execution and errors. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() # Create a choropleth map using quantile classification on a population field code = """ from qgis.core import QgsGraduatedSymbolRenderer, QgsClassificationQuantile, QgsStyle layer = QgsProject.instance().mapLayersByName("Municipalities")[0] renderer = QgsGraduatedSymbolRenderer("POP2020") renderer.setClassificationMethod(QgsClassificationQuantile()) color_ramp = QgsStyle.defaultStyle().colorRamp("Spectral") renderer.updateColorRamp(color_ramp) renderer.updateClasses(layer, 5) layer.setRenderer(renderer) layer.triggerRepaint() print("Choropleth applied successfully") """ result = client.execute_code(code) # { # "status": "success", # "result": { # "executed": true, # "stdout": "Choropleth applied successfully\n", # "stderr": "" # } # } # Error case (bad code) bad_result = client.execute_code("raise ValueError('test error')") # { # "status": "success", # "result": { # "executed": false, # "error": "test error", # "traceback": "Traceback (most recent call last):\n ...", # "stdout": "", # "stderr": "" # } # } print(result) client.disconnect() ``` -------------------------------- ### add_raster_layer Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Loads a raster file into the QGIS project using a GDAL provider. Optionally assigns a custom display name. Returns the layer ID, name, and pixel dimensions. ```APIDOC ## Tool: `add_raster_layer` Loads a raster file (GeoTIFF, IMG, etc.) into the current project using a GDAL provider. Optionally assigns a custom display name. Returns the layer ID, name, and pixel dimensions. ### Parameters - **path** (string) - Required - The file path to the raster layer. - **name** (string) - Optional - A custom display name for the layer. - **provider** (string) - Optional - The GDAL data provider (defaults to 'gdal'). ### Returns - **id** (string) - The unique identifier for the newly added layer. - **name** (string) - The display name of the layer. - **type** (string) - The type of the layer (e.g., 'raster'). - **width** (integer) - The width of the raster in pixels. - **height** (integer) - The height of the raster in pixels. ``` -------------------------------- ### add_vector_layer Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Loads a vector file into the QGIS project. Supports various OGR-compatible formats and allows for a custom display name. Returns the new layer's ID, name, geometry type, and feature count. ```APIDOC ## Tool: `add_vector_layer` Loads a vector file (Shapefile, GeoJSON, GeoPackage, etc.) into the current project using a specified OGR-compatible provider. Optionally assigns a custom display name. Returns the new layer's ID, name, geometry type, and feature count. ### Parameters - **path** (string) - Required - The file path to the vector layer. - **name** (string) - Optional - A custom display name for the layer. - **provider** (string) - Optional - The OGR data provider (defaults to 'ogr'). ### Returns - **id** (string) - The unique identifier for the newly added layer. - **name** (string) - The display name of the layer. - **type** (string) - The type of the layer (e.g., 'vector_2'). - **feature_count** (integer) - The number of features in the layer. ``` -------------------------------- ### Zoom to Layer Extent Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Activates a specified layer and adjusts the QGIS map canvas to fit its entire extent. This is useful for ensuring the desired area is visible before map rendering. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() project_info = client.get_project_info() first_layer_id = project_info["result"]["layers"][0]["id"] result = client.zoom_to_layer(first_layer_id) # {"status": "success", "result": {"zoomed_to": "municipalities_a1b2c3"}} print(result) client.disconnect() ``` -------------------------------- ### zoom_to_layer Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Sets a specified layer as active and zooms the QGIS map canvas to fit its extent. This is useful for ensuring a specific area is visible. ```APIDOC ## Tool: `zoom_to_layer` Sets the specified layer as active and zooms the QGIS map canvas to fit its full extent. Useful before rendering a map to ensure the desired area is in view. ### Parameters - **layer_id** (string) - Required - The ID of the layer to zoom to. ``` -------------------------------- ### get_layer_features Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Retrieves features from a vector layer, including attribute values and WKT geometry. The `limit` parameter controls the maximum number of features returned. ```APIDOC ## Tool: `get_layer_features` Retrieves features from a vector layer, including their attribute values and WKT geometry representations. The `limit` parameter caps the number of features returned (default 10) to prevent large responses. ### Parameters - **layer_id** (string) - Required - The ID of the vector layer. - **limit** (integer) - Optional - The maximum number of features to return (defaults to 10). ### Returns - **layer_id** (string) - The ID of the layer from which features were retrieved. - **feature_count** (integer) - The total number of features in the layer. - **fields** (list of strings) - A list of field names in the layer. - **features** (list of objects) - A list of feature objects, each containing: - **id** (integer) - The feature's ID. - **attributes** (object) - Key-value pairs of the feature's attributes. - **geometry** (object) - The feature's geometry, including type and WKT representation. ``` -------------------------------- ### Remove Layer by ID Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Removes a layer from the QGIS project using its unique layer ID. Ensure the layer ID exists; otherwise, an error will be raised. ```python client = QgisMCPClient(host='localhost', port=9876) client.connect() result = client.remove_layer("dem_d4e5f6") # {"status": "success", "result": {"removed": "dem_d4e5f6"}} # Error case: # {"status": "error", "message": "Layer not found: dem_d4e5f6"} print(result) client.disconnect() ``` -------------------------------- ### remove_layer Source: https://context7.com/jjsantos01/qgis_mcp/llms.txt Removes a specified layer from the QGIS project using its layer ID. An error is raised if the layer ID is not found. ```APIDOC ## Tool: `remove_layer` Removes a layer from the project by its layer ID (obtainable from `get_layers` or `get_project_info`). Raises an error if the layer ID is not found. ### Parameters - **layer_id** (string) - Required - The ID of the layer to remove. ### Returns - **removed** (string) - The ID of the layer that was successfully removed. ### Errors - If the layer ID is not found, an error message is returned. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.