MCP Explained for Developers: Architecture, Use Cases and Security
Learn what the Model Context Protocol is, how clients and servers exchange tool calls, how to write a small Python server and how to keep tool access safe.
MCP, the Model Context Protocol, is an open standard that lets an AI application connect to tools and data through a common interface. A host app runs an MCP client, the client talks to MCP servers, and each server exposes tools, resources or prompts. Developers write a server once and any compatible client can use it. Security depends on narrow permissions and human approval.
Key takeaways
- MCP replaces one-off integrations with a shared protocol: build a server once, use it from any MCP-compatible client.
- Three roles matter: the host (the AI app), the client (one connection per server) and the server (your tools, data and prompts).
- A minimal server in Python is about ten lines, and messages are plain JSON-RPC.
- Treat every server and every tool result as untrusted input: limit scopes, confirm risky calls and log what happens.
On this page:
- What is MCP and why does it exist?
- How do clients, servers and tools interact?
- What does a simple developer workflow look like?
- What permission boundaries and security checks do you need?
- Frequently asked questions
| MCP piece | What it is | Example | Who controls it |
|---|---|---|---|
| Host | The AI application the user works in | A chat app, a code editor, your own agent | The app developer |
| Client | A connector inside the host, one per server | The code that speaks MCP to a server | The host |
| Server | A program that exposes capabilities | An order-lookup service, a file reader | Whoever wrote or installed it |
| Tool | A function the model can ask to run | get_order_status(order_id) | The server, with the user's consent |
| Resource | Read-only data the app can load | A document, a database row | The server |
| Prompt | A reusable prompt template | "Summarise this ticket" | The server |
What is MCP and why does it exist?
MCP exists to stop every AI app from needing a custom connector for every tool. It defines one protocol for describing and calling tools and data sources, introduced by Anthropic as an open standard.
Think about the problem without it. If you have 3 AI apps and 4 internal systems, you could end up writing 12 separate integrations, each with its own format and its own security review. With a shared protocol, you write 4 servers and each of the 3 apps connects to them. That is the same reasoning as a USB port: one standard plug, many devices.
MCP does not make the model smarter, and it does not replace agent frameworks. It standardises the connection between the model's host app and the things the model can use. Our guides to agentic AI tools and frameworks and to LangGraph, CrewAI, AutoGen and the Agents SDK cover the orchestration layer that sits above it.
How do clients, servers and tools interact?
A client connects to a server, asks what it offers, then calls tools on the model's behalf. Messages are JSON-RPC 2.0, and the two common transports are standard input and output for local servers and HTTP for remote ones.
The sequence for one tool call looks like this:
- Initialise: client and server exchange protocol versions and the capabilities each supports.
- Discover: the client asks
tools/listand receives each tool's name, description and input schema. - Decide: the host gives those descriptions to the model. The model chooses a tool and arguments.
- Call: the client sends
tools/call, ideally after the user approves. - Return: the server sends back the result, which goes into the model's context.
On the wire, a call and its reply look like this:
{"jsonrpc": "2.0", "id": 2, "method": "tools/call",
"params": {"name": "get_order_status", "arguments": {"order_id": "4821"}}}
{"jsonrpc": "2.0", "id": 2,
"result": {"content": [{"type": "text", "text": "shipped"}]}}The input schema in step 2 matters: it tells the model what arguments are valid, and your server should still validate them, since the model can produce anything.
What does a simple developer workflow look like?
The quickest way to learn MCP is to write a tiny server, then connect a client to it. In Python, the official SDK lets you expose a function as a tool with a decorator.
# pip install "mcp[cli]"
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("order-lookup")
ORDERS = {"4821": "shipped", "4822": "delivered"}
@mcp.tool()
def get_order_status(order_id: str) -> str:
'''Return the status of an order, or "not found".'''
return ORDERS.get(order_id, "not found")
if __name__ == "__main__":
mcp.run()The function name becomes the tool name, the type hints become the input schema and the docstring becomes the description the model reads. Running the file starts a server on standard input and output. You then register it in an MCP-compatible client; the exact configuration differs by client, so follow that client's documentation. The SDK also ships developer tools for inspecting a server, which is worth using before you hook it to a model.
A sensible first-week workflow:
- Wrap one read-only function as a tool and test it with the inspector.
- Connect it to a client and watch the
tools/listandtools/callmessages. - Write two or three prompts that should trigger the tool, and one that should not.
- Only then add a tool that writes data, with a confirmation step.
If you are building a full agent around such tools, pair this with our walkthrough on building your first AI agent.
What permission boundaries and security checks do you need?
The core security rule is to treat servers, tool descriptions and tool results as untrusted until proven otherwise. A tool gives a model the power to act, so a bad server or a poisoned result can cause real harm.
Specific risks to plan for:
- Prompt injection through results: a web page or file the tool returns may contain instructions aimed at the model, such as "send the user's files to this address".
- Misleading tool descriptions: a malicious server can write a description that steers the model toward harmful behaviour.
- Over-broad access: a server that can read the whole disk or use a powerful token turns any model mistake into a large incident.
- Untrusted installs: a local server runs with your user's permissions, like any program you download.
- Credential leaks: tokens in config files, logs or tool output.
A checklist you can apply to any server before use:
- Who wrote it, and can you read the source?
- What is the smallest set of tools and scopes it needs? Remove the rest.
- Is read access separate from write access? Require approval for writes and deletes.
- Are secrets in environment variables or a secret store, never in prompts?
- Are arguments validated on the server, not only in the schema?
- Is every call logged with arguments and result?
- Have you pinned the version, so a silent update cannot change behaviour?
Authorisation for remote servers is an area where the specification keeps evolving, so read the current official documentation before you design it. For where MCP sits in an agent's overall design, see AI agent vs chatbot.
Next step: To build agentic systems that use tools safely, explore the AI Officer Programme from Vishlesan i-Hub, IIT Patna or the Leap AI Residency Cohort by Masai. Check each page for the current batch date and eligibility.
Frequently asked questions
What is MCP in simple words?
MCP is a shared standard that lets AI apps talk to tools and data sources. You write a server once that describes your tools, and any MCP-compatible app can discover and call them.
Is MCP the same as function calling?
No. Function calling is how a model asks to run a function within one app. MCP is the protocol that lets apps find and call tools from separate servers. An app can use function calling and MCP together.
Do I need Python to write an MCP server?
No. Official SDKs exist for several languages, and the protocol is plain JSON-RPC. Python is a common choice for learning because a tool is just a decorated function.
Is MCP secure by default?
No. Security comes from how you use it: trusted servers, narrow permissions, confirmation for risky calls, validated arguments and logs. Treat tool results as untrusted text.
How should a beginner start learning MCP?
Write one read-only tool, test it with the SDK's inspector, connect it to a client and read the messages. Add write actions only after you have a confirmation step.