Model Context Protocol (MCP): Give Your AI Real Tools
Give your AI tools it can actually use. MCP is the USB-C of AI integrations — here's what it is and how to build one.
A model that can only talk is a novelty. A model that can call tools — search, query a database, read files — is an employee. MCP is an open standard that gives models a uniform way to discover and use your tools.
The mental model
MCP is a client-server protocol. An MCP server exposes tools and resources; an MCP client (Claude, an app, your own code) lets a model call them. Think of it as USB-C for AI integrations — one standard, many devices.
A tiny MCP server
# server.py (using the official SDK)
from mcp.server import Server
from mcp.server.stdio import stdio_server
server = Server("demo")
@server.tool()
async def add(a: float, b: float) -> str:
"Add two numbers."
return f"{a} + {b} = {a + b}"
@server.tool()
async def weather(city: str) -> str:
"Return the current temperature for a city (demo)."
return f"It's 24°C and clear in {city}."
async def main():
async with stdio_server() as (read, write):
await server.run(read, write)
if __name__ == "__main__":
import asyncio
asyncio.run(main())What the model sees
The client reads the server's tool list — names, descriptions, and parameter types — and the model uses those to decide which tool to call and with what arguments. Your description is the model's only guide, so write it carefully.
{
"tools": [
{ "name": "add", "description": "Add two numbers.",
"parameters": { "a": "float", "b": "float" } },
{ "name": "weather", "description": "Current temperature for a city.",
"parameters": { "city": "string" } }
]
}Real tools to expose
- A company knowledge-base search.
- Database queries with read-only access.
- File and document operations.
- Sending emails or creating tickets (with confirmation).
- Calling internal APIs.
Treat tools like a public API. Validate all inputs and gate destructive actions behind explicit user confirmation.
MCP is still young, but it's the direction the industry is moving. Building your tools against a standard now means they'll work with any model that comes next.
More from the lab
Classifiers, Regressors & Clusters: The 3 Shapes of ML
Almost every ML problem is one of three shapes — here's how to recognise and solve each with scikit-learn.
PythonAdvanced Python Data Structures for Interviews & Code
collections, defaultdicts, heaps and deques — the structures that show up in every interview and codebase.
AI & MLFine-Tuning a Large Language Model: A Realistic Guide
When fine-tuning is worth it, how LoRA works, and when RAG is the better answer.
Want us to build this for you?
We turn tutorials like these into production systems every day. Tell us what you need.
Start a project →