What is MCP? The Model Context Protocol explained simply
What MCP is, how hosts, clients and servers fit together, the three things a server can expose, and a working TypeScript server you can connect to Claude.
By Md Anjum Kamali · · 6 min read

On this page
MCP (Model Context Protocol) is an open standard that lets AI apps like Claude connect to outside tools and data through one common interface. You build a small program called an MCP server that exposes a few functions or files, and any MCP-compatible app can discover and call them. Think of it as a plug shape that every AI app and every tool agrees on.
MCP (Model Context Protocol) is a JSON-RPC based protocol, first released by Anthropic in late 2024, that defines how an AI application asks a server what it can do and then asks it to do those things.
I use it every day. Prospectee, the enrichment tool I co-founded, has an MCP server so people can run lookups from inside their AI assistant. My home server runs a Postgres + pgvector memory project that I expose through an MCP server, so Claude can read and write notes there. Neither of those needed a custom plugin per AI app. That's the whole point.
Why does MCP exist?
Before MCP, every AI app had its own way to add tools. If you wanted your product inside three assistants, you wrote three integrations. If an assistant wanted access to fifty tools, someone wrote fifty connectors.
MCP turns that M times N problem into M plus N. Tool builders write one server. AI apps write one client. They meet in the middle.
How does MCP work? Hosts, clients and servers
The MCP architecture spec names three roles.
| Role | What it is | Example |
|---|---|---|
| Host | The AI app the user is talking to. It owns the connections and decides what the model is allowed to touch. | Claude Desktop, Claude Code, an IDE |
| Client | A connector the host creates, one per server. | The piece inside Claude Code that talks to your GitHub server |
| Server | A program that exposes tools, data or prompts. Runs locally or on the internet. | A Postgres server, a Notion server, Prospectee's server |
One host can run many clients at once, and each client talks to exactly one server. The spec is strict about isolation: a server only gets the context it needs and can't read the full conversation or peek at other servers. The host stays in charge.
The current spec revision (2026-07-28) also made MCP stateless. Every request carries its own protocol version and capabilities, so there's no long-lived session to keep alive. That matters more for people running remote servers behind load balancers than for someone writing a weekend server, but it's worth knowing if you read older tutorials that start with an initialize handshake.
What can an MCP server expose?
A server can offer three kinds of things. The server concepts page is useful here because it says who controls each one.
| Primitive | What it is | Who decides to use it | Example |
|---|---|---|---|
| Tools | Functions the model can call | The model | search_companies, send_email, create_ticket |
| Resources | Read-only data the app can pull in as context | The app | A file, a database schema, API docs |
| Prompts | Reusable templates the user picks | The user | A /weekly-report slash command |
Most servers you'll meet are mostly tools. That's where the useful stuff happens: the model sees a list of tools with descriptions and input schemas, decides one fits, and asks the host to call it. Resources and prompts are handy, but plenty of good servers skip them.
What are MCP transports?
A transport is how the messages physically travel. The spec defines two standard ones.
- stdio. The host starts your server as a subprocess on the same machine and they exchange newline-delimited JSON over standard input and output. Good for anything that needs your machine, like local files.
- Streamable HTTP. Each message is an HTTP POST to one endpoint, and replies come back as JSON or a short-lived event stream. This is how remote servers work, including the hosted ones you add by URL.
One stdio gotcha catches almost everyone. Since stdout carries the protocol, a stray console.log() or print() corrupts the messages and the server breaks. Log to stderr instead.
How do I connect an MCP server to Claude?
There are three common routes, depending on where you work.
Claude (web and desktop)
Remote servers go in as custom connectors. Per Claude's help article on custom connectors, open Customize, then Connectors, click Add, choose "Add custom connector", give it a name and paste the server URL. Claude then walks you through sign-in if the server needs it. Free plans get one custom connector. On Team and Enterprise, an owner adds it for the org first.
Claude Desktop with a local server
Local stdio servers go in a config file. On macOS it's ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"days-until": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/days-until/build/index.js"]
}
}
}
Restart the app after saving. Use an absolute path. Relative paths are the most common reason a server silently doesn't show up.
Claude Code
This is what I use most. From the Claude Code MCP docs:
# remote server
claude mcp add --transport http notion https://mcp.notion.com/mcp
# local server (everything after -- is the command that starts it)
claude mcp add --transport stdio days-until -- node /ABSOLUTE/PATH/TO/days-until/build/index.js
Add --scope project and the config lands in a .mcp.json file you can commit, so your whole team gets the same servers. Type /mcp inside a session to see what's connected and to log in to servers that need it.
A minimal MCP server in TypeScript
Here's a full server with one tool. It follows the official build a server tutorial, which now uses the @modelcontextprotocol/server package. I built and ran this exact code against the current SDK before publishing.
1. Set up the project
mkdir days-until && cd days-until
npm init -y
npm install @modelcontextprotocol/server zod
npm install -D @types/node typescript
Add "type": "module" to package.json, and a tsconfig.json with "module": "Node16", "outDir": "./build" and "rootDir": "./src".
2. Write the server
src/index.ts:
import { McpServer } from "@modelcontextprotocol/server";
import { serveStdio } from "@modelcontextprotocol/server/stdio";
import { z } from "zod";
function createServer() {
const server = new McpServer({ name: "days-until", version: "1.0.0" });
server.registerTool(
"days_until",
{
description: "Count the days from today until a date (YYYY-MM-DD)",
inputSchema: z.object({
date: z.string().describe("Target date, e.g. 2026-12-31"),
}),
},
async ({ date }) => {
const ms = new Date(date).getTime() - Date.now();
const days = Math.ceil(ms / 86_400_000);
return {
content: [{ type: "text", text: `${days} days until ${date}` }],
};
},
);
return server;
}
serveStdio(createServer, {
onerror: (error) => console.error("Server error:", error),
});
console.error("days-until MCP server running on stdio");
Two details from the docs. serveStdio takes a function that returns a fresh server, because it may create more than one instance while it works out which protocol version the client speaks. And the only logging is console.error, which goes to stderr.
3. Build and test it
npx tsc
npx @modelcontextprotocol/inspector --cli node build/index.js \
--protocol-era modern --method tools/call \
--tool-name days_until --tool-arg date=2026-12-31
The Inspector should print a result with text like "59 days until 2026-12-31" (the number depends on the day you run it). Then add it to Claude with one of the methods above and ask "how many days until New Year's Eve?". Claude will see the tool, ask you to approve it, and call it.
If you prefer Python, the same tutorial has a version using the mcp package, where a tool is a plain function with an @mcp.tool() decorator.
What makes a good MCP server?
After building a few, these are the things that mattered most for me:
- Write tool descriptions for the model. It picks tools by reading them, so say when to use the tool and what it returns.
- Keep tools few and specific. Ten overlapping tools confuse the model more than three clear ones.
- Return compact text. Dumping a 2 MB JSON blob into context costs tokens and makes answers worse.
- Put limits in the server. If a tool can delete, make it require an ID, and never a wildcard.
- Scope credentials. The server acts with whatever keys you give it.
Where to go from here
Pick one thing you do by hand in a browser tab every day, like checking a dashboard or looking something up in your own database, and wrap it in a one-tool server like the one above. Once it works locally, you'll understand MCP better than any diagram can show you.
If you want to see where MCP fits in a bigger setup, I wrote about how I build products with Claude, and the next step after "Claude can call my tool" is usually building an agent around it. My memory server runs on the box described in my mini PC home server post.
Questions people ask
Is MCP the same as an API?
No. An API is whatever one service decides to expose, in its own shape. MCP is a standard wrapper that AI apps know how to talk to, so a server you write once works in Claude, Claude Code, Cursor and any other MCP client without custom glue. Most MCP servers call a normal API underneath.
Who created MCP and who owns it now?
Anthropic released MCP as an open standard in late 2024. In December 2025 Anthropic donated it to the Agentic AI Foundation, a fund under the Linux Foundation that Anthropic, Block and OpenAI co-founded. The maintainers stayed the same.
Do I need to code to use MCP?
Not to use one. In Claude you can add a remote MCP server as a custom connector by pasting its URL. You only need code if you want to build your own server, and the official SDKs make a small one about 30 lines.
Is MCP safe?
It's as safe as the server you connect. A server can read data and take actions with whatever access you give it, so only install servers you trust, keep tool approval prompts on for anything that writes or deletes, and give API keys the smallest scope that works.


