Skip to main content
Glama

get_length

Calculate the length of a geometric feature using the GIS MCP Server. Input a geometry string to perform accurate spatial measurements for geospatial analysis.

Instructions

Get the length of a geometry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometryYes

Implementation Reference

  • The primary handler function for the 'get_length' tool. It takes a WKT geometry string, loads it with Shapely, computes the length, and returns a dictionary with the result.
    @gis_mcp.tool() def get_length(geometry: str) -> Dict[str, Any]: """Get the length of a geometry.""" try: from shapely import wkt geom = wkt.loads(geometry) return { "status": "success", "length": float(geom.length), "message": "Length calculated successfully" } except Exception as e: logger.error(f"Error calculating length: {str(e)}") raise ValueError(f"Failed to calculate length: {str(e)}")
  • The @gis_mcp.tool() decorator registers this function as an MCP tool named 'get_length'. The function signature provides the input schema.
    @gis_mcp.tool() def get_length(geometry: str) -> Dict[str, Any]: """Get the length of a geometry.""" try: from shapely import wkt geom = wkt.loads(geometry) return { "status": "success", "length": float(geom.length), "message": "Length calculated successfully" } except Exception as e: logger.error(f"Error calculating length: {str(e)}") raise ValueError(f"Failed to calculate length: {str(e)}")
  • A resource endpoint that lists available measurement operations, including 'get_length', to inform clients of available tools.
    @gis_mcp.resource("gis://operations/measurements") def get_measurements() -> Dict[str, List[str]]: """List available measurement operations.""" return { "operations": [ "get_length", "get_area" ] }

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