What Is MCP? A Beginner’s Guide to the Model Context Protocol

On this page 14 sections
  1. Three words first: LLM, context, tool calling
  2. The problem: every app wires every tool its own way
  3. What MCP is
  4. Hosts, clients and servers
  5. What a server offers: tools, resources, prompts
  6. One question, end to end
  7. When a tool fails
  8. Try it yourself
  9. Common beginner mistakes
  10. Questions you will face in production
  11. Check your understanding
  12. What to remember
  13. What to study next
  14. Further reading

Kitebase’s support lead wants to ask Claude one thing: “What’s going on with KITE-142, and is there a help article I can send the customer?”

Claude can’t answer. It has never seen Kitebase’s tickets or help center, and it has no way to look.

So you write glue for your support bot. It’s a ticket-lookup function in the format Claude’s API expects. Then the team wants the same thing in Claude Desktop, which plugs things in its own way. Then an engineer wants it in Cursor. That’s the same lookup written as three integrations, and every new app or system multiplies the work.

MCP, the Model Context Protocol, fixes that. You write the Kitebase side once, as a small program called an MCP server. Any app that speaks MCP can then use it.

What you’ll build: an MCP server for Kitebase with two tools, search_help and get_ticket. You’ll also get a 100-line stand-in for Claude Desktop. It launches the server, shows what the model is given, and calls the tools for the question above. It runs offline. If you have an API key, Claude picks the calls itself.

Three words first: LLM, context, tool calling

If you’ve read the AI Engineering articles, skim this section.

An LLM (large language model) is a program that takes text in and writes text back. Claude is one. You call it over an HTTP API. You send the conversation and get a reply (Your First LLM Integration shows the call).

The model’s context is everything it can see in one request. That means your instructions, the conversation, and anything you pasted in. It’s all the model knows about your situation, and it can’t go and fetch more. (What LLMs Are covers the context window, the limit on how much fits.)

Tool calling is how you get around that limit. With your request, you send a list of functions the model may ask for. Each one has three parts:

  • a name
  • a description
  • a JSON Schema for its arguments

JSON Schema is a standard JSON format for saying “these fields, these types, these are required”. Instead of answering, the model can reply with a request like this:

{"type": "tool_use", "id": "toolu_01", "name": "get_ticket", "input": {"ticket_id": "KITE-142"}}

Your code runs get_ticket and sends the result back in the next request. The model carries on with the real ticket in its context. Note that the model never runs anything. It asks, and your code decides. Giving an Agent Tools goes deeper on writing good tools.

The problem: every app wires every tool its own way

Tool calling solves “the model can’t see Kitebase”, but only for one app. Your support bot defines get_ticket in Claude’s format and runs the loop. That code lives inside the support bot.

So nothing else can use it:

  • Claude Desktop can’t.
  • Cursor can’t.
  • A teammate’s bot on another model provider can’t either. Its API even names the schema field differently: parameters, where Claude’s calls it input_schema.

Each app needs its own Kitebase glue. And every other system you want to reach, like GitHub or your Postgres, needs its own glue in each app too.

WITHOUT MCP: 3 × 3 = 9 INTEGRATIONS Claude Desktop Cursor Your support bot Kitebase GitHub Postgres Each app writes its own glue for each system, in its own tool format. A 4th app means 3 more integrations. WITH MCP: 3 + 3 = 6 PIECES Claude Desktop MCP client Cursor MCP client Your support bot MCP client Kitebase MCP server GitHub MCP server Postgres MCP server One protocol in the middle. Each app speaks it once; each system ships one server. A 4th app means 1 more client.
Three apps and three systems: nine integrations without a shared protocol, six pieces with one.

This is the N×M problem: N apps times M systems. Three apps by three systems is nine integrations to write and maintain. A fourth app adds three more.

A shared protocol turns that into N+M. Each app speaks the protocol once, and each system implements it once. That’s six pieces, and a fourth app adds just one.

Isn't 6 versus 9 a small win?

At three by three, yes. But the gap grows fast. With 10 apps and 20 systems, it’s 200 integrations against 30.

The bigger win is who does the work. Without a standard, Kitebase has to wait for each AI app to build an integration, or build one per app itself. With a standard, Kitebase ships one server, and every MCP app can use it on day one.

What MCP is

MCP is an open protocol. A protocol is a published set of rules for how two programs talk, here an AI app and an outside program. It’s not a product you buy. Anthropic released MCP as an open standard on November 25, 2024. The spec, official SDKs and docs live at modelcontextprotocol.io.

The spec names its inspiration: the Language Server Protocol. That protocol lets any editor get Go autocompletion from one language server, instead of every editor writing its own. MCP does the same for AI apps.

MCP messages use JSON-RPC 2.0. It’s a small convention for sending requests as JSON:

  • Each request has a method name, params, and an id.
  • The response carries the same id back.

Nothing in it is AI-specific, so any language with a JSON library can speak MCP.

The spec is versioned by date. The current revision is 2026-07-28, and version 2 of the official mcp Python SDK targets it. The SDK puts that version string in every request for you.

Hosts, clients and servers

MCP has three roles. Here’s how they map onto the Kitebase setup:

  • The host is the AI app you use, such as Claude Desktop, Claude Code, Cursor, or your own support bot. It holds the conversation, talks to the model, and decides which servers to connect.
  • A client is the connection the host keeps to one server. Each client talks to exactly one server, so a host connected to two servers runs two clients. Clients are built into the host, and you rarely see them.
  • A server is the program that offers capabilities. Here that’s server.py, which looks up Kitebase tickets and searches its help center. Servers are what you’ll mostly write. Hosts already exist.
THE MODEL claude-opus-5 sees tool names, descriptions, schemas API HOST: CLAUDE DESKTOP THE CONVERSATION "What's going on with KITE-142, and is there a help article...?" CLIENT A talks only to kitebase CLIENT B talks only to github stdio stdin/stdout HTTP over the network KITEBASE SERVER python server.py tools: search_help, get_ticket resource: help/{slug} prompt: triage_ticket GITHUB SERVER remote, run by someone else tickets + help repos One client per server. The host keeps the conversation and talks to the model. Servers see only the calls sent to them: not the chat, not each other.
The Kitebase setup. The model only ever talks to the host.

Two things in that picture matter later:

  1. The model never talks to a server. The host sits in the middle of every call. That’s where it can ask you before a tool runs.
  2. A server only sees the calls sent to it. The spec’s design principles keep servers from reading the whole conversation or seeing into other servers. So the Kitebase server never learns what you asked GitHub.

The way the bytes travel between client and server is called the transport. The spec defines two:

  • stdio: the host launches the server as a child process. It writes one JSON message per line to the server’s standard input, and the server answers on standard output. This is how server.py runs.
  • Streamable HTTP: each message is an HTTP POST to one endpoint on a remote server. You’d use this when Kitebase hosts one server for all its customers.

Stdio has one big gotcha: standard output is the wire. The spec says a stdio server must not write anything to stdout that isn’t an MCP message.

Say you add print("looking up", ticket_id) to a tool. That text lands where the host expects JSON. The Python SDK’s client logs Failed to parse JSONRPC message from server and skips the line. Other hosts may not be so forgiving.

The fix is to log to standard error instead. Use print(..., file=sys.stderr), or the logging module, which writes to stderr by default. MCP Architecture covers transports and the message flow in depth.

What a server offers: tools, resources, prompts

A server can offer three kinds of things. The spec splits them by who decides to use each one:

PrimitiveWho decides to use itKitebase example
ToolsThe modelget_ticket(ticket_id), search_help(query)
ResourcesThe appkitebase://help/{slug}, the full text of a help article
PromptsThe usertriage_ticket, a ready-made instruction picked from a menu

Here’s what each one is:

  • A tool is a function the model can call. It’s the same idea as tool calling above.
  • A resource is data the host can read and put in front of the model. It’s addressed by a URI, a bit like a file path, such as kitebase://help/sso-login.
  • A prompt is a template the user picks from the host’s menu. Hosts often show prompts as slash commands.

Here’s the heart of server.py, using the official mcp Python SDK:

from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError

mcp = MCPServer("kitebase")

@mcp.tool()
def get_ticket(ticket_id: str) -> dict:
    """Look up a Kitebase ticket by id, like KITE-142. Returns its title, status and assignee."""
    ticket = TICKETS.get(ticket_id.strip().upper())
    if ticket is None:
        raise ToolError(f"No ticket {ticket_id!r}. Ticket ids look like KITE-142.")
    return ticket

@mcp.resource("kitebase://help/{slug}")
def help_article(slug: str) -> str: ...

@mcp.prompt()
def triage_ticket(ticket_id: str) -> str: ...

if __name__ == "__main__":
    mcp.run()  # stdio by default

TICKETS is a dictionary standing in for Kitebase’s API. search_help is written the same way as get_ticket.

The decorator does all the protocol work:

  • The function name becomes the tool name.
  • The docstring becomes the description.
  • The type hints become the JSON Schema.

The model reads that description to decide when to call the tool. So write it for the model: what the tool does, what the input looks like, and what comes back.

When in doubt, use a tool. Most servers are mostly tools, and every MCP host supports them. Add resources when the app should attach data itself. Add prompts only when your users would pick them from a menu. Tools, Resources, Prompts takes each one properly.

One question, end to end

Here’s the whole trip for the support lead’s question, with the real messages from the companion code:

CLAUDE the model HOST + ITS CLIENT Claude Desktop, or main.py KITEBASE SERVER server.py tools/list search_help, get_ticket + their schemas the question + 2 tool definitions tool_use: get_ticket {"ticket_id": "KITE-142"} tools/call get_ticket {"title": "Customer locked out after SSO…"} tool_result: the ticket JSON tool_use: search_help {"query": "locked out SSO"} tools/call search_help sso-login, account-recovery tool_result: those two lines answer: in progress with Priya; send sso-login CLAUDE'S API, NOT MCP MCP: JSON-RPC OVER STDIO Claude never talks to the server, and the server never sees the chat. The host passes each call along and hands the result back.
MCP is only the right half. The host translates between the two.

It starts before the first question. The host asks the server what it offers, with a tools/list request. The reply gives each tool’s name, description and input schema.

The host then turns those into the model’s tool format. For Claude, that’s three fields. Doing this is most of what main.py does as a host:

def to_claude_tools(mcp_tools) -> list[dict]:
    return [
        {"name": t.name, "description": t.description or "", "input_schema": t.input_schema}
        for t in mcp_tools
    ]

For get_ticket it prints:

{
  "name": "get_ticket",
  "description": "Look up a Kitebase ticket by id, like KITE-142. Returns its title, status and assignee.",
  "input_schema": {
    "type": "object",
    "properties": {"ticket_id": {"title": "Ticket Id", "type": "string"}},
    "required": ["ticket_id"],
    "title": "get_ticketArguments"
  }
}

That translation is why one server works everywhere. Kitebase describes get_ticket once, and each host converts it to whatever its model’s API wants.

Next, Claude replies with tool_use for get_ticket. The host turns that into a tools/call request and sends it down the stdio pipe. Here’s the real line, captured from the SDK’s client. I’ve trimmed the _meta block, which holds the protocol version and client details and is sent on every request:

{"jsonrpc": "2.0", "id": 3, "method": "tools/call",
 "params": {"name": "get_ticket", "arguments": {"ticket_id": "KITE-142"}, "_meta": {...}}}

The server replies with the same id and a result:

{"jsonrpc": "2.0", "id": 3, "result": {"content": [{"type": "text",
 "text": "{\"id\": \"KITE-142\", \"title\": \"Customer locked out after SSO change\", \"status\": \"in_progress\", \"assignee\": \"priya\", ...}"}],
 "isError": false, "resultType": "complete"}}

The host passes that text to Claude as a tool_result. Then the same thing happens once more:

  1. Claude asks for search_help.
  2. The host makes one more tools/call.
  3. Claude writes its answer from the two real results. The ticket is in progress with Priya, and sso-login is the article to send.

Nothing in the server knows which model asked, or which app it’s running in.

When a tool fails

Tools don’t always succeed. Ask for a ticket that doesn’t exist, and get_ticket raises ToolError. The SDK turns that into a normal result with isError: true:

-> tools/call get_ticket {"ticket_id": "KITE-999"}
is_error: True
Error executing tool get_ticket: No ticket 'KITE-999'. Ticket ids look like KITE-142.

The spec calls this a tool execution error. The call worked, but the tool didn’t. The message goes back to the model, so it can fix its input and try again.

That’s different from a protocol error. A protocol error means the request itself is broken. It comes back as a JSON-RPC error instead of a result.

Here’s the gotcha. If you raise any other exception, say a KeyError, this SDK treats it as a crash. The model gets only Error executing tool get_ticket, with no hint of what to change. The details stay in the server’s log.

So whenever the model could do better on a second try, raise ToolError. Give it a message that says what a good input looks like.

Is MCP just tool calling with extra steps?

No. They’re different halves of the same job:

  • Tool calling is how a model asks for a function. It’s part of each provider’s API.
  • MCP is how a host finds and runs functions that live in someone else’s program. It works the same way for every server.

The two meet in the host. It turns MCP tool definitions into tool-calling definitions, and tool-calling requests into tools/call messages. MCP also covers things tool calling doesn’t: resources, prompts and transports.

Try it yourself

The companion example has two files:

  • server.py is the Kitebase server.
  • main.py plays the host. It launches the server over stdio, just as Claude Desktop would. Then it lists what the server offers and calls both tools for the worked question.

Download the runnable example (zip)

cd 01-what-is-mcp
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python main.py

It prints three things:

  • the server’s tools, resources and prompts
  • the get_ticket definition shown above
  • the two tool results: the KITE-142 ticket, then sso-login and account-recovery

Then try these:

  1. In call_like_claude in main.py, change KITE-142 to KITE-999. You get the ToolError message back as a result, not a crash.
  2. Add print("looking up", ticket_id) to get_ticket in server.py and run main.py again. You’ll see Failed to parse JSONRPC message from server, because your print went down the wire. Change it to print("looking up", ticket_id, file=sys.stderr) (and import sys). Now it shows up as a harmless log line.
  3. Set ANTHROPIC_API_KEY and run it again. This time Claude gets the tool list and picks the calls itself. main.py prints each call before it runs. A run costs a few cents at most.

To use the server from a real host, point the host at the Python that has mcp installed. Claude Desktop’s claude_desktop_config.json and Claude Code’s project .mcp.json both use this shape:

{
  "mcpServers": {
    "kitebase": {
      "command": "/full/path/to/01-what-is-mcp/.venv/bin/python",
      "args": ["/full/path/to/01-what-is-mcp/server.py"]
    }
  }
}

Restart the host and ask it the KITE-142 question. Connecting to Claude Desktop, Cursor, Etc. covers each host’s setup.

pip install pytest && pytest -q runs the offline tests. They check the server three ways:

  • They call the tools as plain functions.
  • They connect to the server through the SDK’s in-process client.
  • They launch it over stdio once.

No key, no network.

Common beginner mistakes

  • Printing to stdout in a stdio server. Your debug line lands in the JSON stream. Log to stderr.
  • Relative paths in the host config. The host doesn’t launch your server from your project folder. So python server.py can’t find the file, or finds a Python without mcp installed. Use absolute paths to both.
  • Copying 1.x examples. Many tutorials start with from mcp.server.fastmcp import FastMCP. That’s the 1.x SDK. In 2.x the class is MCPServer, and the old import fails with an error pointing at the migration guide. The companion pins mcp>=2.2,<3.
  • Vague tool descriptions. “Gets a ticket” leaves the model guessing when to call it and what the id looks like. Say what it does, what the input looks like, and what comes back.
  • Plain exceptions for expected failures. The model only sees Error executing tool get_ticket. Raise ToolError with a message it can act on.

Questions you will face in production

“Is it safe to install someone else’s MCP server?” Treat it like any program you run. A stdio server runs with your permissions and can do anything its code does. The spec calls tools arbitrary code execution. It says hosts should keep a human in the loop who can deny a call.

So install servers from sources you trust, and prefer hosts that ask before running a tool. Also remember that tool descriptions are text the model reads. A hostile server can hide instructions in them.

“Local stdio server or remote HTTP server?” Start with stdio, since there’s nothing to deploy. Move to Streamable HTTP when many users need the same server and you don’t want each of them installing it. Kitebase offering one server to all its customers is that case. A remote server brings authentication with it. Connecting to Claude Desktop, Cursor, Etc. shows how hosts connect to remote servers.

“Should I write an MCP server or just use tool calling in my app?” If the only consumer is your own app, plain tool calling is less machinery. Write a server in two cases: when more than one host should use the same capability, or when you want people to use your product from the AI apps they already have.

Check your understanding

Your company uses Claude Desktop, Cursor and an in-house support bot, and wants all three to read from Jira and your Postgres. How many pieces do you write with MCP, and how many without?

Without a shared protocol, it’s 3 × 2 = 6 integrations.

With MCP, the apps already have clients (your bot gets one from the SDK). So you write or install 2 servers: Jira and Postgres. A fourth app costs nothing on the server side.

Claude calls get_ticket with "142" and gets back only "Error executing tool get_ticket". It tries "142" again. What should the server do differently?

The tool raised a plain exception, which the SDK treats as a crash and hides. Instead, raise ToolError("No ticket '142'. Ticket ids look like KITE-142."). The message reaches Claude as an isError result, and Claude can retry with KITE-142.

The Kitebase server is connected. Can it read what the user asked the GitHub server earlier in the chat?

No. Each server has its own client, and it only sees the calls the host sends it, like tools/call get_ticket. The conversation stays in the host, and servers can’t see into each other.

You want Claude to be able to look up a customer's plan and seat count on its own. Tool, resource or prompt?

A tool, say get_customer(customer_id), because the model decides when it needs the data. A resource needs the app to attach it. A prompt is a template the user picks.

What to remember

  • MCP is an open protocol that lets any AI app use any MCP server. It turns N×M integrations into N+M.
  • The host is the AI app. It holds the conversation and runs one client per server. The server is what you write.
  • Servers offer tools (the model decides), resources (the app decides) and prompts (the user decides). Start with tools.
  • Messages are JSON-RPC 2.0. tools/list finds the tools, and tools/call runs one. Use stdio for local servers and Streamable HTTP for remote ones.
  • The model never talks to a server. The host translates tool definitions and calls between the model’s API and MCP.
  • In a stdio server, stdout is the wire. Log to stderr. Raise ToolError with messages the model can act on.

What to study next

Next, MCP Architecture: Clients, Servers, Transports opens up the pipe between client and server. It covers the JSON-RPC messages and the two transports in detail. After that, Setting Up Your First MCP Server walks through building and registering a server step by step.

Further reading

Where this article comes from. This is a synthesis of common practice in AI engineering as of 2026, not a citation of any single paper. The sources above are where the broad mechanics and specific numbers come from. If you find an error or have a better source for a claim, send me a note and the article gets fixed within a day.


Auto-marks when you reach the end. Click to toggle.