Skip to main content
Glama

Gfw Query

gfw_query
Read-onlyIdempotent

Run a read-only SQL SELECT against one Global Forest Watch dataset version, e.g. tree cover loss hectares by year inside an area, or deforestation alerts inside a bounding box. The table is always called data; use gfw_dataset to see the available columns first. Almost every GFW dataset (tree cover loss/gain, GLAD/RADD alerts, fire alerts, carbon, primary forest) is a RASTER TILE SET, not a plain table, a geometry (GeoJSON Polygon/MultiPolygon) is REQUIRED to scope the pixels queried, or the API answers 422 "Raster tile set queries require a geometry". Omit it only for the few vector-table datasets (e.g. wdpa_protected_areas). Requires your own free GFW API key, passed as _apiKey.

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "sql": "SELECT umd_tree_cover_loss__year, SUM(area__ha) AS loss_ha FROM data WHERE umd_tree_cover_loss__year = 2023 GROUP BY umd_tree_cover_loss__year",
      "dataset": "umd_tree_cover_loss",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -63,
              -9
            ],
            [
              -62.8,
              -9
            ],
            [
              -62.8,
              -8.8
            ],
            [
              -63,
              -8.8
            ],
            [
              -63,
              -9
            ]
          ]
        ]
      }
    },
    "name": "gfw_query"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesA SELECT statement over the table `data`, e.g. "SELECT umd_tree_cover_loss__year, SUM(area__ha) AS loss_ha FROM data WHERE umd_tree_cover_loss__year > 0 GROUP BY umd_tree_cover_loss__year". SELECT only; a LIMIT is appended if you omit one.
limitNoRow cap appended when your SQL has no LIMIT (1-1000, default 100).
_apiKeyYesYour own Global Forest Watch API key (BYO). Get one free at globalforestwatch.org: create an account, then POST /auth/token followed by POST /auth/apikey on data-api.globalforestwatch.org to mint an x-api-key.
datasetYesDataset name, e.g. "umd_tree_cover_loss".
versionNoVersion, e.g. "latest" or "v1.13". Default "latest".
geometryNoGeoJSON Polygon or MultiPolygon ({"type":"Polygon","coordinates":[...]}) scoping the query spatially. REQUIRED for raster tile set datasets, which is most of them; see gfw_dataset's version_assets. Example, a ~0.2° box over Rondônia, Brazil: {"type":"Polygon","coordinates":[[[-63.0,-9.0],[-62.8,-9.0],[-62.8,-8.8],[-63.0,-8.8],[-63.0,-9.0]]]}.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / geometry / description
      Previous value: -"GeoJSON Polygon or MultiPolygon ({\"type\":\"Polygon\",\"coordinates\":[...]}) scoping the query spatially. REQUIRED for raster tile set datasets — which is most of them; see gfw_dataset's version_assets. Example, a ~0.2° box over Rondônia, Brazil: {\"type\":\"Polygon\",\"coordinates\":[[[-63.0,-9.0],[-62.8,-9.0],[-62.8,-8.8],[-63.0,-8.8],[-63.0,-9.0]]]}."New value: +"GeoJSON Polygon or MultiPolygon ({\"type\":\"Polygon\",\"coordinates\":[...]}) scoping the query spatially. REQUIRED for raster tile set datasets, which is most of them; see gfw_dataset's version_assets. Example, a ~0.2° box over Rondônia, Brazil: {\"type\":\"Polygon\",\"coordinates\":[[[-63.0,-9.0],[-62.8,-9.0],[-62.8,-8.8],[-63.0,-8.8],[-63.0,-9.0]]]}."
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the readOnly/idempotent annotations, the description discloses the auth model (BYO free GFW API key passed as _apiKey), the raster-tile-set constraint that most datasets impose, the concrete 422 error string, and the implicit row cap behavior. These are exactly the operational traits an agent needs and that annotations alone do not convey.

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

Conciseness4/5

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

Front-loaded with the core action and use cases, then escalates to the geometry gotcha and auth requirement in descending priority. It is a dense single paragraph with mild redundancy around the raster/geometry rule, but no sentence is throwaway.

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?

For a 6-parameter tool with a nested GeoJSON object and no output schema, the description covers auth, the fixed table name, spatial scoping, dataset/version selection, and the row cap — everything needed to call it correctly. Return shape is not described, but SQL results are self-describing and no output schema exists to defer to.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline would be 3; the description earns above that by stating the fixed table name `data` (a fact absent from the sql schema description and essential to writing a valid query) and by reiterating the geometry-required rule in the context of dataset type. It does not add much on version or limit beyond the schema.

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+resource ('Run a read-only SQL SELECT against one Global Forest Watch dataset version') and immediately grounds it with two concrete use cases (tree cover loss hectares by year, deforestation alerts in a bounding box). It is clearly distinguishable from the sibling gfw_dataset, which is named as the schema-inspection step.

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?

Explicitly routes the agent: call gfw_dataset first to see columns, and omit geometry only for the few vector-table datasets such as wdpa_protected_areas. It names the alternative tool and the condition that selects it, plus the exact failure mode (422) if geometry is missing.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.