<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kuntal Ganguly on Medium]]></title>
        <description><![CDATA[Stories by Kuntal Ganguly on Medium]]></description>
        <link>https://medium.com/@kuntalganguly_90844?source=rss-3e3fd60abe51------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Kuntal Ganguly on Medium</title>
            <link>https://medium.com/@kuntalganguly_90844?source=rss-3e3fd60abe51------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 11:06:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kuntalganguly_90844/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I Built a Multi-Agent GIS and Earth Observation System with LLM Orchestration, MCP Tool…]]></title>
            <link>https://medium.com/@kuntalganguly_90844/how-i-built-a-multi-agent-gis-and-earth-observation-system-with-llm-orchestration-mcp-tool-eb85b0666009?source=rss-3e3fd60abe51------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb85b0666009</guid>
            <category><![CDATA[spatial-rag]]></category>
            <category><![CDATA[geospatial-intelligence]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-gis]]></category>
            <category><![CDATA[multiagent-orchestration]]></category>
            <dc:creator><![CDATA[Kuntal Ganguly]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 21:26:41 GMT</pubDate>
            <atom:updated>2026-09-27T21:26:41.980Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How I Built a Multi-Agent GIS and Earth Observation System with LLM Orchestration, MCP Tool Servers, and Geospatial RAG</strong></h3><p>A water manager types one sentence:</p><p><em>“Compare rainfall in the Wear catchment, July to September 2024 against 2025.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*71dORmcP3DpqAIDu-i0g_A.png" /></figure><p>Nobody opens a GIS package. Nobody writes SQL or a Python notebook. About twenty seconds later there’s a map of the catchment with every rain gauge on it, a chart of the two summers, and a short answer: <em>rainfall was about 12.7% lower this year.</em> Under the answer sits a small badge saying every figure has been checked against the data it came from.</p><p>Then she asks: <em>“Compare vegetation health for same time period for this catchment. Show the stats for individual sub catchments while plotting on chart.”</em> The system doesn’t guess. It answers: <em>“Vegetation health (NDVI) showed a marked decline in only 1 Wear sub-catchment for July–September 2025 vs 2024; data were insufficient for the other 29.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UkbydEeO3ug9Q3-zciMPQ.png" /></figure><p>That behaviour isn’t one clever prompt. It comes out of a system of cooperating parts. This article is about how those parts work together, and why each design decision was made.</p><h3>The core idea: agents reason, tools act, data stays put</h3><p>Most “AI + GIS” demos wire a language model straight to a database and hope for the best. The model writes SQL, reads raw geometry back into its context, and narrates whatever comes out. It works in a demo and fails in production. Context windows fill with coordinates, numbers drift between query and answer, and there’s no line between what the model <em>may</em> do and what it <em>can</em> do.</p><p>Here my tool “<strong><em>Terra Analyst</em></strong>” separates three concerns:</p><ul><li><strong>Agents reason.</strong> They decide what to do and explain what happened.</li><li><strong>Tools act.</strong> Every geospatial capability lives in a purpose-built tool server.</li><li><strong>Data stays put.</strong> Results are written to the spatial database and passed around by reference, never by value.</li></ul><h3>How one question flows</h3><p>Example: <em>“Show water-quality sites within 10 miles of NE1 4ST (UK Post code).”</em> The numbers are the real order of events, including the Reviewer agent’s check after the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtlHLlkUeYdp7mZNcXgWLQ.png" /></figure><p>Steps 6 and 11 (blue) are the key design choice. Every tool writes its full output to analysis.results and hands back only an id such as r_b2 plus statistics. Tools can chain on each other&#39;s ids, the LLM&#39;s context stays small, and the map fetches the geometry itself in step 16. The place is looked up in your own tables (here the postcode directory) and the 10-mile radius is converted to 16,093 m and drawn on the British National Grid. If a name matches more than one thing, such as a town in your places table and a district of the same name in your admin areas, step 7 comes back as a question instead: the turn ends, you pick one, and your reply carries on from step 4. Steps 14 and 15 happen after the answer is already on screen. The chat is unlocked at step 13, so the review never makes you wait.</p><h3>Why MCP, and why it matters more than the model</h3><p>Every capability in Terra Analyst is exposed as a tool on a <strong>Model Context Protocol (MCP)</strong> server.</p><p>There are five servers, each with one clear responsibility:</p><ul><li><strong>catalog:</strong> discovering datasets, guarded queries, resolving place names</li><li><strong>spatial:</strong> geoprocessing inside PostGIS</li><li><strong>eo:</strong> satellite data analysis via a STAC catalogue</li><li><strong>hydrology:</strong> live rainfall, river level and flow from Environment Agency gauges</li><li><strong>knowledge:</strong> semantic search across data, documents and past analyses</li></ul><p>The orchestrator holds no GIS logic of its own. It discovers tools at startup and routes calls.</p><p>A tool contract is essentially a well-described function. A simplified, illustrative shape:</p><pre># Illustrative: the shape of a tool, not the implementation<br>@mcp.tool()<br>def analyse_hydrology_condition(<br>    target: str,                 # an area: a catchment, a river, or an earlier result<br>    observed_property: str,      # rainfall | river level | flow | groundwater<br>    mode: str,                   # compare | timeseries | stations<br>    period_a: dict | None = None,<br>    period_b: dict | None = None,<br>) -&gt; dict:<br>    &quot;&quot;&quot;Rainfall, level or flow from gauges inside an area.<br>    Returns a result reference plus summary statistics, never raw geometry.&quot;&quot;&quot;<br>    ...</pre><p>The docstring matters as much as the code. It’s what the model reads when it decides whether and how to call the tool. Good tool descriptions do most of the prompt engineering.</p><h3>Multi-agent orchestration: who does what</h3><p>“Multi-agent” gets used loosely. In Terra Analyst it means distinct roles with distinct jobs, coordinated by one orchestrator.</p><p>user question<br> │<br> ▼<br> ┌───────────────┐ prompt + live catalogue + tool list<br> │ Orchestrator │ ───────────────────────────────▶ LLM<br> │ │ ◀─────────────────────────────── tool call(s)<br> │ │<br> │ for each │──▶ MCP server ──▶ PostGIS / STAC / EA API<br> │ tool call │◀── result reference + summary<br> │ │<br> │ needs the user│──▶ ask a clarifying question, end the turn<br> │ to choose? │<br> │ │ ───────────────────────────────▶ LLM<br> │ │ ◀─────────────────────────────── final answer<br> └───────┬───────┘<br> │ stream answer, layers and charts to the UI<br> ▼<br> Reviewer agent ──▶ verdict badge + audit log</p><p>Two design decisions make the loop reliable.</p><p><strong>1. Results travel by reference.</strong><br> Each tool writes its full output to the database and hands back an identifier plus a compact summary: counts, areas, a few statistics. The model chains steps by passing identifiers around (“take <em>that</em> result and find gauges inside it”). The map fetches geometry directly. Context stays small no matter how many features come back, and every intermediate step can be downloaded.</p><p><strong>2. Ambiguity ends the turn.</strong><br> When a tool finds that a name matches several distinct things, such as a town point and a borough polygon, it returns options, not an answer. The orchestrator stops right there and puts the question to the user. It doesn’t rely on the model choosing to ask; the architecture enforces it.</p><h3>Spatial RAG: how the system understands your data</h3><p>The hardest part of conversational GIS isn’t the geoprocessing. It’s <strong>mapping human words onto real data</strong>.</p><p>This is where spatial RAG comes in. The knowledge layer indexes four kinds of content as embeddings:</p><ul><li><strong>Datasets:</strong> what each layer is, what it contains, what its fields mean</li><li><strong>Attribute values:</strong> the exact vocabulary inside the data</li><li><strong>Documents:</strong> methodology notes, guidance and reports, with page references</li><li><strong>Past analyses:</strong> earlier questions and their results, private to each user.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b58wLkzW2Bf6F-zbQogdVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TO2Jd7nOQLwGTMHjm7FKyg.png" /></figure><h3>The Reviewer: trust is a system property</h3><p>Very important and act as domain expert. A fluent answer and a correct answer look the same until someone acts on the wrong one. Spatial answers get treated as fact, so the system has to earn that. The Reviewer works in two passes after the answer is on screen:</p><p>The first pass is deterministic and fast. The second catches what arithmetic can’t, such as a claim stronger than the data supports. Neither pass delays the answer; the badge arrives a moment later.</p><h3>LLM integration: small prompts, strong contracts</h3><p>The language model does the reasoning, but the system doesn’t lean on it for things the architecture can guarantee:</p><ul><li><strong>Identity</strong> isn’t in the prompt. Every tool call carries a signed caller the model can’t see or change.</li><li><strong>Permissions</strong> aren’t in the prompt. They’re enforced by the tool servers and the database.</li><li><strong>Numbers</strong> aren’t trusted blindly. They’re traced by the Reviewer.</li><li><strong>Place ambiguity</strong> isn’t left to the model’s judgement. The tool detects it and the orchestrator stops the turn.</li></ul><h3>Where the value actually lives</h3><p>Language models are becoming interchangeable, and so are chat interfaces. What isn’t interchangeable:</p><ul><li><strong>Your data layer:</strong> the spatial database, the catalogue, the access rules.</li><li><strong>Your tool contracts:</strong> servers that encode domain knowledge such as metric projections, cloud masking and season-matched comparisons.</li><li><strong>Your review loop:</strong> the guarantee that no number reaches a decision-maker without being traced to its source.</li></ul><p>Agents can run the workflow. What matters is <strong>who controls the data, and what the system is allowed to produce from it.</strong> Build for that, and the model becomes a component you can swap, not a dependency you’re stuck with.</p><p><strong><em>Note</em></strong><em>: Terra Analyst is a working prototype built on open UK data. Code and prompt excerpts in this article are simplified for illustration.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb85b0666009" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>