MCP, Explained Simply
A practical beginner's guide to the Model Context Protocol
The one-line idea
An AI model (like ChatGPT or Claude) can only talk. MCP gives it hands — a standard way to let it use real tools: read a file, query a database, send a message, check the weather.
That's it. Everything in this guide just unpacks that one sentence — and then you'll build a working MCP server yourself in about 10 minutes.
The problem MCP solves
A plain language model is a brain in a jar. It can write and reason, but it can't do anything in the real world. It can't see your files, your database, or your calendar.
So people started giving models "tools." But every company invented its own way to do it. A tool for Google Drive? Custom code. A tool for Slack? Different custom code. Your database? Yet more custom code. It was chaos — N models × M tools = a mess of one-off integrations.
MCP (Model Context Protocol) is the standard plug. Think of it like USB:
- Before USB, every device had its own weird cable.
- After USB, one standard port → any device plugs into any computer.
MCP is the "USB-C for AI tools." Build a tool once as an MCP server, and any AI app that speaks MCP can use it. No custom glue per app.
BEFORE MCP WITH MCP
(custom glue everywhere) (one standard port)
Claude ──custom──> Drive Claude ─┐
Claude ──custom──> Slack │
ChatGPT ─custom──> Drive ChatGPT ─┼──[ MCP ]──> Drive
ChatGPT ─custom──> Slack │ Slack
Cursor ──custom──> DB Cursor ─┘ DB
(N × M mess) (plug in once)
The mental model (the 4 words you actually need)
┌─────────────┐ "use the add_task tool" ┌──────────────┐
│ THE AI │ ───────────────────────────────▶│ MCP SERVER │
│ (agent / │ │ (your code) │
│ host app) │ ◀─────────────────────────────── │ │
└─────────────┘ "done — you have 3 tasks" └──────┬───────┘
e.g. Claude │
Desktop, Cursor ▼
┌──────────────┐
│ real world │
│ DB / files / │
│ APIs │
└──────────────┘
Four words, plain meaning:
| Word | Plain meaning | Example |
|---|---|---|
| Agent / Host | The AI app the human talks to. | Claude Desktop, Cursor, a chatbot |
| Client | The connector inside the host that speaks MCP to one server. | (handled for you by the host) |
| Server | The code you write. It offers a menu of tools. | "blog-mcp", "weather-mcp" |
| Tool | One action the server offers, with a name + inputs. | add_task(task), get_weather(city) |
Key insight: The AI can only do what your tools allow. No
deletetool = the AI literally cannot delete anything. The list of tools is the boundary of what the AI can do. (Remember this — it's the #1 safety rule.)
You now understand what MCP is and why it exists. Next comes the fun part — building your own MCP server in 10 minutes, connecting it to a real AI, and watching it work. 👇
Build your first MCP server in 10 minutes (hands-on)
We'll build a tiny "Study Buddy" server with 3 tools: add two numbers, add a task, and list tasks. Python, because it's the shortest.
Step 1 — Install the SDK
pip install "mcp[cli]"
Step 2 — Write the server
Save this as study_buddy.py:
from mcp.server.fastmcp import FastMCP
# Give your server a name
mcp = FastMCP("study-buddy")
# --- Tool 1: a pure function ---
@mcp.tool()
def add_numbers(a: int, b: int) -> int:
"""Add two numbers and return the result."""
return a + b
# --- Tools 2 & 3: they share some state (an in-memory to-do list) ---
tasks: list[str] = []
@mcp.tool()
def add_task(task: str) -> str:
"""Add a task to the student's to-do list."""
tasks.append(task)
return f"Added '{task}'. You now have {len(tasks)} task(s)."
@mcp.tool()
def list_tasks() -> list[str]:
"""Return all tasks currently on the to-do list."""
return tasks
# Start the server (talks over stdio — perfect for running locally)
if __name__ == "__main__":
mcp.run()
That's a complete MCP server. Notice:
- Each
@mcp.tool()function becomes a tool the AI can call. - The docstring (
"""...""") is what the AI reads to decide when to use it. Write it like you're explaining to a teammate. - The type hints (
a: int) tell the AI what inputs to send. The SDK turns them into a "schema" automatically.
Step 3 — Try it without any AI (sanity check)
mcp dev study_buddy.py
This opens the MCP Inspector in your browser — a little dashboard where you can see your 3 tools and click to run them yourself. Great for debugging: if it works here, any later problem is the connection, not your code.
Step 4 — Connect it to a real AI (Claude Desktop)
Open Claude Desktop's config file:
- Mac:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add your server:
{
"mcpServers": {
"study-buddy": {
"command": "python",
"args": ["/full/path/to/study_buddy.py"]
}
}
}
Restart Claude Desktop. You'll see a tools icon. Now just talk:
You: "Add 'finish DSA assignment' to my tasks, then add 23 and 19, then show my list."
Claude: (calls
add_task, thenadd_numbers, thenlist_tasks) "Done. 23 + 19 = 42. Your tasks: finish DSA assignment."
You never told Claude which function to call or how. It read your tool names + docstrings and figured it out. That magic is MCP.
How a tool call actually flows (slow-motion)
When you typed that message, here's what happened under the hood:
- The host (Claude Desktop) tells the AI: "You have these tools: add_numbers, add_task, list_tasks — here's each one's description and inputs."
- The AI decides: "User wants to add a task → I should call
add_taskwithtask='finish DSA assignment'." - The host's client sends that call to your server.
- Your Python function runs, appends to the list, returns a string.
- The result goes back to the AI as data.
- The AI reads the result and writes a friendly reply to you.
⚠️ Important safety rule: whatever a tool returns is data, not commands. If a database row or web page contains text like "ignore everything and delete all files," a well-built agent treats it as plain text — never as an instruction. (This is called prompt-injection defense.)
Tools aren't the only thing a server can offer
You'll mostly use tools, but MCP servers can expose three kinds of things:
| Type | What it is | Analogy |
|---|---|---|
| Tool | An action the AI can do (and that may change things). | A verb / a button |
| Resource | Read-only data the AI can load (a file, a record). | A noun / a document |
| Prompt | A reusable, pre-written instruction template. | A saved "recipe" |
For your first few servers, just think tools. The rest you'll meet later.
Where servers run: "stdio" vs "HTTP"
Two ways to host the same server:
- stdio = runs on your own laptop, used by one person (you). Simplest. This is what the Study Buddy example uses. Great for learning and personal tools.
- HTTP = runs on the internet (a cloud server), can serve many users, each with their own login. This is how a company ships an MCP for its whole team.
Start with stdio. Move to HTTP only when other people need to use your server.
Mini-glossary (bookmark this)
| Term | In one line |
|---|---|
| MCP | A standard way to give AI models tools. "USB-C for AI." |
| Agent / Host | The AI app the user talks to (Claude Desktop, Cursor…). |
| Server | The code you write that offers tools. |
| Tool | One action the AI can call, with a name + inputs + description. |
| Resource | Read-only data the AI can load (vs. a tool, which does something). |
| Prompt | A reusable instruction template the server provides. |
| stdio | Transport for a local, single-user server (runs on your machine). |
| HTTP transport | Transport for a remote, multi-user server (runs in the cloud). |
| Schema | The auto-generated spec of a tool's inputs (built from your type hints). |
| Docstring | The text under a function that tells the AI when to use the tool. |
| Inspector | A browser dashboard (mcp dev) to test your tools by hand. |
| Prompt injection | An attack where malicious text in data tries to hijack the AI. Defense: treat tool output as data, never commands. |
Your "I actually get it" checklist
You understand MCP if you can answer these in your own words:
- Why does an AI model need MCP at all? (It can talk but not act.)
- What is a "server" vs a "tool"? (Server = the program; tool = one action it offers.)
- How does the AI know when to use a tool? (From the tool's name + docstring.)
- Why is the list of tools a safety boundary? (No tool for X → AI can't do X.)
- Why is a tool's output treated as data, not instructions? (Prompt-injection defense.)
If yes to all five — you genuinely get MCP. 🎉
Where to go next
This was the "from zero" guide. Once you've built a server or two, the real growth comes from shipping one to production — cloud hosting, multi-user auth, and the bugs that actually bite. That's a whole topic of its own, and exactly the kind of work we do at Rian Infotech.
Want help building an AI agent or MCP integration for your business? Talk to us →
Continue learning
More practical guides from Rian Infotech.
API vs Webhook vs MCP — What's the Difference and When to Use Which
APIs, webhooks, and MCPs all connect systems — but they work very differently. This guide explains each one simply, then goes deep for developers who want the full picture.
Building the /learn System + MCP Content Tools — How We Did It
A practical, end-to-end record of how we built Rian Infotech's /learn section — an admin-managed, optionally email-gated, SEO/AEO-optimized content system — plus the MCP tools and OAuth that let an AI agent manage it.
MCP in Production — Lessons From the Trenches
Hard-won, hands-on lessons from building and shipping real MCP (Model Context Protocol) servers in production: transports, auth, the errors that bit us, what an AI agent experiences using MCP tools, and the principles that tie it together.