Skip to main content
Glama
geolens-mcp

geolens-mcp

Official

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

NameRequiredDescriptionDefault
sqlYes
row_limitNo
restrict_tablesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.25.1
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / row_limit / maximum
      Added value: +1000
    • addedInput schema / properties / row_limit / minimum
      Added value: +1
  2. First observedv0.1.0

TDQS

A4.6/5.0
Behavior4/5

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

No annotations exist, so the description carries the full burden, and it delivers substantive behavior: a hardened sandbox, a 5 s statement timeout, a self-join repetition cap, a 1000-row ceiling, and an allowlisted function set. It also discloses the auth prerequisite (AI-chat permission, anonymous configs excluded) and failure behavior (short reason naming the refused function). The exact return shape ({columns, rows, row_count, truncated}) and the geometry hex-EWKB caveat are stated as well, leaving only minor gaps such as how truncation interacts with row_limit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core guidance is front-loaded and the workflow section is well ordered, but the definition is long. The 25-function PostGIS allowlist is a bulky enumeration that consumes several lines, and the ST_AsGeoJSON rounding detail (with its invalid-polygon caveat) is a niche nuance placed mid-paragraph where it interrupts the main usage flow.

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

Completeness5/5

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

There is no output schema, so the description supplies the return shape itself, plus geometry encoding and the readable-geometry workaround. Combined with the auth requirement, sandbox limits, workflow, and parameter rules, an agent has everything needed to call this correctly on the first attempt.

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

Parameters5/5

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

Schema coverage is 0%, yet every parameter is given meaning the schema cannot express: `sql` must be a single SELECT over `data.*`; `restrict_tables` takes bare table names without the `data.` prefix, is required and non-empty, must list every table the query touches, and can only narrow existing credential scope; `row_limit` is bounded 1-1000 with a default of 100.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb and resource: run one read-only SQL SELECT against accessible datasets. It immediately distinguishes itself from the sibling `aggregate` by naming it and stating the condition (counts, statistics, histograms, group-by) where `aggregate` is preferred.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit three-step workflow (search_datasets → get_dataset_schema → query) and explains that the dataset's `table_name` must be referenced as `data.<table_name>` and repeated in `restrict_tables`. It also states the negative case: writes, other schemas, and unlisted functions are rejected, with the sibling `aggregate` offered for cases that need no SQL.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.