Skip to main content
Glama

dissolve_gpd

Dissolve geospatial geometries by attribute to simplify vector data, reducing complexity by merging features with matching values in a specified column.

Instructions

Dissolve geometries by attribute using geopandas.dissolve. Args: gdf_path: Path to the geospatial file. by: Column to dissolve by (optional). output_path: Optional path to save the result. Returns: Dictionary with status, message, and output info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gdf_pathYes
byNo
output_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'dissolve_gpd' MCP tool, decorated with @gis_mcp.tool(). It reads a GeoDataFrame, dissolves geometries by the specified attribute, optionally saves to output_path, and returns stats and preview.
    @gis_mcp.tool()
    def dissolve_gpd(gdf_path: str, by: str = None, output_path: str = None) -> Dict[str, Any]:
        """
        Dissolve geometries by attribute using geopandas.dissolve.
        Args:
            gdf_path: Path to the geospatial file.
            by: Column to dissolve by (optional).
            output_path: Optional path to save the result.
        Returns:
            Dictionary with status, message, and output info.
        """
        try:
            gdf = gpd.read_file(gdf_path)
            result = gdf.dissolve(by=by)
            if output_path:
                output_path_resolved = resolve_path(output_path, relative_to_storage=True)
                output_path_resolved.parent.mkdir(parents=True, exist_ok=True)
                result.to_file(str(output_path_resolved))
                output_path = str(output_path_resolved)
            # Convert geometry to WKT for serialization
            preview_df = result.head(5).copy()
            if 'geometry' in preview_df.columns:
                preview_df['geometry'] = preview_df['geometry'].apply(lambda g: g.wkt if g is not None else None)
            preview = preview_df.to_dict(orient="records")
            return {
                "status": "success",
                "message": f"Dissolve completed successfully.",
                "num_features": len(result),
                "crs": str(result.crs),
                "columns": list(result.columns),
                "preview": preview,
                "output_path": output_path,
            }
        except Exception as e:
            logger.error(f"Error in dissolve_gpd: {str(e)}")
            return {"status": "error", "message": str(e)}
  • Resource listing that includes 'dissolve_gpd' as an available GeoPandas operation.
    @gis_mcp.resource("gis://geopandas/io")
    def get_geopandas_io() -> Dict[str, List[str]]:
        """List available GeoPandas I/O operations."""
        return {
            "operations": [
                "read_file_gpd",
                "to_file_gpd",
                "overlay_gpd",
                "dissolve_gpd",
                "explode_gpd",
                "clip_vector",
                "write_file_gpd"
            ]
        }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool 'dissolves geometries' but doesn't specify whether this is a read-only or destructive operation, what permissions are needed, or any side effects like file modifications. The return format is briefly noted, but key behavioral traits like error handling or performance implications are missing.

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

Conciseness4/5

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

The description is well-structured and front-loaded with the core purpose, followed by parameter and return details in a clear format. It's concise with no wasted sentences, though the parameter explanations could be slightly more detailed without sacrificing brevity.

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?

Given the complexity (a geospatial operation with 3 parameters), no annotations, and an output schema present (which covers return values), the description is moderately complete. It explains the tool's purpose and parameters but lacks behavioral context and usage guidelines. The output schema reduces the need to detail returns, but overall completeness is adequate with clear gaps.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It lists the parameters (gdf_path, by, output_path) and adds some semantics: gdf_path is a 'Path to the geospatial file,' by is a 'Column to dissolve by (optional),' and output_path is an 'Optional path to save the result.' This provides basic meaning beyond the schema's types, but it doesn't detail formats (e.g., file types for gdf_path) or constraints, leaving gaps.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Dissolve geometries by attribute using geopandas.dissolve.' It specifies the verb ('dissolve'), resource ('geometries'), and method ('by attribute'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'merge_gpd' or 'union', which might have overlapping functionality, preventing a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'using geopandas.dissolve' but doesn't explain the context, prerequisites, or compare it to siblings like 'merge_gpd' or 'union' in the list. This lack of usage context leaves the agent with minimal direction.

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

Install Server

Other Tools

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/mahdin75/gis-mcp'

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