Execute a raw Overpass QL query
openstreetmap_query_rawRun an arbitrary Overpass QL query for anything the convenience tools cannot express: multi-type or union queries, relation membership, historical queries, regex tag matching. The query must include [out:json], e.g. "[out:json][timeout:15];node"natural"="peak";out body;"; scope to an OSM boundary with rel();map_to_area->.a; or way();map_to_area->.a; then (area.a) on each statement (the 2400000000 way-area offset is gone since Overpass 0.7.57; openstreetmap_query_bbox takes the same scope as within, without QL). The response is one page: page with limit and offset, and read totalFound and truncated for the whole match. Every element arrives whole unless max_element_bytes is set; an element over it then has its members, nodes or geometry withheld whole, and withheldNotice says how to fetch it back. For plain "near X" or "in this area" questions use openstreetmap_query_nearby or openstreetmap_query_bbox.
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": {
"query": "<query>"
},
"name": "openstreetmap_query_raw"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum elements to return, up to 500 per call; a larger value is served as 500 and limitNotice says so. Applied after the Overpass query — if the query matched more, they are truncated. | |
| query | Yes | Overpass QL query string. Must include [out:json]. The server sets the endpoint and User-Agent; do not include those. With no [maxsize:N] it adds [maxsize:268435456] (256 MiB), which a busy endpoint admits sooner than its 512 MiB default; write your own to change it. Example: "[out:json][timeout:15];node[\"natural\"=\"peak\"](47.5,-122.5,47.7,-122.2);out body;" | |
| offset | No | Elements to skip before applying limit, for paging a large result set. The full match set is cached ~10 minutes keyed by the query, so re-paging at a new offset is deterministic and costs no extra request; a result over 100000 elements or 25 MiB is served uncached, so paging it re-queries and depends on the endpoint returning the same order. Pass the nextOffset from a prior truncated response. | |
| timeout_seconds | No | How long Overpass may spend on the query. A [timeout:N] directive in the query string wins over this. The client waits the full value rather than cutting a long query off early, but the endpoint enforces its own budget and may answer HTTP 504 first. | |
| max_element_bytes | No | Serialized-byte budget for one element, in UTF-8 bytes, applied per element after limit and offset — the dimension limit cannot bound, a single relation or geometry-heavy way. Omitted, every element arrives whole. An over-budget element keeps every scalar and its tags but has its members, nodes and geometry withheld whole, never truncated to a prefix, and lists each under withheld_keys with its item count and byte size; withheldNotice then names the budget that returns the whole page and the offset and budget that fetch each of the first three withheld elements alone; withheldElements carries them for every one. That disclosure is not counted against the budget, so a bounded element runs ~60 bytes per withheld key above it. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Present when the call failed. Absent on success. | |
| notice | No | Why this page is empty and what to try: nothing matched (check the query filters and bounds), or offset ran past the end (retry lower). Absent when results were returned. | |
| elements | No | Raw Overpass elements for this page, up to the limit. Shape varies by type: nodes carry lat/lon, ways nodes[], relations members[]. An element over max_element_bytes swaps its members, nodes, or geometry for withheld_keys, each naming the key, its item count, and its byte size. | |
| truncated | No | True if elements were cut at the limit. Narrow the query, or page with offset to retrieve the rest. | |
| nextOffset | No | Offset to pass on the next call to retrieve the following page of elements. Present only when more elements remain beyond this page. | |
| totalFound | No | Total elements returned by Overpass before limit truncation. | |
| attribution | No | Required data attribution: Data © OpenStreetMap contributors, ODbL 1.0. | |
| limitNotice | No | Present when limit exceeded this tool's maximum: the value requested and the one applied. | |
| data_timestamp | No | OSM data freshness timestamp from the Overpass response. Absent when the endpoint reported no freshness metadata. | |
| effectiveQuery | No | The Overpass QL string as sent to the API (after any timeout or maxsize injection). | |
| total_elements | No | Number of elements returned on this page. See totalFound for the full match count. | |
| withheldNotice | No | The max_element_bytes that returns this page whole, then how to fetch each withheld element alone. Absent when nothing was withheld. | |
| servingEndpoint | No | Overpass endpoint that answered, named by origin alone (scheme, host, port), with "(entry N)" added when two configured endpoints share an origin. May name a failover mirror, or the endpoint that originally served a cached response. Read with data_timestamp when a result looks slow, sparse, or stale. | |
| withheldElements | No | Elements on this page that exceeded max_element_bytes, each with the arguments that fetch it back whole. Absent when nothing was withheld. |