Skip to main content
Glama

read_file_gpd

Read geospatial files to extract statistics and preview data for analysis in GIS workflows.

Instructions

Reads a geospatial file and returns stats and a data preview.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'read_file_gpd' tool. It uses geopandas.read_file to load the geospatial file, computes summary statistics, creates a preview with geometry converted to WKT for JSON serialization, and returns a structured dictionary or error response.
    @gis_mcp.tool()
    def read_file_gpd(file_path: str) -> Dict[str, Any]:
        """Reads a geospatial file and returns stats and a data preview."""
        try:
            if not os.path.exists(file_path):
                raise FileNotFoundError(f"File not found: {file_path}")
    
            gdf = gpd.read_file(file_path)
            # Convert geometry to WKT for serialization
            preview_df = gdf.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",
                "columns": list(gdf.columns),
                "column_types": gdf.dtypes.astype(str).to_dict(),
                "num_rows": len(gdf),
                "num_columns": gdf.shape[1],
                "crs": str(gdf.crs),
                "bounds": gdf.total_bounds.tolist(),  # [minx, miny, maxx, maxy]
                "preview": preview,
                "message": f"File loaded successfully with {len(gdf)} rows and {gdf.shape[1]} columns"
            }
    
        except Exception as e:
            logger.error(f"Error reading file: {str(e)}")
            return {
                "status": "error",
                "message": f"Failed to read file: {str(e)}"
            }
  • Import of the geopandas_functions module in the main entry point, which executes the module-level decorators (@gis_mcp.tool()) to register the 'read_file_gpd' tool with the FastMCP server instance.
    # Import tool modules to register MCP tools via decorators
    from . import (
        geopandas_functions,
        shapely_functions,
        rasterio_functions,
        pyproj_functions,
        pysal_functions,
    )
  • src/gis_mcp/mcp.py:5-5 (registration)
    Definition of the FastMCP server instance 'gis_mcp' that provides the @tool() and @resource() decorators used to register the 'read_file_gpd' tool.
    gis_mcp = FastMCP("GIS MCP")
  • MCP resource that lists 'read_file_gpd' as one of the available GeoPandas I/O operations, serving as a tool discovery/schema endpoint.
    @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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions reading and returning data, but fails to specify critical details like supported file formats (e.g., Shapefile, GeoJSON), error handling for invalid files, performance implications for large files, or whether it loads the entire file into memory. This leaves significant gaps for an agent to understand operational risks.

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?

The description is a single, efficient sentence that front-loads the core action and outcome without unnecessary words. Every part ('Reads a geospatial file and returns stats and a data preview') contributes directly to understanding the tool's function, making it optimally concise for its purpose.

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 tool's moderate complexity (reading geospatial files) and the presence of an output schema (which should cover return values), the description is minimally adequate. However, with no annotations and low schema coverage, it lacks details on behavioral aspects like file handling and errors, making it incomplete for safe and effective use without additional context from the server.

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?

The schema has 0% description coverage, with only one parameter 'file_path' documented structurally. The description adds no specific meaning about this parameter, such as expected path formats, relative vs. absolute paths, or file system access rules. Since there's only one parameter, the baseline is 4, but the lack of any semantic clarification reduces it to 3, as the agent must infer usage from context alone.

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 action ('Reads a geospatial file') and the outcome ('returns stats and a data preview'), which distinguishes it from siblings like 'write_file_gpd' that perform writes. However, it doesn't specify the exact nature of the stats or preview, leaving some ambiguity compared to more detailed geospatial tools in the list.

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, such as 'metadata_raster' for raster files or other geospatial processing tools. It lacks context about prerequisites (e.g., file format support) or exclusions, making it unclear in the crowded sibling toolset.

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