Leanpub Header

Skip to main content

Topics

Model Context Protocol

From hosts, clients and servers to stateless requests, trust boundaries and interfaces inside a conversation, the Model Context Protocol as told through the free samples of the Leanpub books about it.

Created from the free samples of 10 Leanpub books, with every source cited.

The Model Context Protocol (MCP) is an open protocol for connecting applications built on language models to external data, operations and reusable workflows.[1] An application that speaks it can discover what an outside system offers, read context from it, ask it to act and receive a structured result, all in one common form.[1] One of the sources compares it to a standard electrical outlet: the outlet fixes how a device connects and what both sides may assume, and it does not generate the electricity, judge whether the appliance is safe or repair the wiring.[1]

The protocol was published in November 2024 and was adopted within months by the main providers of language models and by widely used code editors.[3][7] It is young and still changing. The books written in the second half of 2026 all describe a revision dated 28 July 2026 that removed sessions from the protocol, and several of them teach the older form beside the new one because so much deployed software still speaks it.[2][1]

This article covers the origins of the protocol, its three roles and three kinds of capability, its messages and transports, the stateless redesign, the question of when the protocol is the right tool, security, the extension that puts interfaces inside a conversation, and the protocol's use in coding agents and IT operations. Its sources are the free samples of ten Leanpub books, all published in 2026. Two of those samples stop before the book reaches its chapter on the protocol, and the article says so where they are cited.

Where to start

A reader who has not met the protocol has two starting points. MCP A Complete Visual Guide (2026) assumes no experience of MCP and a general background in systems or software engineering, supports each concept with a diagram, and builds one example server for infrastructure operations from a read-only beginning; its sample holds the two chapters on the mental model and on roles and trust boundaries.[1] Accelerating Claude Code Workflows with MCP (2026) asks for comfort in a terminal and with configuration files, and no experience of AI tools or of the protocol, and teaches MCP as it is used from one coding agent.[4]

A developer who intends to build a server has two longer books. The Complete Guide to Building Production-Ready Model Context Protocol (MCP) Servers (2026) assumes a working software engineer with no knowledge of MCP or of JSON-RPC, implements servers in five programming languages, and is about servers only: it leaves out clients and hosts, and has no exercises.[2] Stateless MCP Servers in Action (2026) expects a reader who can write code and deploy services, works in Python, and arranges its sixteen chapters around one architectural decision, that a server keeps nothing in memory between requests.[3]

The remaining books each assume something more. MCP Apps for Claude (2026) is for web developers who know TypeScript and the browser and are new to MCP,[5] and Build MCP Apps with React (2026) expects the basics of React and TypeScript and says it is an introduction to neither React nor the protocol.[6] Building Autonomous IT Operations Agents with MCP (2026) is written for platform engineers, site reliability engineers and technical leaders,[7] and The AI Gateway Playbook (2026) for senior platform and infrastructure engineers who already know reverse proxies, managed identities and one major cloud.[10]

Origins

Before the protocol, a language model reached an outside system through an integration written for one framework or one model provider. Each framework had its own way of describing a tool's inputs and outputs, of handling errors and of managing authentication, so a tool built for one could not be used from another without wrapper code, and moving an application between frameworks meant rewriting every integration.[3] The fragmentation ran in both directions: a company with a well-designed internal API still wrote a separate wrapper for each model provider its developers used.[2] One source names the arithmetic, an N×M problem in which each of N applications needs its own connector to each of M systems.[4]

The protocol was designed by two engineers at an AI company who had met the problem while building development tools, and the company released it as an open standard on 25 November 2024, with software development kits for Python and TypeScript.[2] Its model was the Language Server Protocol, which had solved a similar problem for code editors: before it, each editor needed its own plugin for each programming language, and after it any editor that implemented the protocol could work with any language server.[3] A developer now builds a server once, and every compliant client can use it.[3]

Adoption was fast. Within months more than a thousand servers written by the community existed, and an official registry of public servers has been in preview since September 2025.[2] In December 2025 the protocol was donated to a foundation, where it is governed jointly by several large technology companies.[4]

The specification is published in dated revisions. After the initial release came a revision in March 2025, which introduced the Streamable HTTP transport and an authorisation framework based on OAuth 2.1; one in June 2025, which added structured tool output and a way for a server to ask the user for input; one in November 2025; and the stateless redesign of July 2026.[2]

Hosts, clients and servers

The architecture has three roles. A host is the AI application: it owns the user's experience, the interaction with the model, the decisions of policy and the life of every connection. A client is a component inside the host that speaks the protocol to exactly one server. A server is a focused service or local process that exposes selected capabilities.[1] The pairing of client and server is strict, so a host connected to five servers runs five clients, though hosts usually bundle their clients and the user never sees the distinction.[2]

The separation exists for control. The host decides which tool definitions and which content reach the model, and a server receives no automatic access to any other server: if data from one should shape a call to another, the host does the composing.[1] A server needs to know nothing about the model it serves, and can therefore be written in any language and run anywhere.[4] The visual guide argues for small servers, each covering one coherent domain, over a single server with access to cloud accounts, tickets, source control and production databases, because a single compromise of the large one reaches everything.[1]

The guide traces one request from end to end. A user asks why a service is unhealthy; the host decides which servers are relevant; the model selects a diagnostic tool from the catalogue; the host checks its policy; the client sends the call; the server validates the arguments, authenticates and authorises the caller, and queries the monitoring systems behind it; the result returns through the host to the model, which explains it. The protocol standardises the call and the result, and the discovery that precedes them. Every other decision remains with the host, the server or the systems behind the server.[1]

Tools, resources and prompts

A server offers three kinds of capability, and they differ in who chooses to use them. A tool is a callable operation that computes something or acts on an external system, and it is normally chosen by the model, under the host's policy. A resource is addressable data that the application reads and places in the model's context. A prompt is a message template that a user selects to begin a repeatable piece of work.[1] Being the chooser removes no control: the model may propose a tool call, the host can still require confirmation, and the server must still authorise it.[1]

Each tool has a unique name, a description of its purpose and a schema for its input, and the model decides when to call it from the conversation and the description.[3] The description is therefore part of the design. In the booking example of MCP Apps for Claude the description lists the valid room names so that the model never has to guess one, a malformed date is rejected by the schema before the function runs, and the error for an unknown room lists the rooms that exist, which is what the caller needs next.[5] The visual guide warns against wrapping an existing API one endpoint at a time, which exposes implementation detail and produces an oversized catalogue, and prefers tools shaped around tasks.[1]

Resources are read-only, are addressed by URI, and can be listed, read and watched for changes.[3] Prompts usually appear in the host as commands that a user invokes explicitly; they are implemented less often than the other two kinds, and one source values them as a way for a team to encode its practices in reusable templates.[4][3]

Messages and transports

Every message is a JSON-RPC 2.0 message, a single JSON object, and the protocol adds method names and parameter schemas without changing that envelope.[2] A request names a method, such as the one that lists a server's tools or the one that calls a tool, and carries an identifier that the response repeats, so that a client can match results to requests when several are in flight. A notification is a request without an identifier, used for events that need no answer, such as a change in the list of tools or progress on a long operation.[2] The protocol is stricter than its base in two respects: an identifier may not be null, and the batch form, in which several requests travel as one array, has not been supported since the revision of June 2025.[2]

The format of a message is separate from the means of carrying it. Two transports cover almost every case. With stdio the client launches the server as a subprocess and exchanges messages over its standard input and output, one to a line, which suits servers that work on the same machine as the host. With Streamable HTTP each message is an HTTP POST to a single endpoint, and the reply is either a JSON object or a stream of events for a longer operation.[4] Since the 2026 revision an HTTP request also carries the method and the name of its target in headers, so that a gateway, a rate limiter or a firewall can route and meter the traffic without parsing its body.[4]

The stateless protocol

In its first revisions the protocol had sessions. A client opened one with an initialisation request that declared its protocol version and capabilities, the server answered with its own, and only then could ordinary requests begin.[2] The revision of 28 July 2026 removed the handshake. Every request now carries the protocol version, the client's identity and the client's capabilities in its metadata, and the server processes it without reference to any earlier request. A client that wants to know a server's versions and capabilities in advance may ask through an optional discovery request, or may simply send a real request and handle a version error if one returns.[2]

The same revision ended requests from server to client. A server that needs something more from the user no longer opens a second exchange in the middle of the first: it returns a result marked as requiring input, and the client sends the original request again with the answers attached.[2] Three features that had been part of the core were deprecated, with a window of at least twelve months before removal, and long-running tasks moved out of the core into an extension.[2] Capabilities remain a strict contract in both forms: each side declares what it supports, and a request that relies on something undeclared is a protocol error.[2]

Because older clients remain in use, a server usually serves both forms, telling them apart by how a client opens.[2] The authors of MCP Apps for Claude report what this meant in practice in September 2026: installing the new development kit did not make their server speak the new revision, a server set up as the quick-start guide showed refused it outright, and one handler function, mentioned in few tutorials, served both forms from the same code.[5]

Stateless MCP Servers in Action makes the case for the design from the side of operations. A server that holds sessions in memory cannot be scaled out without routing each client back to the same instance, loses every conversation in progress when an instance crashes, and has to be drained of connections before each deployment. A stateless server can be replaced or multiplied freely, since any instance can answer any request.[3] The price is deliberate design: state is moved to databases and caches, requests are made to carry their own context, and long operations use queues and polling.[3] The book concedes the temptation, since conversations run over many tool calls and some tools, such as a code execution environment that accumulates variables, are stateful by nature.[3]

Stateless describes the protocol and not the application. The visual guide's image is a parcel, which carries its own address and tracking number although the delivery company keeps large databases behind it. A server may hold plans, jobs and records, provided that the state is stored deliberately and authorised on every use: the identifier of a plan is an ordinary argument to a tool, and is no proof that the caller may apply the plan.[1]

When the protocol fits

The sources agree on what the protocol is not. It is not an AI framework, since inference, memory and the orchestration of agents belong to the client application; it is not a runtime, since it sandboxes nothing; and it does not replace REST or gRPC, which a server commonly calls to do its work.[3] The visual guide sets it beside its neighbours one by one. A REST API often remains the interface behind the server; a software development kit is a common dependency inside one; retrieval of documents may be offered through resources or tools, with the protocol as the boundary and not the ranking method; and an agent framework may run inside a host that speaks the protocol to its integrations.[1]

The guide gives conditions for using it. The protocol adds most when capabilities should be discovered and not hard-coded, when the host needs one layer of consent and policy across integrations, and when a team wants to change a server independently of the applications that use it. It adds little when one application calls one stable API, or when the operation is fully deterministic and gains nothing from a model's choosing.[1] The two can coexist, as when an application reads its monitoring system directly for a fixed dashboard and exposes a smaller diagnostic subset through the protocol for conversational investigation.[1]

Adoption has costs, which the same chapter lists: vague or overlapping tools are selected badly, long descriptions and large resources consume the model's context and add latency, clients and servers on different revisions need testing, and the server needs an owner, versioning and monitoring like any other service. The guide's summary is that a protocol does not erase the cost of integration and moves it toward a reusable contract.[1]

Security and trust

The first of the misconceptions the visual guide corrects is that the protocol makes an integration safe. A server that exposes an unrestricted shell command or a broad cloud credential is as dangerous inside the standard wrapper as outside it, and a description that says a tool should not be misused enforces nothing: the server must reject an invalid or unauthorised call itself.[1] The guide treats host, client and server as separate domains of trust. A host should not assume a server is honest because it speaks the protocol, a server should not assume every host is equally trusted, and the output of the model is untrusted input to the host.[1]

The transports differ in what they protect. For HTTP the protocol defines no authentication of its own and builds on OAuth 2.1.[3] A local server over stdio is a child process of the host, and the guide is plain that stdio is not a sandbox: the process has whatever permissions the operating system gave it at launch, so a server that needs one configuration directory should not inherit the whole home directory and every environment variable.[1] In a server shared by several tenants a broad scope is not enough, and each request has to be checked against the verified caller and tenant, so that a guessed address or identifier cannot cross from one tenant to another.[1]

Practical AI Security Engineering (2026) opens with incidents. In one, from August 2025, a compromised package in a build system used AI command-line tools to steal about two thousand access tokens and more than twenty thousand files; in another, a month later, an update to a widely installed email server for the protocol silently copied every message an agent sent to an attacker for two weeks before it was noticed.[8] The book lists compromised tools and servers, which it calls tool poisoning, among the attacks particular to agents, and observes that the reach of such a compromise extends to every credential and system the server can touch.[8]

Hosts add controls of their own. A tool can carry annotations that say whether it only reads or could cause damage, and MCP Apps for Claude records how one host treated them: a tool marked read-only still began at a setting that asked the user's approval on first use, from which the authors conclude that a hint describes a tool and grants no permission.[5] Agentic Coding Harnesses, Compared & Explained (2026) makes the general point that a typed tool call is the natural place for a permission boundary, because every action the model takes passes through a named, structured call that the surrounding program can allow, ask about or refuse, and prose offers no such checkpoint.[9]

MCP Apps

A tool result was at first text and data for the model to read. MCP Apps, an official extension of the protocol, lets a server answer with a small interface shown inside the conversation.[5] It came from two earlier projects that had solved the same problem in different ways; a proposal merged them, and the maintainers announced the result in January 2026 as the first official extension.[5] The reason for it is that text answers a question well and serves action badly: a person who wants to sort, filter or book has to type another request for each step.[5]

The mechanism is a tool linked to a resource. The tool's metadata names a resource holding an HTML page; a host that supports the extension calls the tool, fetches the page through the protocol and shows it in a sandboxed frame, passing it the result.[6] The page may then call the server's tools, and those calls always go through the host and never straight to the server.[5] Build MCP Apps with React describes four participants where a casual description sees a frame attached to a tool call: the server, which owns validation, the rules of the domain and lasting effects; the host, which brokers messages and supplies context such as the colour theme; the view, which has none of the host page's authority; and the model, which explains and routes and is the source of truth for no score, approval or recorded decision.[6]

Two rules of design follow. The text of the result is a fallback interface and not a loading message, since a host without the extension, a screen reader or a log may see nothing else, so the text and the structured data are generated from the same result and may not contradict each other.[6] And a change is made only by the server: in that book's example a button in the view calls a second tool, visible to the view alone, and the view shows confirmation only after the server has validated the decision and returned a receipt.[6]

MCP Apps for Claude adds the host's side of the arrangement. The server declares, and the host decides whether to ask before a call, whether a message from the interface is sent, which external domains load, how tall the interface may be and whether an organisation allows such servers at all.[5] Its rule of thumb is to build an interface when typing the follow-up request would be an annoyance, and it lists the poor fits: long content, deep navigation, nested scrolling, menus, and a chat box inside the chat.[5]

Coding agents, operations and gateways

The protocol is most often met through coding agents. Agentic Coding Harnesses, Compared & Explained explains such agents through the harness, the program around the model that executes its tool requests, and treats MCP as the layer through which tools are registered: because tools are declared by schema, a new one can be added and used by the model without the harness being rewritten, which the book calls the whole premise of the protocol.[9] Its chapter on the protocol is not in the sample; the contents show it building a minimal server in Python and treating every tool as a capability to be secured, and a later chapter covers the pressure that tool results put on the model's context.[9]

Accelerating Claude Code Workflows with MCP starts from that limit of context. A model's window is finite, filling it with everything it might need to know about a development environment is impractical, and the alternative is to define actions the model may take and let it choose the relevant ones.[4] When the agent starts, it creates a client for each configured server and asks each for its tools, the definitions become part of the model's context beside the agent's built-in abilities, and a server can announce a change to its list without a restart.[4]

Building Autonomous IT Operations Agents with MCP applies the protocol to one domain. Its argument for the protocol is composability, since an operations agent gains an ability by connecting to another server and not by having its core rewritten, together with the separation of the reasoning layer from the tool layer.[7] It describes autonomy as a spectrum of five levels, from manual operation through fixed automation and recommendation to agents that act within defined boundaries under human oversight and, last, agents bounded by policy and not by a rule for each action.[7] The chapter it calls its most important covers least privilege, approval gates, limits on the extent of damage and defences against prompt injection, and the book says that chapter should be read before any agent is deployed to production.[7]

At the scale of a whole organisation the protocol becomes one part of a larger system. The AI Gateway Playbook describes an in-house gateway between a codebase and its model providers, with a registry of models, access without static keys, quotas and cost accounting. One of its eight chapters, which the sample does not reach, places a server in front of more than ninety internal tools, with OAuth 2.1, encrypted secrets, masking of personal data and an audit of every tool invocation.[10]

Questions about Model Context Protocol

Which Model Context Protocol book should I start with?

MCP A Complete Visual Guide assumes no experience of the protocol, and its sample holds the chapters on the core terms and on the roles of host, client and server.[1] A developer who means to build a server can go to The Complete Guide to Building Production-Ready Model Context Protocol (MCP) Servers, which assumes a working engineer new to MCP and covers the server side only.[2]

What is the difference between a host, a client and a server in MCP?

The host is the AI application, which owns the user's experience, the model and the decisions of policy; a client is a component inside the host that speaks to exactly one server; and a server exposes selected capabilities.[1] A host connected to five servers runs five clients.[2]

What is the difference between tools, resources and prompts?

A tool is an operation that the model normally chooses to call, a resource is addressable data that the application reads into the model's context, and a prompt is a template that a user selects.[1] Tools act and may have effects, while resources are read-only.[3]

Does MCP replace REST APIs?

No. A server commonly calls REST or gRPC APIs to do its work, and the protocol standardises only how an AI client discovers and invokes capabilities.[3] When one application calls one stable API, the protocol adds little.[1]

Is an MCP server safe to use because it follows the standard?

No. A server that exposes an unrestricted shell command or a broad credential is as dangerous inside the standard wrapper as outside it, and safety comes from constrained tools and authorisation on the server.[1] A local server over stdio is not sandboxed and runs with the permissions it was launched with.[1]

What does it mean that MCP is stateless?

Since the revision of 28 July 2026 there is no opening handshake, and every request carries its protocol version and the client's capabilities.[2] Any instance of a server can therefore answer any request, while the application behind it may still keep state in databases and authorise it on each use.[3][1]

Sources

Every source is a Leanpub book or course. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.

  1. 1.
    MCP A Complete Visual Guide, Reiner Braun: Complete Guide: Foundations Through Production Operations Free sample: the introduction, chapter 1 on the core terms, comparisons and misconceptions, and chapter 2 on roles, statelessness and trust boundaries. 2026. Free sample: PDF · EPUB
  2. 2.
    The Complete Guide to Building Production-Ready Model Context Protocol (MCP) Servers, Steve Publications: From First Principles to Enterprise Deployment Free sample: the introduction, chapter 1 on hosts, clients, servers, capabilities and the protocol's history, and the start of chapter 2 on JSON-RPC messages. 2026. Free sample: PDF · EPUB
  3. 3.
    Stateless MCP Servers in Action, Steve Publications: Designing, Building, and Operating Scalable Model Context Protocol Infrastructure Free sample: the introduction and chapter 1 on the problem the protocol addresses, what it is and is not, and stateful and stateless servers. 2026. Free sample: PDF · EPUB
  4. 4.
    Accelerating Claude Code Workflows with MCP, Steve Publications: A Beginner-to-Advanced Guide to the Model Context Protocol Free sample: the introduction and chapter 1 on the context problem, the three roles, the three kinds of capability and the transports. 2026. Free sample: PDF · EPUB
  5. 5.
    MCP Apps for Claude, Sandeep Kumar Patel: Build interactive UI inside the conversation Free sample: the preface, chapter 1 on what MCP Apps are and where they suit, and most of chapter 2 on tools, annotations, transports and the development kit. 2026. Free sample: PDF · EPUB
  6. 6.
    Build MCP Apps with React, Tintcairn Studio: A Project-Based TypeScript Guide to Interactive Dashboards, Forms, and Tool UIs for AI Chat Hosts Free sample: the opening, chapter 1 on the four participants and the pattern of a tool linked to a UI resource, and the start of chapter 2 on authority and trust. 2026. Free sample: PDF
  7. 7.
    Building Autonomous IT Operations Agents with MCP, Steve Publications: A Practical Guide to Designing, Deploying, and Operating Production-Grade Agentic AI for IT Infrastructure Free sample: the introduction, with an outline of the seventeen chapters, and the start of chapter 1 on levels of autonomy. 2026. Free sample: PDF · EPUB
  8. 8.
    Practical AI Security Engineering, Steve Publications: Building and Operating Secure AI Systems in Production Free sample: the introduction, with its account of recent incidents, and the start of chapter 1 on the attack surface of AI systems. 2026. Free sample: PDF · EPUB
  9. 9.
    Agentic Coding Harnesses, Compared & Explained, Yohan J. Rodríguez: Master Claude Code, Aider, OpenCode, Goose, and Codex — Then Run Them Locally Free sample: the preface and the opening of chapter 1; the chapter on the protocol is not in the sample and is cited from the table of contents. 2026. Free sample: PDF
  10. 10.
    The AI Gateway Playbook, Sanghyeok Y: Building a Production LLM Gateway with Auth, Quotas, Cost Control, and MCP Free sample: the front matter, with a map of the chapters, and the opening chapter on why model traffic differs; the chapter on the protocol is not in the sample. 2026. Free sample: PDF

Further reading

Other books in the library on the same ground, not cited above.

  • Mastering the AI Coworker, Robert Nash: Principles for running an AI coworker in a one-person studio One developer's operating model for working with an AI coding agent, with a chapter on when to plug the protocol in and when the author shelved it. 2026. Free sample: PDF
  • TypeScript in the AI Era, Steve Publications: Building Modern Applications with Type-Safe Code and Intelligent Systems TypeScript for applications that use AI, with one section on building servers for the protocol in TypeScript. 2026. Free sample: PDF · EPUB
  • The Complete Guide to Becoming an AI Expert in 7 Days with Claude Code, Steve Publications: From Beginner to Advanced AI-Powered Productivity, Automation and Software Development A seven-day course in one coding agent, which reaches servers for the protocol on its sixth day. 2026. Free sample: PDF · EPUB
  • Python AI Programming, Second Edition, GitforGits | Asian Publishing House: Kickstart developing AI-ready apps with RAG, DSPy, MCP, agents, evals, observability and open-source models Building AI applications in Python on existing models, with a server for the protocol among the things added to one growing application. 2026.

This is an article created from the free samples of 10 Leanpub books. We're building these articles to provide you, the Leanpub reader, with a good jumping-off point to discover more Leanpub books that are interesting and relevant to you. We never use material which is paid-only when building these articles: we only use material which is already free on Leanpub. However, Leanpub authors can opt out from inclusion in articles from their book settings page.

Updated November 2026.

In the Leanpub store: 25 books in the Model Context Protocol category

All topics