From c7dae12a11d2576607db93e361b6cad1597dea66 Mon Sep 17 00:00:00 2001 From: vortx-jaya Date: Tue, 28 Jul 2026 23:03:08 +0530 Subject: [PATCH 1/4] python: add emem geospatial memory MCP example for Streamable HTTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Demonstrates using MCPStreamableHttpPlugin to connect to emem (https://emem.dev/mcp), a public no-auth Streamable HTTP MCP server providing Ed25519-signed Earth observation facts. The example shows a three-step verification chain: 1. emem_locate — resolve a place name to a canonical cell64 address 2. emem_recall — read signed facts (elevation, AQI, flood extent, etc.) 3. Report the emem:fact: receipt for offline verification No API key or signup is needed for emem reads (Apache 2.0). --- .../concepts/mcp/emem_mcp_geospatial_agent.py | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 python/samples/concepts/mcp/emem_mcp_geospatial_agent.py diff --git a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py new file mode 100644 index 000000000000..c2158736cf29 --- /dev/null +++ b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py @@ -0,0 +1,70 @@ +"""Semantic Kernel + emem MCP example — multi-step verification: locate, recall, verify. + +Connects a Microsoft Semantic Kernel agent to the emem MCP server over +Streamable HTTP and runs a multi-step verification chain for South Mumbai: +resolve the place, recall elevation, then verify the receipt/fact CID. + +Install: + pip install semantic-kernel + +Usage: + export OPENAI_API_KEY="sk-..." + python emem_mcp_geospatial_agent.py + +The agent will resolve South Mumbai, recall its elevation, then verify +the receipt/fact CID, showing each step in the chain. +""" + +import asyncio +import os + +from semantic_kernel.agents import ChatCompletionAgent, ChatHistoryAgentThread +from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion +from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin + +EMEM_MCP_URL = os.getenv("EMEM_MCP_URL", "https://emem.dev/mcp") + +USER_INPUTS = [ + ( + "Using emem, resolve South Mumbai, recall its elevation " + "(copdem30m.elevation_mean), then verify the receipt/fact CID. " + "Show each step: locate, recall, verify." + ), + "Is the air quality in Delhi safe for outdoor exercise right now? Give me a signed fact with a receipt I can cite.", + "Has there been recent deforestation near the Amazon at -3.47° N, -62.22° W?", +] + + +async def main() -> None: + async with MCPStreamableHttpPlugin( + name="emem", + description="Shared, verifiable Earth memory — signed facts for any place on Earth", + url=EMEM_MCP_URL, + ) as emem_plugin: + agent = ChatCompletionAgent( + service=OpenAIChatCompletion(ai_model_id="gpt-4o"), + name="GeospatialAgent", + instructions=( + "You are a geospatial verification agent grounded in emem's signed Earth memory. " + "For every place query: " + "1. Call emem_locate to resolve the place to a canonical cell64 address. " + "2. Call emem_recall to read signed facts (air quality, elevation, flood extent, etc.). " + "3. Report the emem:fact: receipt so the user can verify it offline. " + "Always cite the fact_cid from the receipt." + ), + plugins=[emem_plugin], + ) + + thread: ChatHistoryAgentThread | None = None + + for user_input in USER_INPUTS: + print(f"\n# User: {user_input}") + response = await agent.get_response(messages=user_input, thread=thread) + print(f"# {response.name}: {response}") + thread = response.thread + + await thread.delete() if thread else None + + +if __name__ == "__main__": + asyncio.run(main()) From 25e4ad06b100675ddf16d27f44f42ccba8379c23 Mon Sep 17 00:00:00 2001 From: vortx-jaya Date: Wed, 29 Jul 2026 15:40:57 +0530 Subject: [PATCH 2/4] fix review: use generic tool descriptions, isolate thread per query --- .../concepts/mcp/emem_mcp_geospatial_agent.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py index c2158736cf29..037f5712b246 100644 --- a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py +++ b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py @@ -47,23 +47,19 @@ async def main() -> None: instructions=( "You are a geospatial verification agent grounded in emem's signed Earth memory. " "For every place query: " - "1. Call emem_locate to resolve the place to a canonical cell64 address. " - "2. Call emem_recall to read signed facts (air quality, elevation, flood extent, etc.). " - "3. Report the emem:fact: receipt so the user can verify it offline. " - "Always cite the fact_cid from the receipt." + "1. Use emem's locate tool to resolve the place to a canonical cell64 address. " + "2. Use emem's recall tool to read signed facts (air quality, elevation, flood extent, etc.). " + "3. Report the emem:fact: receipt so the user can verify it offline, including the fact_cid." ), plugins=[emem_plugin], ) - thread: ChatHistoryAgentThread | None = None - for user_input in USER_INPUTS: + thread = ChatHistoryAgentThread() print(f"\n# User: {user_input}") response = await agent.get_response(messages=user_input, thread=thread) print(f"# {response.name}: {response}") - thread = response.thread - - await thread.delete() if thread else None + await thread.delete() if __name__ == "__main__": From bb6dcf3614d23510d23eeee3233df6f251083843 Mon Sep 17 00:00:00 2001 From: vortx-jaya Date: Wed, 29 Jul 2026 15:42:56 +0530 Subject: [PATCH 3/4] fix review: update docstring, use env-driven model id --- .../concepts/mcp/emem_mcp_geospatial_agent.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py index 037f5712b246..52e1088457c7 100644 --- a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py +++ b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py @@ -1,18 +1,19 @@ -"""Semantic Kernel + emem MCP example — multi-step verification: locate, recall, verify. +"""Semantic Kernel + emem MCP example — multi-step geospatial verification. Connects a Microsoft Semantic Kernel agent to the emem MCP server over -Streamable HTTP and runs a multi-step verification chain for South Mumbai: -resolve the place, recall elevation, then verify the receipt/fact CID. +Streamable HTTP. For each query the agent: resolves a place to a canonical +cell64 address, recalls signed Earth-observation facts, and reports the +emem:fact: receipt so the answer can be verified offline. Install: pip install semantic-kernel Usage: export OPENAI_API_KEY="sk-..." + export OPENAI_CHAT_MODEL_ID="gpt-4o" # optional, defaults to gpt-4o python emem_mcp_geospatial_agent.py -The agent will resolve South Mumbai, recall its elevation, then verify -the receipt/fact CID, showing each step in the chain. +No API key is needed for emem — reads are anonymous (Apache 2.0). """ import asyncio @@ -42,7 +43,7 @@ async def main() -> None: url=EMEM_MCP_URL, ) as emem_plugin: agent = ChatCompletionAgent( - service=OpenAIChatCompletion(ai_model_id="gpt-4o"), + service=OpenAIChatCompletion(), name="GeospatialAgent", instructions=( "You are a geospatial verification agent grounded in emem's signed Earth memory. " From cdfd29a5799469e228bda88a339208532afbb0d6 Mon Sep 17 00:00:00 2001 From: kumari-jaya <10583908+kumari-jaya@users.noreply.github.com> Date: Fri, 31 Jul 2026 23:38:26 +0530 Subject: [PATCH 4/4] python: polish emem MCP sample --- python/samples/concepts/mcp/emem_mcp_geospatial_agent.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py index 52e1088457c7..5b803e0895a2 100644 --- a/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py +++ b/python/samples/concepts/mcp/emem_mcp_geospatial_agent.py @@ -1,3 +1,5 @@ +# Copyright (c) Microsoft. All rights reserved. + """Semantic Kernel + emem MCP example — multi-step geospatial verification. Connects a Microsoft Semantic Kernel agent to the emem MCP server over @@ -48,8 +50,8 @@ async def main() -> None: instructions=( "You are a geospatial verification agent grounded in emem's signed Earth memory. " "For every place query: " - "1. Use emem's locate tool to resolve the place to a canonical cell64 address. " - "2. Use emem's recall tool to read signed facts (air quality, elevation, flood extent, etc.). " + "1. Use the available emem tools to resolve the place to a canonical cell64 address. " + "2. Use the available emem tools to read signed facts (air quality, elevation, flood extent, etc.). " "3. Report the emem:fact: receipt so the user can verify it offline, including the fact_cid." ), plugins=[emem_plugin],