make_valid
Ensure geometry validity for accurate geospatial analysis. Fix invalid geometries to enable precise GIS operations and spatial measurements using the GIS MCP Server.
Instructions
Make a geometry valid.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:452-466 (handler)The handler function decorated with @gis_mcp.tool() that implements the make_valid tool. It parses WKT input, calls Shapely's make_valid method, and returns the result as WKT.@gis_mcp.tool() def make_valid(geometry: str) -> Dict[str, Any]: """Make a geometry valid.""" try: from shapely import wkt geom = wkt.loads(geometry) result = geom.make_valid() return { "status": "success", "geometry": result.wkt, "message": "Geometry made valid successfully" } except Exception as e: logger.error(f"Error making geometry valid: {str(e)}") raise ValueError(f"Failed to make geometry valid: {str(e)}")
- src/gis_mcp/shapely_functions.py:71-81 (registration)Resource endpoint that lists 'make_valid' among available validation operations, serving as tool discovery/registration.@gis_mcp.resource("gis://operations/validation") def get_validation_operations() -> Dict[str, List[str]]: """List available validation operations.""" return { "operations": [ "is_valid", "make_valid", "simplify" ] }