Skip to main content
Glama

get_bounds

Calculate the bounding coordinates of a geographic shape to define its spatial extent for mapping and analysis.

Instructions

Get the bounds of a geometry.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geometryYes

Implementation Reference

  • The handler function for the 'get_bounds' tool. It parses a WKT geometry string using Shapely, computes the bounds (minx, miny, maxx, maxy), and returns them as a list in a success dictionary.
    @gis_mcp.tool()
    def get_bounds(geometry: str) -> Dict[str, Any]:
        """Get the bounds of a geometry."""
        try:
            from shapely import wkt
            geom = wkt.loads(geometry)
            return {
                "status": "success",
                "bounds": list(geom.bounds),
                "message": "Bounds calculated successfully"
            }
        except Exception as e:
            logger.error(f"Error calculating bounds: {str(e)}")
            raise ValueError(f"Failed to calculate bounds: {str(e)}")
  • Imports the shapely_functions module in the main entry point, triggering the @gis_mcp.tool() decorators to register the get_bounds tool with the FastMCP instance.
    from . import (
        geopandas_functions,
        shapely_functions,
        rasterio_functions,
        pyproj_functions,
        pysal_functions,
    )

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