<?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 Nico Jahn on Medium]]></title>
        <description><![CDATA[Stories by Nico Jahn on Medium]]></description>
        <link>https://medium.com/@nicojahn?source=rss-41ebaf8729f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vMgPohr8sg4XHhxpYBSSsg.png</url>
            <title>Stories by Nico Jahn on Medium</title>
            <link>https://medium.com/@nicojahn?source=rss-41ebaf8729f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:02:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicojahn/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[Bridging SLMs and LLMs with MCP: Practical Agentic AI for Edge and Enterprise]]></title>
            <link>https://medium.com/datareply/bridging-slms-and-llms-with-mcp-practical-agentic-ai-for-edge-and-enterprise-bd19eca019dc?source=rss-41ebaf8729f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd19eca019dc</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Nico Jahn]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 11:36:20 GMT</pubDate>
            <atom:updated>2025-09-16T13:46:12.892Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Authored by: </em><a href="http://medium.com/@nicojahn"><em>Nico Jahn</em></a><em>, </em><a href="https://medium.com/@intuitive_puce_porpoise_615"><em>Ahmed Hatem</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wopj8uO8aL7rGywP-VUc0w.png" /><figcaption>Multi-Agent Chatbot Application with MCP</figcaption></figure><p>We assume you most likely already heard of MCP and its advantages. But the technical adoption is still lacking, and maybe you’re asking yourself what real-world problems can be solved with it? In this article <strong>we focus on two use-cases</strong> where one of them is a real customer use-case that we’re covering. We prepared a running demo for you for the first use-case, which <a href="https://github.com/AhmedHatemReply6c/mcp_demo/tree/main">you can fork and use free of charge</a>.</p><h3>Recap, What Actually Is MCP?</h3><p>MCP (Model Context Protocol) is an open, JSON-RPC-based standard for structuring the way models communicate with external tools, data, and each other. Instead of writing custom glue code for every integration, MCP lets AI agents dynamically discover available capabilities on the fly. This allows for more modular, scalable, and interoperable systems — especially useful as we move into more complex agentic architectures.</p><p>The protocol defines three core capabilities that servers can expose:</p><ul><li><strong>Prompts</strong> — reusable instruction templates that a model can include or modify. Think of them as pre-configured tasks that can be partially filled in and reused.</li><li><strong>Resources</strong> — handles to data streams or files, such as a pointer to a log file, a filtered database query, or a structured document.</li><li><strong>Tools</strong> — typed function calls representing API actions or logic like “fetch user record”, “summarize report”, or “translate document”.</li></ul><p>On the client side, an agent (which might be an SLM, a chatbot, or a coordinator process) can discover what’s available through standard methods like <em>tools/list</em>, <em>resources/list</em>, and <em>prompts/list</em>. Once discovered, these can be invoked dynamically without the client needing to hard-code request logic. This is particularly valuable when systems scale across multiple teams or vendors, where agility and interface consistency matter.</p><p>MCP runs over standard transport like HTTP, WebSockets, or even stdio, making it flexible for both edge and cloud environments. Security, authentication, and capability scoping are also built-in, so services can be safely exposed in production.</p><h3>Use Case 1 — SLMs on the Edge with LLM Support via MCP</h3><p>On-device AI is an increasingly important area as companies push inference to the edge — whether that’s on mobile phones, embedded devices, or local apps that need to run offline or with limited connectivity. However, those devices typically rely on small language models (SLMs) due to constraints in memory, compute, and power. These models are surprisingly capable, but they hit a wall when tasked with reasoning over longer context or large documents.</p><p>This is where MCP comes in. An SLM running on-device might be able to understand the structure of a user request but not have the capacity to fulfill it fully. Using MCP, the SLM can offload complex or long-context reasoning tasks to a remote LLM server.</p><p>Here’s what that flow might look like:</p><blockquote><em>A (business) user asks their on-device assistant to summarize a multi-page report (could be for example a long report on the corporate SharePoint or from an online source). The assistant — the SLM — is smart enough to understand the task and extract a summary of the current conversation but knows it cannot read and process the entire document. Instead, it formulates a structured request with the core user intent and context digest and sends it to an MCP-compliant server. That server runs an LLM, retrieves the full document from an attached resource (say, a reference to the report in SharePoint), and uses a reusable summarization prompt to generate the result. It then streams the summary back to the SLM, which displays it in the UI.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*krd1mipjpEVE9cORubkPDg.png" /></figure><p>This small language model keeps the device lightweight, preserves user experience, and ensures only essential context is exchanged — no need to send the entire chat history or document up the wire.</p><p>If you’re curious about why SLMs are such a good fit for this pattern, we dive deeper into the topic in another article we wrote: <a href="https://medium.com/datareply/driving-efficiency-and-agentic-ai-innovation-with-small-language-models-slms-4e5e73cccda8">Driving Efficiency and Agentic AI Innovation with Small Language Models (SLMs)</a>. It walks through the motivations, advantages, and design tradeoffs behind using SLMs in modern agentic workflows.</p><h3>What’s Next: Python Demo</h3><p>In the coming section, we’ll build a minimal Python MCP server using SSE <strong>implementing a variation of the first use-case above</strong>. You’ll walk away with a <a href="https://github.com/AhmedHatemReply6c/mcp_demo">GitHub-ready repo</a> <a href="https://github.com/AhmedHatemReply6c/mcp_demo/fork">which you can fork right away</a> and extend for your own tools — be it document retrieval, API orchestration, or multi-agent workflows.</p><p><strong>The best part: </strong>You only need <strong>git</strong> and <strong>docker</strong> installed. No API keys necessary, everything is running locally. Bear with us.</p><p>In our example we will utilize three docker containers. One running <a href="https://ollama.com/">Ollama</a> (the runtime engine for our two SLMs) which is fairly standard — you don’t have to install it, we are using the docker container to serve it.</p><p>Start by cloning our GitHub repository at <a href="https://github.com/AhmedHatemReply6c/mcp_demo"><strong>AhmedHatemReply6c/mcp_demo</strong></a> by running the following command in the terminal:</p><pre>git clone https://github.com/AhmedHatemReply6c/mcp_demo.git</pre><p>Now let’s have a look into the components of our demo, starting with the client (representing our on-device SLM) and continuing with the server (an MCP server; simulating a remote server with LLM support).</p><h3>The Client</h3><p>The client code (client/client.py) is the on-device component responsible for interacting with the MCP server over a Server-Sent Events (SSE) connection. This enables efficient, asynchronous, bidirectional streaming communication, which is crucial for handling potentially long-running requests or responses without blocking the device’s main thread.</p><p>client/client.py</p><pre>[...]<br><br>from mcp import ClientSession<br>from mcp.client.sse import sse_client<br><br>from langchain_ollama import ChatOllama<br><br>from langgraph.prebuilt import create_react_agent<br>from langchain_mcp_adapters.tools import load_mcp_tools<br><br>[...]<br><br>async with sse_client(url=SERVER_URL) as (read, write):<br>    async with ClientSession(read, write) as session:<br>        # Initialize the connection<br>        await session.initialize()<br><br>        tools = await load_mcp_tools(session)<br><br>        # Small Language Model through Ollama<br>        slm = ChatOllama(<br>            model=MODEL_NAME, base_url=&quot;http://ollama:11434&quot;, temperature=0.3<br>        )<br><br>        # Set debug to True if you want to see all different steps the agent takes to solve the task<br>        graph = create_react_agent(<br>            model=slm,<br>            tools=tools,<br>            prompt=SYSTEM_PROMPT,<br>            checkpointer=memory,<br>        )</pre><p>SSE Client Abstraction</p><p>Using the sse_client context manager, the client establishes a persistent connection to the MCP server URL. This abstraction exposes two coroutine endpoints — read and write — which respectively listen for incoming server events and send user-initiated requests or messages back to the server. By keeping this communication asynchronous and event-driven, the client remains responsive even during complex, multi-step interactions.</p><p>Loading MCP Tools</p><p>Once connected, the client calls load_mcp_tools(session), which dynamically queries the server to discover available MCP tools. Each tool is a self-contained module exposing specific functionality — for example, document retrieval, summarization, or code generation — that the server can execute on behalf of the client. This dynamic loading allows the client agent to flexibly access and orchestrate a broad range of capabilities without hardcoding them in the client.</p><p>Ollama Model Integration</p><p>The client uses a lightweight Small Language Model runtime, ChatOllama, which wraps calls to the Ollama API running inside a Docker container. This local model handles the initial understanding and intent extraction from user input. It’s configured with parameters like temperature=0.3 to balance creativity and determinism in its responses, making it well-suited for structured interaction flows.</p><p>Creating the ReAct Agent</p><p>The heart of the client’s reasoning pipeline is the create_react_agent function. This function builds an agent that leverages the local Ollama model together with the loaded MCP tools. It implements a ReAct (Reasoning and Acting) pattern — the agent iteratively reasons about the user’s query, decides which tools to call, processes intermediate results, and formulates a final response.</p><p>The agent is initialized with:</p><ul><li>The model to perform natural language understanding and generation,</li><li>The tools list to provide actionable capabilities,</li><li>A prompt that sets system-level instructions guiding the agent’s behavior,</li><li>And a checkpointer for memory persistence, allowing the agent to keep track of conversation state or intermediate computations across requests.</li></ul><h3>The Server</h3><p>The server (server/server.py) hosts the MCP-compliant backend that powers the complex reasoning and document processing tasks beyond the capacity of on-device Small Language Models (SLMs). It exposes an API for MCP clients to interact with, manages tool implementations, and runs a larger Language Model (LLM) to fulfill the heavy lifting.</p><p>server/server.py</p><pre>from mcp.server.fastmcp import FastMCP<br>[...]<br>from pathlib import Path<br><br>[...]<br><br>mcp = FastMCP(name=&quot;code-generation&quot;, host=&quot;0.0.0.0&quot;)<br><br>[...]<br><br>DOC_PATH = Path(&quot;mcp_documentation.txt&quot;)<br>MCP_DOC = DOC_PATH.read_text(encoding=&quot;utf-8&quot;).strip()<br><br>@mcp.tool()<br>async def get_mcp_doc() -&gt; str:<br>    &quot;&quot;&quot;Return a short MCP summary/documentation.&quot;&quot;&quot;<br>    return MCP_DOC</pre><p>At startup, the server reads key reference documents — like mcp_documentation.txt - into memory. These documents serve as static knowledge bases that the server’s MCP tools can query or summarize.</p><p>Each MCP tool is implemented as an asynchronous function decorated with @mcp.tool(). For example, the get_mcp_doc() tool returns a short summary or snippet from the MCP documentation when invoked by the client. This modular approach allows adding or modifying server-side capabilities without changing the core server infrastructure.</p><pre>from mcp.server.fastmcp import FastMCP<br>from langchain_ollama import OllamaLLM<br>from pathlib import Path<br><br>[...]<br><br>mcp = FastMCP(name=&quot;code-generation&quot;, host=&quot;0.0.0.0&quot;)<br><br># This could of course also be another LLM like GPT-4, Claude, etc.<br># To enable a free usage for everyone we use Ollama here.<br>code_llm = OllamaLLM(model=MODEL_NAME, base_url=&quot;http://ollama:11434&quot;, temperature=0.3)<br><br>[...]<br><br>DOC_PATH = Path(&quot;llms-small.txt&quot;)<br>MCP_LLMS_SMALL_DOC = DOC_PATH.read_text(encoding=&quot;utf-8&quot;).strip()<br><br>[...]<br><br>@mcp.tool()<br>async def generate_mcp_client_server_code(query: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    Takes a natural-language specification of required tools and returns code.<br>    Args:<br>        query: A natural-language specification of the MCP (Model Context Protocol) server and/or client and what needs to be implemented.<br>    &quot;&quot;&quot;<br>    prompt = f&quot;&quot;&quot;\<br>/no_think You are an expert Python developer.<br>Depending on the user request generate a complete MCP (Model Context Protocol) server or MCP (Model Context Protocol) client implementation, based on the following spec:<br>&lt;query&gt;<br>{query}<br>&lt;/query&gt;<br><br>The documentation for MCP (Model Context Protocol) is:<br>&lt;documentation&gt;<br>{MCP_LLMS_SMALL_DOC}<br>&lt;/documentation&gt;<br><br>Align with the &#39;Implementation example&#39; from the documentation! Stick to the example implementations as much as possible.    &quot;&quot;&quot;<br>    code = await code_llm.ainvoke(input=prompt)<br>    return code</pre><p>The Code Generation Tool</p><p>A particularly powerful server tool is generate_mcp_client_server_code(). This tool accepts a natural language query describing what the client or server should implement, and uses an LLM-powered code generation prompt to produce complete MCP-compliant Python code dynamically.</p><p>The tool constructs a prompt that includes:</p><ul><li>The user’s specification wrapped in &lt;query&gt; tags,</li><li>The MCP protocol documentation loaded from llms-small.txt,</li><li>An explicit instruction to align generated code with the official MCP implementation examples.</li></ul><p>This prompt is sent to an Ollama LLM instance (code_llm), which runs inside a dedicated Docker container. The LLM’s response is returned as generated Python code that the client or server can integrate or execute. This pattern exemplifies how MCP servers can extend their functionality at runtime, using AI-assisted code synthesis.</p><p>Ollama LLM Runtime</p><p>The server leverages the same Ollama runtime environment as the client but with a larger or more capable model suited for intensive tasks. The OllamaLLM wrapper manages communication with the Ollama API, configured with model name and temperature parameters for tuning output behavior.</p><p>Overall Server Role</p><p>Together, these components enable the MCP server to:</p><ul><li>Serve as a knowledge hub with fast access to large documents,</li><li>Expose reusable, composable tools over an async protocol,</li><li>Generate or update MCP code dynamically based on evolving requirements,</li><li>Stream results back to clients efficiently using SSE.</li></ul><p>This architecture makes the MCP server a flexible and powerful extension point for edge AI workflows, allowing lightweight SLM clients to offload complex processing securely and seamlessly.</p><h3>Use Case 2 — Multi-Agent Enterprise Chatbot Across Boundaries</h3><p>MCP isn’t just about offloading work to LLMs — it also shines when coordinating across multiple agents and services. In enterprise environments, departments often have their own internal systems (HR, finance, compliance, etc.) and sometimes rely on external services for specific capabilities (e.g., Workday for HR data or Salesforce for CRM). Coordinating queries across all of them typically means brittle API chaining or middleware spaghetti.</p><p>A more scalable and modular approach is to design a chatbot that acts as an orchestrator, integrating multiple MCP servers — one per domain — and calling into each as needed. Each of these servers might expose their own tools, resources, and prompts.</p><p>Imagine a user asks a chatbot: “<em>What’s my available PTO, and are there any compliance trainings I missed?</em>” The bot doesn’t need to know exactly how to fulfill this; instead, it dynamically discovers a tool for fetching PTO from the HR server and another tool for querying training completions from the compliance server. It invokes both over MCP, aggregates the results, and returns a coherent answer.</p><p>This pattern also allows for external integration. If one department’s logic is best served by a third-party LLM service (for instance, Workday or ServiceNow), the orchestrator can call out to it via MCP without losing consistency or context.</p><p>This entire approach maps to what we refer to as the Hybrid Agentic Model: combining in-house agents with selectively outsourced capabilities. It gives teams control of where they need it (security, auditability), but the flexibility to scale by relying on external tools or models for non-core functions.</p><p>We’ll be exploring this model in more depth in another article. Leave a comment if you would like to read how different Agentic Models cooperate in enterprise environments. If you’re thinking about how to structure your AI systems across teams and vendors, it’s worth keeping an eye out for.</p><h3>Why MCP Matters Now</h3><p>A few things make MCP particularly relevant in 2025 and beyond:</p><ul><li>The shift from monolithic models to agentic, modular AI is accelerating.</li><li>More enterprises are adopting edge + cloud hybrid architectures.</li><li>Developers want to avoid writing the same glue code repeatedly across APIs.</li><li>Security and auditability of model interactions is becoming non-negotiable.</li></ul><p>What makes MCP elegant is that it gives you typed, discoverable interfaces between models and tools. You can version capabilities cleanly, stream partial results, and keep everything interoperable. And because it’s open and JSON-based, it’s easy to adopt in existing stacks.</p><p>As the ecosystem matures, we’re seeing growing support: SDKs in Python, TypeScript, Rust, and more; hosted servers for everything from PostgreSQL to GitHub to Google Drive; and model providers (like OpenAI and Anthropic) beginning to support it natively in their agent runtimes.</p><h3>Call to Action</h3><p>If you’re unsure how to utilize the demo or you want to explore advanced use-cases, feel free to drop us a message.</p><p>At Reply, we help organizations design scalable, secure, and future-ready AI architectures — whether you’re just getting started or optimizing production workloads.</p><h3>Sources</h3><p>1. Driving Efficiency and Agentic AI Innovation with Small Language Models (SLMs)</p><p><em>Reference in Use Case 1 (SLM on the Edge)</em></p><p>🔗 <a href="https://medium.com/datareply/driving-efficiency-and-agentic-ai-innovation-with-small-language-models-slms-4e5e73cccda8">https://medium.com/datareply/driving-efficiency-and-agentic-ai-innovation-with-small-language-models-slms-4e5e73cccda8</a></p><p>2. Model Context Protocol (MCP) GitHub Repository</p><p>🔗 <a href="https://github.com/modelcontextprotocol/modelcontextprotocol">GitHub — modelcontextprotocol/modelcontextprotocol: Specification and documentation for the Model Context Protocol</a></p><p>3. MCP Overview / Intro Documentation</p><p>🔗 <a href="https://modelcontextprotocol.io/introduction">https://modelcontextprotocol.io/introduction</a></p><p>4. mcp-summarizer (Reference Implementation)</p><p>🔗 <a href="https://github.com/AhmedHatemReply6c/mcp_demo">GitHub — AhmedHatemReply6c/mcp_demo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd19eca019dc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/datareply/bridging-slms-and-llms-with-mcp-practical-agentic-ai-for-edge-and-enterprise-bd19eca019dc">Bridging SLMs and LLMs with MCP: Practical Agentic AI for Edge and Enterprise</a> was originally published in <a href="https://medium.com/datareply">DataReply</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>