Skip to main content
Glama

geojson_to_geometry

Convert GeoJSON data to Shapely geometry for geospatial analysis in GIS applications, returning geometry as WKT format.

Instructions

Convert GeoJSON to a Shapely geometry using shapely.geometry.shape. Args: geojson: GeoJSON dictionary. Returns: Dictionary with status, message, and geometry as WKT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geojsonYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'geojson_to_geometry' tool, decorated with @gis_mcp.tool(). It converts a GeoJSON dictionary to a Shapely geometry and returns it as WKT string.
    @gis_mcp.tool()
    def geojson_to_geometry(geojson: Dict[str, Any]) -> Dict[str, Any]:
        """
        Convert GeoJSON to a Shapely geometry using shapely.geometry.shape.
        Args:
            geojson: GeoJSON dictionary.
        Returns:
            Dictionary with status, message, and geometry as WKT.
        """
        try:
            from shapely.geometry import shape
            geom = shape(geojson)
            return {
                "status": "success",
                "geometry": geom.wkt,
                "message": "GeoJSON converted to geometry successfully"
            }
        except Exception as e:
            logger.error(f"Error in geojson_to_geometry: {str(e)}")
            return {"status": "error", "message": str(e)}
  • Resource listing that includes 'geojson_to_geometry' as one of the available Shapely utility operations.
    @gis_mcp.resource("gis://operations/shapely_util")
    def get_shapely_util_operations() -> Dict[str, List[str]]:
        """List available Shapely utility/advanced operations."""
        return {
            "operations": [
                "snap_geometry",
                "nearest_point_on_geometry",
                "normalize_geometry",
                "geometry_to_geojson",
                "geojson_to_geometry"
            ]
        }
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. It mentions the conversion process and return format, but does not disclose behavioral traits such as error handling (e.g., invalid GeoJSON), performance considerations, or dependencies on the shapely library. The description is functional but lacks depth on operational context.

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 front-loaded with the core purpose in the first sentence, followed by structured 'Args' and 'Returns' sections that efficiently document inputs and outputs without unnecessary details. Every sentence adds value, and the format is clear and well-organized.

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

Completeness4/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 (1 parameter, no annotations, but with an output schema), the description is reasonably complete: it explains the conversion purpose, parameter semantics, and return format. The presence of an output schema reduces the need to detail return values, though additional behavioral context would enhance completeness.

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?

With 0% schema description coverage, the description compensates by clearly defining the single parameter 'geojson' as a 'GeoJSON dictionary', adding essential meaning beyond the schema's generic 'object' type. It effectively explains the parameter's purpose and format, though it could provide more details on valid GeoJSON structures.

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 specific action ('Convert GeoJSON to a Shapely geometry') and the method used ('using shapely.geometry.shape'), which distinguishes it from sibling tools like 'geometry_to_geojson' that perform the inverse operation. It explicitly names both the input format (GeoJSON) and output format (Shapely geometry/WKT), making the purpose unambiguous.

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

Usage Guidelines3/5

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

The description implies usage by specifying the input format (GeoJSON dictionary) and output (geometry as WKT), but does not explicitly state when to use this tool versus alternatives like 'geometry_to_geojson' for the reverse conversion. It provides basic context but lacks explicit guidance on prerequisites or exclusions.

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