CASE STUDY

Building a Custom MCP Server to Connect AI Assistants to Real Tools

A lightweight MCP (Model Context Protocol) server that turns a general-purpose AI assistant into an agent that can check live weather, search hotels, send email, and run alongside other tools — local and remote, side by side.

4

Live tools built: weather, hotel search, email, plus utility tools

2

Transport types supported: local stdio and remote SSE

3

MCP servers running side by side in one assistant config

0

Hardcoded secrets — every credential loaded from .env

The Challenge

Large language models are excellent at reasoning and writing, but on their own they can’t check live data or perform real-world actions. Anthropic’s Model Context Protocol solves this by giving an assistant a standard way to call external tools — but someone still has to build those tools, wire them together safely, and make them discoverable. The goal for this build:

  • Expose multiple independent tools through a single, consistent interface.
  • Run locally over stdio for development, and remotely over SSE so it could be used from anywhere.
  • Be added straight into an AI assistant’s configuration alongside other MCP servers, with zero custom glue code on the client side.

The Solution: A Custom MCP Server

Built with FastMCP, the official Python framework for MCP-compliant servers. FastMCP handles the protocol plumbing — tool registration, schema generation, transport — so the actual work is just writing plain Python functions and decorating them. Each capability lives in its own module and gets registered with a one-line decorator, which keeps the codebase easy to extend.

mcp = FastMCP("Using MCP-tool for learning MCP")

@mcp.tool()
def get_weather(city: str) -> str:
    """Get weather details for a city"""
    from weather import fetch_weather
    return fetch_weather(city)

@mcp.tool()
def search_hotels_tool(city: str) -> str:
    """Find top hotels in a given city."""
    return search_hotels(f"best hotels in {city}")

if __name__ == "__main__":
    mcp.run(transport="stdio")

Tools & Capabilities Built

Live Weather Lookup

Using LangChain’s OpenWeatherMap wrapper, the assistant asks for current conditions in any city and gets a real, live answer — not a guess from training data.

Hotel Search

A search_hotels tool queries Google Search results through SerpAPI and returns a clean list of titles, links, and snippets the assistant can reason over directly.

Email Automation

An SMTP-based send_email tool lets the assistant compose and send real emails on request — subject, body and recipient all supplied from the conversation.

Multi-Server Orchestration

Three MCP servers registered side by side — one local, one hosted remotely on Hugging Face Spaces over SSE — proving capabilities don’t need to live in one codebase or one machine.

Tech Stack

Python 3.12+ (uv)FastMCP (mcp[cli])LangChain / langchain-communitySerpAPIpyowm (OpenWeatherMap)python-dotenvsmtplib
Security & Best Practices

API keys are loaded from a local .env file via python-dotenv rather than hardcoded, with .gitignore keeping secrets out of version control entirely. This is the pattern we recommend for any agentic AI build: keep credentials out of source code, rotate them regularly, and use app-specific passwords wherever a service supports it.

Results & Takeaways

The finished server gives an AI assistant a working toolbox: it can answer with live weather data, find hotels, send emails, and be extended with new tools in minutes. More importantly, it demonstrates a pattern that scales — local and remote MCP servers running side by side, each contributing tools to the same assistant, with no custom integration code required on the client. This is the same MCP foundation that powers our broader agentic AI work.

Frequently Asked Questions

It’s a standard way to give an AI assistant real tools — a defined “button” it can press to fetch live data (like weather) or take an action (like sending an email), instead of guessing from training data.

Yes — this build proved it directly, running a local server and a remote, cloud-hosted server side by side in the same assistant configuration.

Every credential is loaded from a local .env file via python-dotenv, never hardcoded, with .gitignore keeping secrets out of version control entirely.

Typically minutes — each capability is a plain Python function with a one-line @mcp.tool() decorator, so the codebase is built to extend without restructuring.

Yes — if you want your AI assistant to check live data, talk to internal systems, or take real actions on your website, we design and build a custom MCP server for your workflow the same way we built this one.

Want an MCP Server Built for Your Business?

If you want your AI assistant to check live data, talk to your internal systems, or take real actions on your website, we can design and build a custom MCP server for your workflow — the same way we built this one.

Digital AI SEO AssistantAsk about our agentic AI services