What is MCP Server? A Beginner Guide to the Next AI Tool Protocol
MCP became the default way to connect AI models to tools in 2026, but most explanations stop at the analogy. This covers the problem it solves, the three primitives, how to run a server in ten minutes, and the security caveats.
📜 Table of Contents
📖 Keep reading
What Is an MCP Server? A Beginner's Guide to the AI Tool Protocol
MCP (Model Context Protocol), open-sourced by Anthropic in November 2024, standardises how AI models connect to tools and data sources. Think USB-C for AI.
The problem
Three AI apps and five data sources used to mean 3 x 5 = 15 integrations. MCP turns the matrix into a sum: each app implements a client once, each data source implements a server once - 3 + 5 = 8, and community servers are reusable.
Three primitives
| Primitive | What it is | Who controls it | Example |
|---|---|---|---|
| Tools | Functions the model may call | The model | Query a DB, send a message |
| Resources | Readable data identified by URI | App or user selects | File contents, schemas, logs |
| Prompts | Parameterised interaction templates | The user picks | Code review, weekly report |
Clients also support sampling (server asks the client to run a model), roots (which directories are in scope) and elicitation (server asks the user a question).
Transports
stdio for local processes - the client spawns the server and talks over standard input/output. Streamable HTTP for remote services, one endpoint with streaming; the earlier HTTP+SSE transport was superseded in the spec. Messages are JSON-RPC 2.0, with version and capability negotiation at handshake.
Running one in ten minutes
Point any MCP-capable client at a reference server. In claude_desktop_config.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/Documents"]
}
}
}
Restart the client, then ask it to summarise the three most recently edited files. The model chooses the tool and arguments itself.
Writing one in about 20 lines
pip install mcp
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("demo")
@mcp.tool()
def add(a: int, b: int) -> int:
"Add two integers"
return a + b
@mcp.resource("config://app")
def get_config() -> str:
return "env=prod, region=cn"
@mcp.prompt()
def review(code: str) -> str:
return f"Review this code for risks and fixes: {code}"
if __name__ == "__main__":
mcp.run()
Type hints become the JSON Schema; the docstring becomes the tool description. Debug with npx @modelcontextprotocol/inspector python server.py.
Writing tool descriptions the model can use
Name with a verb (search_orders, not orders). Describe when to use it, not only what it does. Enumerate allowed values and formats. Return structured errors with a hint instead of raising, so the model can correct itself.
Three security risks
- Tool poisoning - a third-party server hides instructions in its description. Read the source, prefer official or well-known repos.
- Prompt injection amplification - content inside a resource may say "ignore previous instructions". Label external content as data, minimise permissions, require confirmation for high-risk actions.
- Over-broad permissions - a filesystem server pointed at your home directory hands over everything. Mount only what is needed.
FAQ
Is MCP the same as function calling? No. Function calling is a model capability; MCP defines how tools are discovered, described and invoked.
Do I need Claude? No. It is an open protocol with multiple client and model implementations.
Can it reach a database? Yes - community servers exist for Postgres, MySQL and SQLite. Use read-only credentials in production.
How does remote auth work? The spec defines an OAuth-based flow; support varies by client and server.
Does it add latency? Local stdio overhead is small; the tool's own execution dominates. Watch context budget if you attach many tools.
The spec is still evolving - check the official specification and SDK docs.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.