query
Run a single read-only SELECT query against accessible PostGIS datasets in a sandboxed SQL environment to retrieve filtered rows, spatial calculations, and custom summaries.
Instructions
Run one read-only SQL SELECT against accessible datasets.
Executes through the server's hardened SQL sandbox: a single SELECT over
data.* tables, an allowlisted function set (aggregates, math, string,
date, JSON), and a strict server-side budget (a 5 s statement timeout, a
repetition cap on self-joins, and row_limit rows, at most 1000).
For counts, statistics, histograms and group-by summaries prefer
aggregate, which needs no SQL. Returns {columns, rows, row_count, truncated} with rows as lists in
column order. Geometry columns come back as hex EWKB; select
ST_AsText(geom) or ST_AsGeoJSON(geom) for readable geometry.
ST_AsGeoJSON(geom, 6) rounds coordinates to six decimals, which suits
display but can make a small polygon invalid.
PostGIS functions allowed: ST_Area, ST_AsGeoJSON, ST_AsText, ST_Buffer,
ST_Centroid, ST_Collect, ST_Contains, ST_Distance, ST_DWithin,
ST_GeometryType, ST_GeomFromGeoJSON, ST_GeomFromText, ST_Intersects,
ST_IsValid, ST_Length, ST_MakeEnvelope, ST_MakePoint, ST_NPoints, ST_Point,
ST_SetSRID, ST_Transform, ST_Union, ST_Within, ST_X, ST_Y. ST_Collect and
ST_Union take two geometries (no aggregate form). The && bounding-box
operator works, as do ::geography / ::geometry and geography(geom).
Requires credentials with AI-chat permission — anonymous configurations
cannot use this tool. Workflow: search_datasets to find a dataset, then
get_dataset_schema for its table_name and columns, then reference it
as data.<table_name> in the SQL and list the same table_name in
restrict_tables. Every table the query touches must be listed there;
the scope can only narrow what your credentials already see. Writes,
other schemas, and unlisted functions are rejected with a short reason
that names the refused function.
Args:
sql: A single SELECT statement over data.* tables.
restrict_tables: Table names (no data. prefix) the query may touch.
Required and non-empty.
row_limit: Max rows to return (1-1000, default 100).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sql": "<sql>",
"restrict_tables": "<restrict_tables>"
},
"name": "query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| row_limit | No | ||
| restrict_tables | Yes |