Skip to main content
Glama

get_length

Calculate geometry length for spatial measurements in GIS analysis. Input a geometry string to get accurate length results.

Instructions

Get the length of a geometry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometryYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the get_length tool logic, using Shapely to compute the length of a WKT geometry and return it in a standardized dict format. The @gis_mcp.tool() decorator registers it as an MCP tool.
    @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)}")
  • Resource handler that lists 'get_length' among available measurement operations for discovery.
    @gis_mcp.resource("gis://operations/measurements")
    def get_measurements() -> Dict[str, List[str]]:
        """List available measurement operations."""
        return {
            "operations": [
                "get_length",
                "get_area"
            ]
        }
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description only states what the tool does ('Get the length') without explaining what 'length' means in this context (e.g., linear distance, perimeter), what units are returned, whether this works for all geometry types, or what happens with invalid geometries. For a tool with zero annotation coverage, this is inadequate.

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 extremely concise at just 6 words, with no wasted language. It's front-loaded with the core purpose immediately clear. Every word earns its place, making it efficient for an AI agent to parse while still conveying the basic function.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there's an output schema (which should document return values), the description doesn't need to explain return format. However, with zero annotation coverage, 0% schema description coverage, and many sibling tools in a geospatial context, the description should provide more context about what 'length' means, what geometry formats are accepted, and when to use this versus alternatives. The current description is insufficient for a tool in this complex domain.

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

Parameters2/5

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

Schema description coverage is 0%, meaning the single parameter 'geometry' has no documentation in the schema. The description adds minimal value by implying the parameter should be a geometry, but doesn't explain what format 'geometry' should be in (e.g., GeoJSON string, WKT, geometry object), what coordinate reference system is assumed, or what validation occurs. With 0% schema coverage, the description should compensate more substantially.

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 verb ('Get') and resource ('length of a geometry'), making the purpose immediately understandable. It distinguishes from siblings like 'get_area' or 'get_bounds' by specifying length rather than area or bounds. However, it doesn't explicitly differentiate from potential similar tools like 'calculate_geodetic_distance' which might also involve length measurements.

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. With many sibling tools like 'get_area', 'calculate_geodetic_distance', and 'get_bounds', there's no indication of when length measurement is appropriate versus area, distance, or bounds calculations. The description lacks any context about use cases or prerequisites.

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