mcp-toolkit
Custom MCP server demonstrating the Model Context Protocol with tools for arithmetic calculation and weather lookup.
README
mcp-toolkit
A hands-on exploration of the Model Context Protocol (MCP) — the open protocol (created by Anthropic) that standardizes how AI applications connect to external tools and data sources. This repo implements both sides of the protocol: an MCP client and an MCP server, plus a test suite and CI.
Why this project
MCP is becoming the standard way AI assistants (Claude, and increasingly others) discover and call external tools — think of it as a plugin interface for LLMs. Rather than just reading about it, I built:
- A client that connects to Anthropic's official filesystem MCP server
- A custom MCP server exposing my own tools
- A client that talks to that custom server
- Unit + integration tests, and CI to run them on every push
Architecture
MCP protocol (JSON-RPC over stdio)
┌──────────────┐ ┌──────────────────────────────┐
│ client.py │ <────> │ @modelcontextprotocol/ │ (official,
│ │ │ server-filesystem (npx) │ Anthropic)
└──────────────┘ └──────────────────────────────┘
┌──────────────┐ ┌──────────────────────────────┐
│client_local.py│ <────> │ server.py │ (custom,
│ │ │ - calculate(expression) │ this repo)
│ │ │ - get_weather(city) │
└──────────────┘ └──────────────────────────────┘
Both clients follow the same MCP lifecycle:
- Spawn the server as a subprocess (stdio transport)
initialize— protocol handshakelist_tools— discover what the server can do, dynamically (no hardcoded knowledge of the server's capabilities)call_tool— invoke a tool by name with typed arguments
This is exactly what Claude Desktop does under the hood when you connect an MCP server.
Repo structure
mcp-toolkit/
├── server.py # custom MCP server (FastMCP) — calculate & get_weather
├── client.py # MCP client -> official filesystem server
├── client_local.py # MCP client -> server.py
├── sandbox_files/ # sample files used by client.py's demo
├── tests/
│ ├── test_calculate.py # unit tests: correctness + security
│ └── test_server.py # integration tests: tool registration & schemas
├── .github/workflows/tests.yml # CI: pytest on Python 3.10 & 3.12
├── requirements.txt
└── LICENSE
Getting started
git clone https://github.com/<your-username>/mcp-toolkit.git
cd mcp-toolkit
pip install -r requirements.txt
Run the client against Anthropic's official filesystem server:
python3 client.py
Run the client against the custom server built in this repo:
python3 client_local.py
Run the test suite:
pytest -v
Example output
$ python3 client_local.py
Connexion au serveur MCP maison (server.py)
✅ Session MCP initialisée
🔧 Outils disponibles :
- get_weather: Donne la météo actuelle (température, vent) pour une ville donnée.
- calculate: Évalue une expression arithmétique (+, -, *, /, %, **).
🧮 Appel de calculate(expression='12 * (3 + 4)') :
12 * (3 + 4) = 84
$ pytest -v
tests/test_calculate.py::TestCalculateNominal::test_addition PASSED
tests/test_calculate.py::TestCalculateNominal::test_power PASSED
tests/test_calculate.py::TestCalculateSecurity::test_rejects_function_calls PASSED
tests/test_calculate.py::TestCalculateSecurity::test_rejects_attribute_access PASSED
tests/test_server.py::test_registered_tools PASSED
...
21 passed in 0.49s
Engineering notes
A few things worth calling out for anyone reviewing this code:
-
Security-conscious tool design.
calculatedoesn't useeval(). It parses the expression into a Python AST and walks a restricted whitelist of node types (ast.BinOp,ast.UnaryOp, numeric constants), so arbitrary code execution isn't possible even though the input is a raw string. Covered by dedicated security tests intests/test_calculate.py(rejecting function calls, attribute access, name lookups, etc.). -
Default environment isolation. The MCP SDK does not forward the parent process's full environment to spawned servers by default — only a minimal safe subset (
get_default_environment()). Servers that need network access (likeget_weather, viahttpx) needenvpassed explicitly. This tripped up the first version of this project and is documented here so it doesn't trip up the next person. -
Tests don't require a live subprocess.
tests/test_server.pyexercises the server's tool registration and schemas directly through theFastMCPinstance (mcp.list_tools()), not by spawning a real stdio subprocess — faster and more deterministic for CI.
Connecting to Claude Desktop
To use server.py as a real MCP server inside Claude Desktop, add it to
your claude_desktop_config.json:
{
"mcpServers": {
"mcp-toolkit-demo": {
"command": "python3",
"args": ["/absolute/path/to/mcp-toolkit/server.py"]
}
}
}
Restart Claude Desktop and the calculate / get_weather tools become
available in conversation.
License
MIT — see LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.