---
title: "Tool Tuesday: How to Build Your First MCP-Powered Host"
newsletter: "MLOps Community"
date: 2025-03-25
source: https://aaif.live/newsletters/mlopscommunity/2025-03-25-tool-tuesday-how-to-build-your-first-mcp-powered-host
---

# Tool Tuesday: How to Build Your First MCP-Powered Host

*MLOps Community — Agentic AI Foundation, 2025-03-25*

Now panicking in case it comes out in the court papers [https://techcrunch.com/2025/03/21/meta-has-revenue-sharing-agreements-with-llama-ai-model-hosts-filing-reveals/] how much kickback Zuckerberg’s been getting from our merch [https://go.mlops.community/Merch].

## Model Context Protocol (MCP)

TOOL TUESDAY: HOW TO BUILD YOUR FIRST MCP-POWERED HOST

Last time, we looked in to Model Context Protocol (MCP)—an open protocol that lets AI agents call tools, fetch contextual resources, and collaborate through a standardized interface.

🔧 This week, we’re getting our hands dirty: we’re building a simple, production-ready MCP Host in Python—an LLM agent that connects to any MCP-compliant server, calls tools dynamically, and gives users live, interactive feedback.

To recap, MCP follows a client-server architecture. It consists of a host that integrates both a language model and an MCP client. The client interacts with multiple MCP servers, which supply relevant context to the model.

Source: The Neural Blueprint (TNB) [https://neurlcreators.substack.com/].

⚙️ Quick Setup (Under 2 mins)

Before writing a single line of code:


# Step 1: Create project uv init mcp-host cd mcp-host uv venv source .venv/bin/activate # Step 2: Install dependencies uv add mcp anthropic python-dotenv # Step 3: Add your Anthropic API key echo "ANTHROPIC_API_KEY=sk-..." > .env

You'll also need a working MCP server. For this tutorial, we'll use a simple Python-based server like FastMPC() [https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#server] (a high-level abstraction that simplifies server creation), or you can use Node.js-based servers like @modelcontextprotocol/server-filesystem [https://www.npmjs.com/package/@modelcontextprotocol/server-filesystem].

📦 Step 1: Set Up the MCP Host Skeleton

Think of the MCP host as an AI agent powered by:

 * An LLM (like Claude 3.5)
 * An MCP client (to communicate with any MCP server)
 * A simple event loop to connect it all

Start by importing and initializing:

from anthropic import Anthropic from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client

Already set up your Anthropic API key above? Create an instance:

anthropic = Anthropic()

🧠 Step 2: Let the Agent "Know" What Tools It Has

Define a function that fetches and formats tool metadata from the MCP server. This step lets the LLM understand what functions it can call.

async def list_available_tools(session): tools = await session.list_tools() return [{ "name": t.name, "description": t.description, "input_schema": t.inputSchema } for t in tools.tools]

💬 Step 3: Chat with Claude and Handle Tool Calls

The LLM processes natural language prompts and decides whether to call a tool. If it does, your host app will:

 1. Run the tool via the MCP server
    
    
 2. Return the result to the LLM for a final response

async def handle_tool_use(session, content): result = await session.call_tool(content.name, content.input) return { "tool_use_id": content.id, "content": result.content[0].text }

🤖 Step 4: Run the Interactive Agent Loop

Now you’ll build an interactive REPL where users can chat with your Claude-powered agent:

async def chat(session): tools = await list_available_tools(session) messages = [] while True: user_input = input("You: ") if user_input.lower() == "exit": break messages.append({"role": "user", "content": user_input}) response = await get_claude_response(messages, tools) # Process text & tool calls for content in response.content: if content.type == "tool_use": tool_result = await handle_tool_use(session, content) messages += [ {"role": "assistant", "content": [content]}, {"role": "user", "content": [{"type": "tool_result", **tool_result}]} ] response = await get_claude_response(messages, tools) print("Assistant:", response.content[0].text)

⚡ Step 5: Launch Your MCP Host

Save your script as host.py, and ensure you have an MCP server like the simple Python server (either with FastMCP or using a Server class—the MCP SDK [https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#mcp-python-sdk] lets you create a server with both) or the Node.js Filesystem MCP Server [https://www.npmjs.com/package/@modelcontextprotocol/server-filesystem] ready.

To start chatting with your MCP agent:

# With a Python server: python host.py python server.py

Or, run it against the Node.js filesystem server:

# With a Node.js MCP server: python host.py npx -y @modelcontextprotocol/server-filesystem .

✨ Sample Interaction

Now you’re chatting with Claude, and under the hood, your host is executing server-side tools like:

“What’s the time in Dubai?” → Calls get_time_in_timezone → Claude returns the local time. 🕒


You: What’s the current time in Dubai? Assistant: I’ll help you check using the get_time_in_timezone function… The current time in Dubai is 12:58 PM (UTC+4)

💡 Why This Matters

This lightweight setup shows how good MCP is:

 * 🔌 Plug into any server/tool written in any language
 * 🧠 Let the LLM decide which tool to call
 * 🛠️ Expand capabilities just by connecting to more MCP servers

No agent frameworks. No black-box orchestration. Want to scale across languages? Swap in a Node, Rust, or Java-based server. Need new tools? Just add them server-side.

Just structured access and control over your LLM’s environment—the way it should be.

Want the full code example? We’re publishing the full guide on The Neural Blueprint [https://neurlcreators.substack.com/] by tomorrow, so… uhm… subscribe? 😄

💬 Have questions or want to showcase your own MCP server? Jump into #agents [https://mlops-community.slack.com/archives/C0861BQ65A7] on the MLOps Community Slack and share your builds!

Huge thanks to Stephen Oladele [https://go.mlops.community/733wfg] for the contribution.

## TOOL TUESDAY REQUESTS OPEN

Want us to cover a specific tool or got one you want to write about?

Just reply and let us know.

## HERE TO HELP

Before you go, here are three ways I can help - just hit reply:

 * Curated intros to other community members
 * What problems are you dealing with? Let me help you find the best solutions through my network
 * Looking to augment your staff for an MLOps or AI project? I got you covered

Thanks for reading, catch you next time!

Interested in partnering with us? Get in touch: partners@mlops.community

Thanks for reading. See you in Slack [https://go.mlops.community/slack], YouTube [https://www.youtube.com/channel/UCG6qpjVnBTTT8wLGBygANOQ?view_as=subscriber], and podcast [https://home.mlops.community/public/content/] land. Oh yeah, and we are also on X [https://twitter.com/mlopscommunity] and LinkedIn [https://go.mlops.community/linkedin].

The MLOps Community newsletter is edited by Jessica Rudd [https://www.linkedin.com/in/jmrudd/].

Shoutout to Ranuga Disansa [https://go.mlops.community/i83caq] for his contributions.

---
Source: https://aaif.live/newsletters/mlopscommunity/2025-03-25-tool-tuesday-how-to-build-your-first-mcp-powered-host
