Skip to content

Command Palette

Search for a command to run...

BLOG / MCPIntermediate

What is MCP? Model Context Protocol Explained for AI Engineers

MCP is the open standard that lets any AI agent use any tool server. How it works, its three primitives, transports, security and when plain function calls win.

Bhavin Mistry September 4, 2026 11 min readLast reviewed

Topics:MCP and tool use

Picture a function that queries Postgres. Before MCP you wrapped it once for OpenAI function calling, again for a LangChain tool, again for your own agent loop, and again when a second team wanted it in a different product. The wrapper was never the interesting part, and every copy drifted from the others. MCP exists to make that wrapper a thing you write once.

TL;DR

The Model Context Protocol (MCP) is an open, vendor-neutral standard for connecting AI applications to external tools, data and prompt templates. A server exposes capabilities over JSON-RPC; a client, usually an agent or an IDE, discovers them at runtime and calls them. You write a tool server once and any MCP-compatible client can use it, which removes the per-framework tool code that used to be the most duplicated part of an agent stack. It is worth adopting when tools are shared across more than one agent or product, when you connect to enterprise systems, or when you want a security boundary between the model and the systems it touches. It is not worth adopting for a single agent with two simple functions.

The problem MCP solves

Before MCP, every agent framework and every model vendor had its own way of describing a tool. A function that queried Postgres had to be wrapped once for OpenAI function calling, again for a LangChain tool, again for a custom agent loop, and again when a second team wanted it in a different product. The wrapper was never the interesting part, but it consumed real engineering time, and each copy drifted from the others.

The result was an N times M problem. N agents, M tools, N times M integrations. Every new tool had to be integrated into every agent. Every new agent had to re-implement every tool.

MCP turns this into N plus M. Each tool is served once. Each agent speaks the protocol once. After that, any agent can use any tool without either side knowing about the other in advance.

Before: N times M

  • Every agent re-implements every tool
  • Each copy of a wrapper drifts from the others
  • A new tool must be integrated into every agent

After: N plus M

  • Each tool is served once
  • Each agent speaks the protocol once
  • Any agent can use any tool without either side knowing the other in advance
The integration problem, before and after MCP

The three primitives

An MCP server can expose three kinds of capability. Most production servers use the first, some use the second, and the third is underused.

Tools

Tools are functions the model can call. Each has a name, a natural-language description, and a JSON Schema for its input. The description is what the model reads when deciding whether to call it, so it is the most important line of code in the server. "Query the customer database" is weak. "Look up a customer by email or customer ID and return their plan, status and open tickets. Use this before answering any billing question." tells the model when and why.

Tools can have side effects. A tool that creates a ticket or sends an email is a tool. The protocol has annotations for whether a tool is read-only or destructive, and a well-behaved client surfaces that to the user or to an approval step.

Resources

Resources are data the client can read, identified by a URI. A file, a database row, a log stream, a document. Resources are read-only from the model's point of view and are meant to be loaded into context by the application, not called like a function. A resource lets a client show a user "here is the document the agent is looking at" without the model having to fetch it through a tool.

Prompts

Prompts are reusable templates the server offers to the client. A server for a code review tool might expose a "review this pull request" prompt that takes a PR number and expands into a full instruction set. This is how a tool author ships the instructions that make their tool work well, instead of hoping every client writes them from scratch.

How a call actually works

The wire protocol is JSON-RPC 2.0. The sequence for a single session is short.

  1. Step 1: Initialise

    The client sends its protocol version and capabilities; the server replies with its own, so both sides know what the other supports

  2. Step 2: Discover

    The client asks for the list of tools, resources and prompts at runtime, so a server can add a tool without a client redeploy

  3. Step 3: Present to the model

    The client converts the tool list into the format its model expects. The model never sees MCP; it sees ordinary tool definitions

  4. Step 4: Call

    The client sends a tools/call request. The server validates arguments against the schema, executes, and returns text, images or embedded resources

  5. Step 5: Continue

    The client feeds the result back to the model as a tool response and the loop continues

One MCP session, step by step

The important design choice is in step three. MCP is a protocol between the application and the tool server. It is not a protocol between the model and the tool. That keeps it independent of any particular model vendor's function-calling format.

Transports

MCP defines how messages are framed, not how bytes move. Two transports are standard.

Standard input and output is for local servers. The client launches the server as a child process and exchanges JSON-RPC over stdin and stdout. This is how IDE integrations and desktop assistants typically run tool servers. It is simple, needs no network, and inherits the user's local permissions, which is both its strength and its risk.

Streamable HTTP is for remote servers. The client sends requests over HTTP and the server can stream responses back, including server-initiated messages. This is the transport for shared, hosted tool servers used by many clients, and it is where authentication and authorisation actually matter.

Choose stdio for developer tooling on one machine. Choose HTTP for anything shared, anything in production, and anything that touches an enterprise system.

  • If

    Developer tooling on one machine

    Choose

    Standard input and output

    Because

    Simple, needs no network, inherits the user's local permissions

  • If

    A shared tool server used by many clients

    Choose

    Streamable HTTP

    Because

    Supports streaming and is where authentication and authorisation matter

  • If

    Anything in production or touching an enterprise system

    Choose

    Streamable HTTP

    Because

    Give it authentication and its own credentials

Which transport?

What MCP costs you

Adopting a protocol is never free. Three costs show up in practice.

Latency. Every tool call is now a network hop, or at least a process boundary, with serialisation on both sides. For a chatty agent that makes twenty tool calls per task, that adds up. Measure it. Batch where the server allows it.

Operational surface. A hosted MCP server is a service. It needs deployment, monitoring, versioning, and an on-call owner. A function in your codebase needed none of that.

Discovery drift. Because clients discover tools at runtime, a server can change its tools underneath a running agent. That is a feature during development and a hazard in production. Pin server versions in production and treat a tool schema change like an API change.

Security: the part most teams skip

An MCP server is an execution boundary between a language model and real systems. Treat it like one.

  • Least privilege per server. A server that reads the CRM should have a read-only credential. A server that can write should be a separate server with its own audit trail, not a flag on the read server.
  • Validate inside the server. The JSON Schema protects you from malformed arguments, not from malicious ones. A file tool must refuse paths outside its allowed root. A SQL tool must not accept raw SQL from the model unless that is a deliberate, sandboxed decision.
  • Treat tool output as untrusted. Data returned by a tool can contain instructions aimed at the model. A web-fetch tool that returns a page saying "ignore your previous instructions" is the standard prompt-injection vector. Filter, label, or isolate tool output before it reaches the model.
  • Authenticate the client on HTTP servers. A remote MCP server with no authentication is an open API to your internal systems. Use the OAuth flow the specification describes, or at minimum a bearer token bound to a client identity.
  • Log every call. Tool name, arguments, caller identity, result size, latency. This is your audit trail when someone asks what the agent did on Tuesday.

For the broader guardrail model this sits inside, see Enterprise AI Guardrails.

When to use MCP, and when not to

Use MCP when

  • More than one agent, product or team needs the same tools
  • You connect to enterprise systems and want a controlled boundary between model and system
  • You want to buy or reuse tool servers rather than write them
  • Your IDE, desktop assistant or platform already speaks MCP

Skip MCP when

  • One agent, two or three simple functions, one codebase: native function calling is less code and latency
  • You are prototyping: make it a plain function first
  • A latency-sensitive path where an in-process call is measurably faster and the tool will never be shared
Use MCP, or keep it native

The rule of thumb: wrap a tool in MCP the day a second consumer appears, not before.

A minimal server, conceptually

A server needs four things: a name and version, a list of tool definitions with schemas, a handler that executes each tool, and a transport. In the official SDKs that is a few dozen lines. The parts that take real time are the descriptions, the input validation, and the permission model, none of which the protocol can write for you.

The MCP chapter walks through a complete server and client in the agentic workflows series.

Frequently asked questions

Is MCP tied to one model vendor? No. It was published as an open specification and has clients and servers across multiple model providers, IDEs and frameworks. The model never sees the protocol; the client translates.

Does MCP replace function calling? No. Function calling is how a model asks for a tool. MCP is how an application finds and runs tools. A client uses both: MCP to discover and execute, function calling to let the model choose.

Can an MCP server call another MCP server? Yes. A server can itself be a client of other servers. This is how aggregation and gateway servers work. Be careful with latency and with permission chaining.

How do I version a tool? The protocol does not version individual tools. Version the server, pin it in production clients, and treat a schema change as a breaking change with a new tool name if old clients still exist.

Is stdio safe in production? Stdio runs the server with the launching user's permissions on the same machine. It is fine for developer tooling. For shared or production use, run an HTTP server with authentication and its own credentials.

What are the three MCP primitives? Tools are functions the model can call, resources are read-only data identified by a URI that the application loads into context, and prompts are reusable templates the server offers to the client.

What does MCP cost me in practice? Three things: latency from an extra network hop or process boundary on every tool call, the operational surface of running a hosted server, and discovery drift when a server changes its tools under a running agent. Pin server versions in production.

How do I secure an MCP server? Use a least-privilege credential per server, validate arguments inside the server, treat tool output as untrusted, authenticate the client on HTTP servers and log every call with tool name, arguments, caller identity, result size and latency.

MCP and tool use

Your next step

Reading is the start. Turn it into skill: read the chapter, practise on something real, check the numbers, then follow a path.

  1. Read · ChapterModel Context Protocol (MCP)
  2. Practise · Debug challengeTool Error Cascade
  3. Use a free toolModel Explorer
  4. Follow a roadmapAgentic AI Engineer roadmap
All articles on MCP and tool use
#MCP#tools#agents#protocol#tool calling

Discuss this article

Got a question, a counter-example or a correction? Bring it to the community.

Join the discussion

Email updates

Enjoyed this? Get the next guide by email.

One email when something substantial is published. No digests, no daily drip. Unsubscribe in one click.

We will email you a confirmation link first, then send an occasional email when a substantial guide is published. Unsubscribe in one click. Stored on our own servers, never sold or shared. See the privacy policy.

Prefer a feed reader? Follow by RSS.