GuideAgentic ways of working · Intermediate

MCP: connect agents to your tools and data

How the Model Context Protocol works in its 2026-07-28 revision, how to add servers to Claude Code, Claude, ChatGPT, Codex and other tools, how to build one with the official SDKs, and how to keep a server from becoming a back door.

Checked 13 Oct 202618 min read1 prompt1 hook

On this page
  1. What it is
  2. When to use it
  3. How a tool call works
  4. Members only: Set it up step by step
  5. Members only: Secure it: least privilege, poisoning and injection
  6. Members only: Recipes
  7. Members only: Patterns that work
  8. Members only: Mistakes to avoid
  9. Members only: Exercises

The Model Context Protocol (MCP) is an open standard for connecting AI applications to tools and data. You install or write a server once, and any MCP host that supports its transport can use it: Claude Code, the Claude apps, ChatGPT, Codex, GitHub Copilot in VS Code, Cursor, Gemini CLI and Microsoft Copilot Studio. The current protocol revision is 2026-07-28.

What it is#

MCP has three roles:

  • Host: the AI application you use, such as Claude Code, Claude Desktop or ChatGPT. The host holds the conversation, decides what the model sees and asks you for consent.
  • Client: one connection the host opens to one server. A host runs a client per server.
  • Server: a program that offers capabilities. It runs on your machine or as a web service.

A server offers three kinds of things:

PrimitiveWho decides to use itExample
ToolsThe model calls themsearch_issues, create_ticket, run_query
ResourcesThe app or you attach themA file, a database schema, runbook://disk-full
PromptsYou pick them, often as slash commands/mcp__github__pr_review 456 in Claude Code

A server can also ask you a question in the middle of a call (elicitation), for example to confirm an account. Servers never see the whole conversation or each other: the host passes each one only what it needs.

Messages are JSON-RPC, carried by one of two standard transports:

  • stdio: the host starts the server as a child process and talks to it over stdin and stdout. Use it for local tools. The server must never print anything else to stdout.
  • Streamable HTTP: every message is an HTTP POST to one endpoint, such as https://mcp.example.com/mcp. Use it for shared and hosted servers. The older HTTP+SSE transport is deprecated.

Authorization applies to HTTP servers and builds on OAuth 2.1. The server publishes OAuth Protected Resource Metadata (RFC 9728) so a client can find its authorization server. Clients should identify themselves with Client ID Metadata Documents; Dynamic Client Registration still works but is now deprecated. Tokens must be issued for that one server, travel only in the Authorization header and never be forwarded to another service. Local stdio servers read credentials from their environment instead.

1. The host app, an AI app or IDE, runs one MCP client per server. 2. Client 1 asks the local files server for a resource over stdio. The server reads local files and answers. 3. Client 2 calls a tool on the remote tickets server over HTTP. 4. The HTTP hop carries an OAuth token, and the server checks it before doing anything. 5. The server calls the ticketing API and returns the result to the host.Host appAI app, IDE or agentMCP clientMCP clientstdiolocal processHTTPOAuth tokenFiles serverMCP serverToolsResourcesPromptsTickets serverMCP serverToolsResourcesPromptsLocal filesTicketing APIClient 1 reads a resource from a local server over stdio.Client 2 calls a remote tool over HTTP. The server checks the token first.Every server offers tools, resources and prompts through one protocol.

The 2026-07-28 revision changed the plumbing more than the features. MCP is now stateless: there is no initialize handshake and no session ID, and every request carries its own protocol version and capabilities. Servers must answer server/discover. A server that needs input mid-call returns an "input required" result, and the client retries the request with the answer. Roots, Sampling and Logging are deprecated, and long-running tasks moved into an official extension next to MCP Apps (interactive UI inside the chat). You rarely notice: the official SDKs negotiate with older peers, so servers written for 2025 revisions keep working.

Anthropic donated MCP to the Agentic AI Foundation under the Linux Foundation on December 9, 2025. The project runs as "Model Context Protocol a Series of LF Projects, LLC", with maintainers, working groups and a public Specification Enhancement Proposal (SEP) process. Seats belong to individuals, not companies. The official MCP Registry at registry.modelcontextprotocol.io publishes metadata about public servers, with namespaces verified through GitHub or DNS. It is still in preview and does not scan code for security problems.

When to use it#

Use MCP when the agent needs live data or actions in a system it cannot see, and you would otherwise copy from that system into the chat:

  • Read and update tickets in your issue tracker while fixing the bug they describe.
  • Query a read-only replica of the analytics database during an investigation.
  • Pull a production error with its stack trace into a debugging session.
  • Give the same internal tool to Claude, ChatGPT and Copilot users without building three integrations.
  • Let each person sign in with their own account through OAuth, so the agent acts with their permissions instead of a shared key.

Something else often fits better:

You wantUse insteadWhy
A CLI the agent can already run, such as gh, kubectl or psqlA permission rule such as Bash(gh issue view *)No server to run, and the output is usually smaller
A procedure or house style the agent should followA skillInstructions load on demand and need no process
One web pageThe built-in web fetch toolNothing to install
A rule that must hold every timeA hook or a deny ruleThe runtime enforces it, not the model
A nightly batch jobA script or a routineDeterministic and cheaper

Mind the context cost. Every connected server adds tool names and descriptions to what the model reads. Claude Code defers MCP tool definitions by default and loads them through tool search when a task needs them. A host without deferred loading puts every definition in context upfront, so ten servers with 20 tools each can crowd out the code you want the model to read.

How a tool call works#

  1. At session start the host connects to each server and reads its tool list: names, descriptions and input schemas.
  2. You ask for something. The model reads the tool descriptions as part of its instructions and picks a tool.
  3. The host checks its permission rules and, if a rule or mode requires it, asks you to approve the call.
  4. The client sends tools/call with the arguments. The server validates them and runs the tool.
  5. The result goes back to the model as text or structured data, and the model carries on.

Steps 2 and 5 are where the risk lives. Tool descriptions are instructions the model follows, and tool results can contain text an attacker wrote. The members section shows how to set servers up in each tool, build your own, and defend both steps.

Set it up step by step

Claude Code Add a remote server over HTTP, then sign in from inside a session with /mcp if the server uses OAuth. From a plain shell, claude mcp login <name runs the same sign-in.

Members only below this line

Get the rest of this guide free

What you get on this page:

  • 1 prompt
  • 1 hook

Free. You also get Stratiflux Weekly: one email a week, unsubscribe anytime.

Also in the members part

  1. Secure it: least privilege, poisoning and injection
  2. Recipes
  3. Patterns that work
  4. Mistakes to avoid
  5. Exercises

Sources

Checked against these on 13 Oct 2026.

  1. MCP specification 2026-07-28: key changes (opens in a new tab)modelcontextprotocol.io
  2. MCP specification: architecture (opens in a new tab)modelcontextprotocol.io
  3. MCP specification: transports (opens in a new tab)modelcontextprotocol.io
  4. MCP specification: authorization (opens in a new tab)modelcontextprotocol.io
  5. MCP security best practices (opens in a new tab)modelcontextprotocol.io
  6. MCP local server security (opens in a new tab)modelcontextprotocol.io
  7. MCP official SDKs and tiers (opens in a new tab)modelcontextprotocol.io
  8. MCP Python SDK v2 documentation (opens in a new tab)py.sdk.modelcontextprotocol.io
  9. MCP TypeScript SDK v2 documentation (opens in a new tab)ts.sdk.modelcontextprotocol.io
  10. MCP TypeScript SDK: plug into a real host (VS Code, Claude Code, Cursor) (opens in a new tab)ts.sdk.modelcontextprotocol.io
  11. MCP Inspector CLI (opens in a new tab)modelcontextprotocol.io
  12. The MCP Registry (opens in a new tab)modelcontextprotocol.io
  13. MCP governance and stewardship (opens in a new tab)modelcontextprotocol.io
  14. Linux Foundation announces the Agentic AI Foundation (opens in a new tab)linuxfoundation.org
  15. Claude Code: connect Claude Code to tools via MCP (opens in a new tab)code.claude.com
  16. Claude Code: control MCP server access for your organization (opens in a new tab)code.claude.com
  17. Claude: add a connector that isn't in the directory (opens in a new tab)claude.com
  18. Claude: connector verification (opens in a new tab)claude.com
  19. Claude API: MCP connector (opens in a new tab)platform.claude.com
  20. OpenAI: connect and test your plugin in ChatGPT (opens in a new tab)developers.openai.com
  21. OpenAI API: MCP servers in the Responses API (opens in a new tab)developers.openai.com
  22. Codex: Model Context Protocol (opens in a new tab)learn.chatgpt.com
  23. Microsoft Copilot Studio: connect your agent to an existing MCP server (opens in a new tab)learn.microsoft.com
  24. Gemini CLI: MCP servers (opens in a new tab)github.com
  25. Cloudflare: MCP server portals are generally available (opens in a new tab)developers.cloudflare.com
  26. Docker MCP Gateway (opens in a new tab)docs.docker.com