jmespath string argument. The server applies the expression after any per-tool filter and summary args, then projects the response before serialisation. A well-chosen projection typically cuts payload size by 80–95% — the single most effective lever you have for keeping a long agent loop inside its context window.
This page is the practical reference: a quick orientation, then twelve worked examples against three real captured tool responses. For the grammar itself, lean on the spec — jmespath.org/specification.html. Coming back here is faster than re-reading the spec.
Quick orientation
-
Every tool advertises
jmespathin its input schema, so you never have to check first. The expression root is the full response envelope —{ cached_at, stale, data: { … } }for cache tools — so most expressions start withdata.<key>to reach the payload, andcached_at/staleare addressable from the same root when you want them. -
Hyphenated keys must be quoted with double quotes. Most WorldMonitor tools have hyphenated cache keys (
stocks-bootstrap,ucdp-events,etf-flows,fear-greed,transit-summaries). Usedata."stocks-bootstrap".quotes[*].symbol, notdata.stocks-bootstrap.…. -
Numbers and JSON literals go in backticks, strings in single quotes.
[?deathsBest > \5`](numeric),[?country == ‘Iraq’]` (string). Mixing them up silently parses the value as something else. -
Server-side limits keep edge functions healthy:
- Expression itself: ≤ 1024 bytes.
- Projected output: ≤ 256 KB.
- Evaluation is checked before search. Expressions allow at most 128 AST nodes, 32 levels of AST nesting, eight pipe stages, and eight multiselects. The product of all multiselect widths and literal container widths must not exceed 64, including independent branches. An array’s width is its length; an object’s width is its number of keys. Empty containers count as one. These limits also cover repeated evaluation in maps and projections.
to_string()is unavailable. Equality and inequality require at least one scalar literal operand, such ascountry == 'Iraq'.join()requires a literal string separator, such asjoin(', ', names).map(),sort_by(),min_by(), andmax_by()require explicit&expressionreferences, such asmap(&name, rows); data objects and computed references are rejected.
{ _jmespath_error, original_keys, ... }inside the normal result envelope — the tool call still succeeds at the JSON-RPC layer (noisError: true), andoriginal_keysechoes the top-level keys of the unprojected response so the model can self-correct on the next call. -
A projection appears in two places.
result.content[0].textnormally holds the raw projected JSON.result.structuredContentcarries it underprojection. Attribution, coverage, and deprecation metadata can change these envelopes. See MCP result channels.
tests/fixtures/jmespath-samples/ (re-captured periodically against the prod MCP endpoint). They were picked deliberately — fat (~100 KB with limit: 0), medium (~30 KB), and thin (~10 KB) — to span the size tiers you’ll actually project against.
MCP result channels
WorldMonitor preserves raw projection text for existing clients.structuredContent must be a JSON object, so it wraps every successful projection, including object projections. The channels carry the same projected value but do not always have the same shape. Validate structuredContent against the tool’s advertised outputSchema, not against the parsed text.
For example, call get_sources with {"view":"summary","jmespath":"summary.providerCount"}. If the provider count is 3, the result contains:
A projection that selects nothing because it names a field the response does not have returns
_jmespath_error with the empty_projection kind. It fires when the result is null, or a multiselect whose every entry is null, and at least one field the expression reads appears nowhere in the response, such as {stories: topStories[].{h: headline}} when stories carry primaryTitle. JMESPath yields null for a path that does not exist, so returning it as data reads as “the source has nothing”. The envelope lists those names in unknown_fields and adds key_paths, the dotted paths into the response, so the retry can use the real field names. A field that exists and holds null (a story that names no country) is returned as null, and an empty list or a hash with only some null entries is a result.
Attribution comes from the payload before projection. When source attribution is present, the server attaches _attribution outside the selected data value. This also applies to invalid expressions, whose error envelope becomes data. If the payload contains no source attribution values, no rider is added. Keep the rider with any values you redistribute.
Some tools fit large responses to their output budget. If a projection selects fitted data, transportCoverage remains outside the projection in both channels. With an attribution rider, both channels use { "data": <value>, "_attribution": <rider>, "transportCoverage": <coverage> }. Preserve this coverage record so omitted records remain visible. If the final text still exceeds the budget, the budget envelope replaces the data in both channels. The budget measures text after attribution, coverage, and deprecation metadata have been added.
Deprecated tool aliases add a root deprecation notice to structuredContent. If parsed text is an object, the server also adds the notice at that object’s root. Scalar, array, and null text remain raw, so their notice is available only in structuredContent. For an object projection, the structured value stays under projection, with the notice beside it. Budget and projection-error envelopes also retain the notice.
For new clients, prefer structuredContent and retain its metadata. Check for _budget_exceeded at the root. Check for _jmespath_error at the root or inside attribution data before you use a projected value. A legacy text client must handle the envelopes above as well as raw JSON values. Do not assume that JSON.parse(content[0].text) equals structuredContent, or unwrap an ordinary tool payload merely because it has a field named data.
The MCP structured-content specification recommends serialized structured JSON in a text block at SHOULD level. WorldMonitor keeps its existing raw-text contract for compatibility. The wrapper difference is not an output-schema failure. This guide does not introduce a new response mode or change existing response bytes.
REST API (?jmespath=)
The same projection is available on every REST GET operation. The gateway applies it to the JSON response server-side before returning it. Reuse the expressions you already know from MCP, with two differences:
- The expression root is the raw response body, not an MCP
{ cached_at, stale, data }envelope — so you project the payload directly (compositeScore,keys(@)) with nodata.prefix. - A bad, unsafe, over-long, or over-expanding expression returns
HTTP 400with the same{ _jmespath_error, original_keys }body (the MCP transport soft-fails inside a 200 result instead). REST and MCP use the same evaluation rules, 1024-byte expression limit, and 256 KB projected-output cap.
Attribution riders
No tool refuses a projection. Some carry data that is licensed for reuse with attribution, and a projection can easily select the values while leaving the licence fields behind. For those, the server re-attaches the attribution itself rather than refusing the request. When you project such a tool, the result is wrapped:- Resilience source rows keep their value association. Each row includes the indicator ID, retrieval date, and exact source URL needed to attribute the projected value correctly.
-
Your expression only ever sees
data. The rider is extracted from the unprojected payload and merged after your expression runs, so it cannot be selected away — including by an expression that projects its own_attributionkey, which lands harmlessly insidedata. -
Omitting
jmespathchanges nothing. The unprojected response already carries its attribution inline, so it is returned exactly as before, with no wrapper and no_attributionkey. -
The rider counts toward the tool’s output budget, and on a soft-failed
expression it rides on the
{ _jmespath_error, original_keys }envelope too (which then appears underdata). On REST, where a bad expression is an HTTP 400 that serves no data, there is nothing to accompany and no rider.
get_resilience_indicators,
get_imd_cyclone_marine, GET /api/resilience/v1/get-resilience-indicators,
and GET /api/safety/v1/get-toronto-safety. The retired Toronto tools
(get_toronto_reported_occurrences, get_toronto_calls_attended) are off
tools/list but stay callable, and keep their rider. The list is derived from the tool
schemas rather than hand-maintained — a tool that grows a licence field without
declaring its attribution extraction fails the build.
The twelve examples
1. Drill into a single nested object
Intent. Skip the equity list and just get the WorldMonitor fear-greed composite score fromget_market_data.
Tool call:
limit: 0). Hundreds of equity quotes, every sector, all of crypto, every Gulf ticker, the full fear-greed breakdown:
data."fear-greed" quotes the hyphenated key, then .composite plucks the nested object. Everything else in the payload — the 100 KB of quotes — never crosses the wire.
Omit limit: 0 for ordinary use: cache tools default-cap list- and map-shaped fields at 30 items when limit is omitted.
2. Slim each item to a few fields (multiselect-hash)
Intent. Fromget_market_data, get a compact three-row table of the default-capped equity quotes: symbol, price, percent change.
Tool call:
name, display, and a sparkline array — none of which the model usually needs for a “what moved today” question:
[*] projects across every array element; {s:symbol, p:price, chg:change} is the multiselect-hash — it builds a new object per element using whichever fields you list. Shorter output keys (s, p, chg) shave a few more bytes; standard keys (symbol, price, change) are fine too if you want readability.
3. Filter on a numeric comparator
Intent. Fromget_conflict_events, keep only UCDP events with at least one confirmed fatality.
Tool call:
deathsBest: 0 — political incidents, intercepted attacks, near-misses:
deathsBest: 0 entry is dropped.
Why this works. [?expr] is the filter projection; > is the numeric comparator. Backticks around the literal matter — [?deathsBest > 0] (no backticks) treats 0 as an identifier, which JMESPath parses but then evaluates to null, and the comparison silently returns no rows. Always wrap numeric and boolean literals in backticks.
4. Filter on string equality
Intent. Fromget_conflict_events, get every UCDP event whose country is exactly "Iraq".
Tool call:
"stocks-bootstrap"). A common first-time mistake is [?country == "Iraq"], which JMESPath parses as “compare country to a field literally named Iraq”, evaluates the right-hand side to null, and returns no rows.
5. Array projection — flat list of one field
Intent. Fromget_market_data, get a flat list of sector ETF tickers.
Tool call:
[*] projects across every array element, and .symbol is applied to each one in turn. The result is an array of just the symbol strings — no enclosing objects.
6. Slice — first N elements
Intent. Fromget_conflict_events, return only the first five UCDP events.
Tool call:
events[].
Why this works. [start:stop] is the slice projection (stop is exclusive). Negative indices and a step are also supported — [-5:] for the last five, [::-1] to reverse, [::2] for every other element. Slicing is post-filter in the pipeline — to slice the filtered set, pipe (see example 12).
7. length() for counting
Intent. How many UCDP events are in the default-capped latest bundle?
Tool call:
length() is one of JMESPath’s built-in functions; it works on arrays, strings, and objects (where it returns the key count). Useful as a sanity check before a longer call — a length() projection returns a single integer, costs nothing in tokens, and tells the model whether the bundle is empty before deciding what to project next.
Because this call omits limit, the tool-level default cap is applied before JMESPath, so the count is the capped candidate set (30). Pass limit: 0 when you need to count the full underlying bundle instead.
8. sort_by + reverse + slice — Top-N
Intent. From get_conflict_events, give me the three deadliest UCDP events with country + death count only.
Tool call:
|:
sort_by(events, &deathsBest)— JMESPath sorts ascending;&expris an expression reference (sort key).reverse(@)— flip ascending to descending.@is the current node.[0:3].{...}— slice the top three, then multiselect-hash to slim each row.
9. Filter on enum-string field
Intent. Fromget_conflict_events, return the first five UCDP events classified as state-based violence — the highest-severity tier.
Tool call:
[?...].{a:..., b:...} filters first, then slims each surviving row. Most WorldMonitor responses use upper-snake enum strings (SEVERITY_LEVEL_HIGH, TREND_DIRECTION_STABLE, UCDP_VIOLENCE_TYPE_*); search them with == and single quotes exactly as written.
10. Object-as-map navigation
Intent. Fromget_chokepoint_status, get the risk level + 7-day incident count for the Strait of Hormuz only.
Generated riskSummary and riskReportAction prose is withheld as empty strings. Missing prose does not mean low risk. Use the structured risk fields and check measurement availability before interpreting counts.
Tool call:
summaries is keyed by chokepoint name (object map), not an array of {name, ...} records:
fear-greed.categories, EU member-keyed series in get_country_macro’s house-prices dataset. Treat them as dotted path navigation: known key → use the key directly. If you don’t know the key, see the next example.
11. Object-as-map projection — * and keys()
Intent. From get_chokepoint_status, list every chokepoint currently rated “critical” with its incident count.
Tool call:
summaries.* flattens the map’s values into an array — so suez, hormuz_strait, bab_el_mandeb, etc. become indexable array elements. Then a normal [?…] filter and multiselect-hash apply.
The flatten drops the original map keys (the chokepoint names). If you need the names too, project them separately with keys(data."transit-summaries".summaries), or accept the structural mismatch and switch to the sibling chokepoint_transits.transits payload, which IS keyed-as-map of {tanker, cargo, other, total} with the chokepoint name as the key — keys(data.chokepoint_transits.transits) gets you a flat list of every chokepoint covered.
12. Pipe combinator — multi-stage projection
Intent. Fromget_conflict_events, give me the five deadliest fatality-positive events with country, death count, and violence type.
Tool call:
| resets the context to “the result so far” and starts a new projection — so the filter runs first, the sort runs against the filtered set (not the whole array), reverse flips it, slice takes the top five, and the multiselect-hash slims each row. Pipe is the right tool whenever you need to apply a projection (like sort_by) after a filter rather than across the original array.
Escape hatches
Get the full payload (no projection)
Omit thejmespath argument entirely. Cache tools default-cap list- or map-shaped fields at 30 items when limit is omitted; pass limit: 0 to disable that cap when you genuinely want the whole bundle:
_budget_exceeded — when the payload is too big
Each tool declares a per-tool output budget (_outputBudgetBytes). When a tool’s serialised response exceeds that budget after all filtering, summary, and JMESPath have been applied, the server returns this envelope instead of the oversized payload — still inside the normal MCP result, still HTTP 200, not a JSON-RPC error (success results carry no isError flag):
country, since, limit) underneath it. The Pro daily quota slot stays charged when this envelope fires — the tool already ran its full upstream fetch/compute before the output was measured, so the cost is sunk (a refund here would let a caller drive unlimited real cost by always exceeding the budget). Budget your projection up front via describe_tool’s outputSchema rather than relying on retries.
_jmespath_error — when the projection itself fails
A JMESPath expression can fail when it exceeds 1024 bytes, has invalid syntax, violates the evaluation rules above, selects nothing, or exceeds the 256 KB output cap via a runaway multiselect-hash. In all cases you get this envelope back. _jmespath_error is a string (<kind>: <details>), not an object:
original_keys is the top-level keys of the unprojected response (capped at 50 keys with a ...<N more> sentinel) — enough context for the model to retry with a corrected expression in one extra call. When the unprojected root is not an object, it degrades to a shape hint instead: ["<array length=N>"] for an array root, ["<string>"] / ["<number>"] for a scalar. A bad expression does consume one daily quota slot per attempt when that quota path applies; the echoed original_keys exists specifically to make the retry self-correcting rather than guesswork. The four kinds (expression_too_long, invalid_expression, empty_projection, projection_too_large) and their exact discriminator strings live in the MCP Error Catalog.
Complements to projection
summary: true flag
Every cache tool also accepts a universal summary: true argument that returns a server-built summary instead of the full payload. Arrays become { count, sample } with up to 3 sample items; object fields with more than 5 keys are treated as entity maps and become { count, sample_keys } with up to 3 sample keys. Use it when:
- You want a quick sanity-check of what’s in the bundle before designing a projection —
summary: truereturns the shape and tier counts in a handful of fields. - The model only needs aggregate counts (“how many active conflicts?”, “how many critical chokepoints?”) and not the underlying rows.
summary: true and jmespath compose: the summary is built first, then the projection applies on top. Combine the two when you want the summary’s pre-aggregated counts but only some of the categories.
describe_tool
To re-read one tool’s definition — its outputSchema included — without re-listing the whole catalog, call describe_tool({ tool_name: "get_market_data" }). describe_tool is metadata-only and exempt from the Pro daily quota — use it freely while authoring projections. If the name is wrong, the response is { error: "unknown_tool", available: [...] }, again with no quota cost.
See also
- JMESPath specification — the canonical grammar reference.
- MCP Quickstart — five-minute zero-to-first-call onboarding.
- MCP Tools Reference — per-tool parameters, freshness budgets, and response shapes for every tool.
- MCP Server reference — auth, OAuth setup, plans, quotas, errors.
- MCP Error Catalog — every JSON-RPC code, HTTP status, and soft envelope (including
_budget_exceededand the three_jmespath_errorkinds).
