11MCP: Connecting Agents to Everything
The Model Context Protocol is the open standard for plugging tools and data into AI apps. Connect existing MCP servers, then build your own in about 20 lines of Python.
What you'll learn
- Explain MCP hosts, clients and servers
- Connect a ready-made MCP server to an AI app
- Build a simple custom MCP server
- Apply MCP security best practices
The problem MCP solves
Before MCP, every AI app needed custom code for every integration: one connector for Google Drive in app A, a different one in app B. The Model Context Protocol is an open standard — think of it as a USB-C port for AI. Build or install a connector once as an MCP server, and any MCP-compatible app can use it: Claude, Claude Code, Hermes Agent, n8n, VS Code, Cursor and many more.
What an MCP server can offer
| Capability | What it is | Example |
|---|---|---|
| Tools | Actions the model can call | create_invoice, search_orders |
| Resources | Data the app can read into context | A file, a database record, a price list |
| Prompts | Reusable prompt templates | “Weekly sales report” template |
Servers run either locally (the app launches them as a process — “stdio” transport) or remotely over HTTP, which is how hosted connectors for services like Notion or Asana work.
Connect a ready-made server
The official filesystem server lets an AI app read and write files — but only inside folders you allow. Most desktop hosts accept a config like this (the file location differs per app; check its docs):
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/you/ClientProjects"
]
}
}
}
With Claude Code, the same thing is one command:
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem ~/ClientProjects
Restart the app and ask: “List the files in my ClientProjects folder and summarize the newest proposal.”
Build your own MCP server (Python)
Expose your own business data as tools any agent can use. This server gives agents read access to invoices.
Install the SDK
terminalbash pip install "mcp[cli]"Write the server
invoice_server.pypython from mcp.server.fastmcp import FastMCP import csv mcp = FastMCP("invoices") def _load(): with open("invoices.csv", newline="") as f: return list(csv.DictReader(f)) @mcp.tool() def get_invoice(invoice_id: str) -> dict: """Get one invoice by its ID: client, amount in PHP, due date and status.""" for row in _load(): if row["id"] == invoice_id: return row return {"error": f"Invoice {invoice_id} not found"} @mcp.tool() def unpaid_total() -> str: """Total amount (PHP) of all unpaid invoices.""" total = sum(float(r["amount_php"]) for r in _load() if r["status"] == "unpaid") return f"PHP {total:,.2f}" if __name__ == "__main__": mcp.run() # stdio transport — the host app launches this processTest it with the MCP Inspector
terminalbash mcp dev invoice_server.pyA browser inspector opens where you can call each tool manually.
Register it in your AI app
mcp configjson { "mcpServers": { "invoices": { "command": "python", "args": ["/full/path/to/invoice_server.py"] } } }
Security: MCP servers are code you run
Key takeaways
- MCP is an open standard: build a connector once, use it in any compatible AI app.
- Servers provide tools (actions), resources (data) and prompts (templates).
- Local servers run as processes; remote servers run over HTTP.
- A custom server is ~20 lines with FastMCP — and deserves the same caution as any installed software.
Knowledge check
0 / 3Q1In MCP, what is the “host”?
The host is the AI app (e.g. Claude, Hermes) that connects to MCP servers via clients.
Q2Which MCP capability lets a model perform an action?
Tools are callable actions; resources are readable data; prompts are templates.
Q3Safest way to give an agent file access?
Least privilege: allow only the folders the task needs.