Skip to content
Blog

MCP explained, then hardened

What the Model Context Protocol is as of the 2026-07-28 specification, a tool call on the wire, the attacks seen so far, and a hardening checklist for anyone connecting servers to agents.

Mohamad Al Assaad10 min read

The Model Context Protocol (MCP) is now how most major AI applications plug in outside tools and data. That makes it two things at once: a useful standard and a fresh attack surface. This post covers both. The first half explains the protocol for someone new to it. The second half covers how it breaks and what I would do about it. I have written a few MCP servers of my own, and the second half is the part I wish more tutorials started with.

1. What MCP is, and what it is not

Anthropic introduced MCP in November 2024 as an open standard for connecting AI assistants to the systems where data lives. Concretely, it is a set of JSON-RPC 2.0 messages that let an application ask a server “what can you do?” and then “do this”. That is all.

It is not:

  • A model or an agent framework. It does not plan, reason or loop. The application does that.
  • A security layer. It carries tool descriptions and results. It does not make them trustworthy.
  • Required. A function call inside your own code works fine without it (more on that at the end).

2. Hosts, clients and servers

The architecture has three roles:

  • Host: the application the user sees, such as a chat app or an IDE. It runs the model, enforces consent and decides what each server may see.
  • Client: a connector inside the host. Each client talks to exactly one server.
  • Server: a program that exposes capabilities. It can be a local process or a remote service.

One design principle matters for security: servers “should not be able to read the whole conversation, nor ‘see into’ other servers”. The host holds the full context and controls what crosses between servers. That isolation is only as good as the host’s implementation.

3. What a server offers, and what a client offers back

Servers expose three primitives, each with a different owner:

Primitive Who controls it Example
Tools The model Query a database, send an email
Resources The application File contents, git history
Prompts The user A slash command template

Clients can offer features back to servers: elicitation (ask the user for input, through a form or by sending them to a URL), sampling (ask the host’s model for a completion) and roots (tell the server which directories it may use). As of the current version, sampling and roots are deprecated, which I come to next.

4. Transports and the current version

Two standard transports exist. stdio runs the server as a subprocess and exchanges newline-delimited JSON over standard input and output. Streamable HTTP sends each message as an HTTP POST to one endpoint, with replies as JSON or a request-scoped event stream. Local servers usually use stdio; remote ones use HTTP.

As of October 2026, the latest specification is 2026-07-28. Its authors name “a stateless protocol core” as the highlight (MCP blog). The changelog lists the main changes:

  • No more sessions. The initialize handshake and the Mcp-Session-Id header are gone. Every request carries its protocol version and client capabilities in _meta, so any server instance behind a load balancer can answer any request.
  • Multi round-trip requests. Servers no longer send requests to clients. When a tool needs user input, the server returns resultType: "input_required" and the client retries with the answers attached.
  • Extensions. A formal extension mechanism, with Tasks (durable, pollable long-running calls) moved out of the core into an official extension, and MCP Apps (interactive UIs) shipping as another.
  • Authorisation hardening. Clients must validate the issuer (iss) of an authorisation response, credentials are bound to the server that issued them, and Dynamic Client Registration is deprecated in favour of Client ID Metadata Documents.
  • Deprecations. Roots, Sampling and Logging are deprecated, with a minimum twelve-month window before removal.

Structured tool output, where a tool declares an outputSchema and returns typed JSON in structuredContent, was already in the spec and is now loosened to accept any JSON Schema 2020-12 keyword.

5. Who runs it, and who uses it

Governance moved in December 2025, when Anthropic donated MCP to the Agentic AI Foundation, a directed fund under the Linux Foundation co-founded by Anthropic, Block and OpenAI. The maintainers keep technical control through the proposal (SEP) process. That is still the arrangement as of October 2026.

The same announcement listed first-class client support in ChatGPT, Claude, Cursor, Gemini, Microsoft Copilot and Visual Studio Code. OpenAI’s API also accepts remote MCP servers as a tool type. The project reports close to half a billion monthly downloads for its main SDKs; that is a self-reported figure.

There is an official MCP Registry for discovering public servers. It is still in preview. Note what it does and does not do: it verifies that a namespace such as io.github.alice/server belongs to its publisher, and it delegates security scanning of the code to npm, PyPI and downstream marketplaces. A verified name is not a reviewed server.

6. A worked example: one tool, two messages

Here is a minimal read-only tool. The schema does real work: the pattern rejects anything that is not an invoice ID, and additionalProperties: false rejects extra arguments.

{
  "name": "get_invoice",
  "title": "Invoice lookup",
  "description": "Return status, amount and due date for one invoice. Read-only.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "invoice_id": { "type": "string", "pattern": "^INV-[0-9]{6}$" }
    },
    "required": ["invoice_id"],
    "additionalProperties": false
  },
  "outputSchema": {
    "type": "object",
    "properties": {
      "status": { "type": "string", "enum": ["draft", "sent", "paid", "overdue"] },
      "amount_eur": { "type": "number" },
      "due_date": { "type": "string", "format": "date" }
    },
    "required": ["status", "amount_eur", "due_date"]
  }
}

The client discovers it with tools/list. Under 2026-07-28 the request carries its own version and capabilities, and the result carries cache hints (ttlMs of 300,000 is five minutes; private stops shared proxies caching it):

→ {"jsonrpc": "2.0", "id": 1, "method": "tools/list",
   "params": {"_meta": {
     "io.modelcontextprotocol/protocolVersion": "2026-07-28",
     "io.modelcontextprotocol/clientCapabilities": {}}}}

← {"jsonrpc": "2.0", "id": 1, "result": {
     "resultType": "complete",
     "tools": [ { "name": "get_invoice", "...": "definition above" } ],
     "ttlMs": 300000, "cacheScope": "private"}}

When the model decides to use it, the host sends tools/call. The result returns the same data twice: as text for older clients, and as structuredContent that the client should validate against outputSchema (tools spec):

→ {"jsonrpc": "2.0", "id": 2, "method": "tools/call",
   "params": {"name": "get_invoice",
              "arguments": {"invoice_id": "INV-004217"},
              "_meta": { "...": "same as above" }}}

← {"jsonrpc": "2.0", "id": 2, "result": {
     "resultType": "complete",
     "content": [{"type": "text",
       "text": "{\"status\":\"overdue\",\"amount_eur\":1840.5,\"due_date\":\"2026-09-30\"}"}],
     "structuredContent": {"status": "overdue", "amount_eur": 1840.5, "due_date": "2026-09-30"},
     "isError": false}}

One number to keep in mind before part two. Suppose a host connects five servers with twenty tools each, and each definition costs around 120 tokens. That is 5 × 20 × 120 = 12,000 tokens of tool descriptions the model reads before the user’s question. Every one of those tokens is text written by someone else, placed in the model’s instructions.

7. The attack classes, with dates

Tool poisoning and rug pulls. In April 2025, Invariant Labs showed tool poisoning: an add tool whose hidden description told the model to read ~/.cursor/mcp.json and ~/.ssh/id_rsa and pass them in a parameter. The same post described rug pulls (a server changes a description after you approved it) and shadowing (one server’s description changes how the model uses another server’s tool, without being called).

Prompt injection through tool results. In May 2025, Invariant Labs showed that a malicious issue in a public repository could make an agent using the official GitHub MCP server read the user’s private repositories and leak their contents in a public pull request. The authors stressed it was “not a flaw in the GitHub MCP server code itself”. The agent had a token that could read everything and a tool that could write publicly. I covered the general pattern in Prompt injection is a data problem.

Confused deputy and token passthrough. A server that proxies a third-party API can be tricked into handing an attacker an authorisation code when it uses one static client ID and skips per-client consent. The spec’s security best practices require per-client consent for such proxies, and on passthrough they are blunt: servers “MUST NOT accept any tokens that were not explicitly issued for the MCP server”. Forwarding the user’s token downstream breaks audit trails and every control tied to the token’s audience.

Over-broad scopes. The same document lists the common mistakes: publishing every scope, wildcard scopes such as files:*, and bundling privileges to avoid future prompts. A stolen broad token reaches every tool at once.

Malicious and name-squatted servers. In September 2025 an npm package called postmark-mcp, which Postmark says it had nothing to do with, shipped 15 clean versions and then, in 1.0.16, started silently copying every outgoing email to an outside address. It worked because people installed a plausible name.

Local servers with too much power. In July 2025, CVE-2025-6514 in mcp-remote (versions 0.0.5 to 0.1.15, CVSS 9.6) let a malicious server run commands on the client machine through a crafted OAuth URL. In 2026 the pattern has been local servers exposed over HTTP without authentication: CVE-2026-5029 in Code Runner MCP Server (May, unfixed at disclosure) and CVE-2026-48989 in Windows-MCP (June, fixed in 0.7.5), where an exposed PowerShell tool meant remote code execution.

8. A hardening checklist

  1. Allow-list servers. Only servers you named, from publishers you checked. A registry listing is not a review.
  2. Pin and review. Pin exact package versions or image digests. Store a hash of each tool description and refuse to run if it changes without re-approval. That closes rug pulls.
  3. Least-privilege scopes per tool. Start with read scopes and step up only when a write is attempted. Never use one token for everything.
  4. Separate read and write servers. A server that reads private data should not also post publicly. The GitHub case needed both in one session.
  5. Human confirmation for writes. The spec says there SHOULD be a human able to deny tool calls. For anything that sends, deletes, pays or publishes, make it a MUST in your host. OpenAI’s API requires approval by default for the same reason.
  6. Sandbox local servers. A container or similar with no home directory, no SSH keys, no network unless needed. Bind HTTP to localhost and require a token, or use stdio.
  7. Treat tool output as untrusted data. Validate it against outputSchema, strip instructions where you can, and never let a tool result widen the agent’s permissions.
  8. Log every call. Server, tool, arguments, result size, user, decision. You will need the trace; Agents need contracts covers what to record.

Common mistakes I see in configurations: npx -y some-server@latest in a config file, a personal access token with full scope pasted into an environment variable, and treating tool annotations such as “read-only” as facts. The spec says clients MUST treat annotations as untrusted unless the server is trusted.

9. When not to use MCP

MCP solves an integration problem: many hosts, many tools, written by different people. If the tool lives inside your own application, is called by your own agent and is maintained by your own team, a plain function call with a typed schema is simpler, faster and easier to secure. Reach for MCP when you want the same tool usable from Claude, ChatGPT and an IDE, or when you are consuming someone else’s system. Not before.

What this looks like in practice

  • Inside your own app: a function call. At the boundary between products: MCP.
  • Target 2026-07-28 for new servers; keep fallback for older clients.
  • Allow-list, pin, hash descriptions, review updates.
  • Narrow scopes, separate read from write, confirm every write.
  • Sandbox local servers and log every call.

Sources