Tutorial: an agent question, end to end#
Ask the local stack one geospatial question through MCP, the way an agent does, and record the answer as a finding in the Geospatial Knowledge Base (GKB). The question:
Which satellite scene near San Francisco has the least
cloud? Record the answer as a finding.
A script makes the same MCP calls an agent harness would make, so you can see each call and its result. At the end you ask a harness the same question yourself.
Prerequisites#
The local stack running with its seed data (Make a first call, Run the local stack).
The workspace
.venvfrom Install.
Steps#
Run the script from the repository root:
.venv/bin/python docs/examples/mcp_tour.pyIt connects to
http://127.0.0.1:8201/mcp. The local stack runs without sign-in, but its MCP endpoint still expects a bearer token, and accepts any value; the script sendslocal.Read the calls it prints. The output is trimmed here.
It lists the tools the connection allows, then the collections:
32 tools > catalog_list_collections {} {"items": [ {"name": "imagery", "record_count": 0, ...}, {"name": "preview-imagery", "record_count": 3, ...}]}It searches the seeded collection with a box around San Francisco Bay and an exact metadata filter:
> catalog_search {"collection": "preview-imagery", "bbox": [-122.6, 37.6, -122.0, 37.9], "filters": {"platform": "fixture-sat"}, "limit": 5} {"items": [ {"id": "preview-coast-001", "metadata": {"cloud_cover": 2.5, ...}, ...}, {"id": "preview-coast-002", "metadata": {"cloud_cover": 8.0, ...}, ...}], "next_cursor": null, "total": 2}The third seeded record lies outside the box. Picking the lowest
cloud_coveris the agent’s own step; the script does it in Python. It then reads that record:> catalog_get_record {"collection": "preview-imagery", "record_id": "preview-coast-001"} {"id": "preview-coast-001", "source_uri": "catalog://preview-imagery/preview-coast-001", "geometry": {"type": "Point", "coordinates": [-122.4, 37.8]}, "acquired_at": "2026-08-01T12:00:00Z", ...}It publishes the answer as a GKB finding. The Markdown comes from
ArtifactDraft.render()in the typed client (Read and publish knowledge), with the record as evidence:> gkb_publish {"markdown": "---\ngkb_schema: '1.0'...", "idempotency_key": "mcp-tour-v1-preview-coast-001", "publication_requested": true} {"receipt": { "artifact_id": "gkb_01JMCPT0RS0000000000000001", "durability": "committed", "duplicate": false, ...}, "viewer_link": "/gkb/gkb_01JMCPT0RS0000000000000001"}Last, it reads the finding back with
gkb_get_artifact.Run the script again. Every call returns the same result, and
gkb_publishreturns the first receipt with"duplicate": true: the same key and the same Markdown never write twice.Open the finding in the console at
http://127.0.0.1:3101/gkb/gkb_01JMCPT0RS0000000000000001:
Ask a harness the same question. Connect it with the lines under “Local stack” in Connect an MCP client, then paste the question at the top of this page. The harness chooses its own calls; expect the same tools.
Result#
You have the scene with the least cloud, preview-coast-001, and a GKB finding that cites
it. The seed data is a synthetic image; to search your own imagery, load it first
(Load your own data).
What the script shows#
Step |
Tool |
What the server does |
|---|---|---|
List |
|
Returns the collections the connection may read |
Search |
|
Matches text, box, time and exact metadata filters |
Read |
|
Returns one record with its footprint and time |
Publish |
|
Validates the Markdown, stores it once per key |
Read back |
|
Returns the stored finding |
The script is docs/examples/mcp_tour.py. To write your own client, see
Use your own agent framework.