MCP is an open standard that lets any agent connect to any tool server. Learn its core pieces, stand up a tiny MCP server, and connect it to Claude so the model can call its tools.
Why: without a standard, every agent wires up every tool its own way; MCP (Model Context Protocol) is a common plug so a tool server written once works with any MCP-aware agent. When: use it to share tools across agents and apps instead of re-implementing them. Where: it is the same idea as USB — one connector, many devices.
MCP Host — The app the user interacts with (e.g. an IDE or chat app) that wants to use tools.MCP Client — The connector inside the host that speaks the MCP protocol to a server.MCP Server — The process that exposes tools (and data) — you write one to share your capabilities.Host (your app) ── Client ──MCP──► Server (exposes tools)
│
┌──────────┼──────────┐
search database files
Write the server once; any MCP host can connect to it.Why: standing one up shows how little it takes to expose a tool over MCP. When: any function you decorate becomes a tool any MCP client can discover and call. Where: install the MCP SDK first (pip install mcp); the decorator turns the function signature into the tool schema for you.
# pip install mcp
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("weather")
@mcp.tool()
def get_forecast(city: str) -> str:
"""Return a short weather forecast for a city."""
return f"Sunny, 24°C in {city}"
if __name__ == "__main__":
mcp.run() # now any MCP client can discover and call get_forecastWhy: the MCP connector lets the model call a remote MCP server's tools directly from the Messages API — Anthropic makes the connection server-side. When: point it at a hosted MCP server by URL and name. Where: you must pass both the server and a matching mcp_toolset entry, plus the beta flag.
response = client.beta.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
betas=["mcp-client-2025-11-20"],
mcp_servers=[{
"type": "url",
"url": "https://your-mcp-server.example.com/mcp",
"name": "weather",
}],
tools=[{"type": "mcp_toolset", "mcp_server_name": "weather"}],
messages=[{"role": "user", "content": "What's the forecast in Paris?"}],
)
print(text_of(response))Why: MCP servers can run next to you or far away, and the choice is about trust and access. When: run locally for desktop tools that touch your own files and apps; run remote for shared services many users hit. Where: local servers usually speak over stdio, remote ones over HTTP.
Local / Desktop -> runs on the user's machine; great for
filesystem, local apps, personal data (stdio)
Remote / Cloud -> hosted service shared by many users;
reached over HTTP, like the connector above
Pick local when the tools need the user's own machine; remote
when the capability is a shared service.