Geometry primitivesFree tier

geometry_validate

Validate a WKT geometry. Returns is_valid, reason (if invalid), geometry type, and number of sub-geometries. If invalid, also returns fixed_wkt from ST_MakeValid. Pre-flight check for LLM-generated WKT — common failure modes: self-intersecting polygons, ring-ordering issues, duplicate vertices.

Use cases

  • Pre-flight a polygon generated by an LLM before passing it to points_in_polygon.
  • Auto-repair self-intersecting WKT with fixed_wkt.
  • Surface clear validation errors back to the user instead of cryptic PostGIS messages.

Arguments

NameTypeRequiredDescription
geom_wkt string required WKT to validate.
srid integer optional Coordinate system.
Allowlist as in geometry_ops. Default 4326.

Example request

curl
bash
curl -X POST https://mcp.qubitdata.it/mcp \
  -H "Authorization: Bearer $QUBITDATA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "geometry_validate",
      "arguments": {
            "geom_wkt": "POLYGON((0 0, 1 1, 1 0, 0 1, 0 0))"
      }
    }
  }'

Example response

JSON-RPC 2.0 result
json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "content": [
      {
        "type": "text",
        "text": "{\n  \"is_valid\": false,\n  \"reason\": \"Self-intersection\",\n  \"type\": \"Polygon\",\n  \"num_geometries\": 1,\n  \"fixed_wkt\": \"MULTIPOLYGON(((0 0, 0.5 0.5, 1 0, 0 0)),((0.5 0.5, 1 1, 0 1, 0.5 0.5)))\"\n}"
      }
    ]
  }
}

Prompts to try

Drop these into Claude Desktop, Cursor, or any MCP-aware client wired to https://mcp.qubitdata.it/mcp.

  • Claude Desktop
    Is this WKT polygon valid? If not, return the fixed version.
  • Cursor
    Validate every WKT in my batch; replace invalid ones with the fixed_wkt.
  • Custom MCP client
    Pre-flight LLM-generated geometry before downstream calls.

Related tools

geometry_ops · coordinate_transform

Get started

Sign up for a free key to call this tool from your agent. Need a wider geo cap or higher quota? See pricing.

Last updated: