The MCP Layer: Exposing Tools to AI Models

Before there was a standard, wiring an AI assistant into your product meant writing glue. You described your operations in whatever function-calling format the assistant wanted, pointed the glue at internal endpoints, and hoped nobody renamed anything. The Model Context Protocol offers a common socket instead. LVD gives it a layer of its own, L6, and a firm rule about what that layer may know.

A second front door, built for models

MCP is an open standard for connecting AI agents, such as assistants built on large language models, to external tools and data sources. Where the API layer faces people and their applications, the MCP layer faces agents, using a structured, machine-readable protocol designed for invoking tools and exchanging context. Its volatility coefficient is 0.9, a little higher than the API layer's 0.85.

The book's argument for it is about coupling. Ad-hoc function-calling interfaces bind an agent tightly to a system's internal APIs. MCP establishes a standard adapter boundary instead: the agent discovers which tools exist, learns their schemas, calls them and receives structured replies, all without any knowledge of how your layers are arranged.

The dependency direction stays intact. MCP depends on Tools and below, while Tools remain unaware that MCP exists. A tool written last year, before anyone had thought of agents, can be offered to one today without being edited.

Defining a tool for a model reader

MCP tools are defined declaratively with a name, a description and a parameter schema. In an LVD system that schema is the same Layer 1 definition the tool already uses, so the contract is written once and reused at every door. The registration then joins a tool handler to those three things and translates between the protocol's content-based replies and the handler's domain-typed return value.

mcpServer.tool(
  "find-trail",
  "Search hiking trails by region, difficulty or maximum length",
  { region: z.string(), maxKm: z.number().optional() },
  async (params) => {
    const result = await findTrailHandler(params);
    return { content: [{ type: "text", text: JSON.stringify(result.data) }] };
  },
);

Everything inside that callback is translation. The handler does the real work, and the registration only reshapes its result. If you read the anatomy of a tool, you will recognise the payoff of the two-part result: the MCP layer takes what suits an agent from the same return value that a REST route takes its JSON from.

What comes back

MCP replies use structured content blocks rather than raw JSON. The book names three kinds:

  • Text: plain text or Markdown for the model to read.
  • Image: base64-encoded data with a MIME type.
  • Resource: a reference carrying a URI and a MIME type.

Typed blocks let an agent process results programmatically instead of parsing free text. The book's search example, for instance, returns a one-line summary in the first block and the full results serialised as JSON in the second, so the model gets a readable overview and a payload it can work with.

Serving it

The book's worked server uses the official TypeScript SDK. It creates one server object, registers several tools from the Tools layer, and binds the server to an HTTP route through the SDK's streamable HTTP transport. Look at what the file imports: the SDK, a schema library and tool handlers from Layer 4. There is no import from the API layer, because the MCP server goes straight to the tools.

That keeps the new protocol cheap. Adding an MCP front door to an existing system means writing a thin registration for each tool you want to expose, with no changes beneath it. The book also describes a distributed variant in which the MCP layer calls the API layer's endpoints instead, and we pick that up in the companion article on authentication.

The takeaway

The MCP layer is an adapter, no more and no less. It presents your tools to agents in a standard form, reuses the schemas you already have, and keeps your internal structure out of the agent's sight. Everything it needs comes from below. Once agents can reach your tools, you need to decide who is allowed to, and how to shape the tools so models choose well, which is the subject of MCP authentication and best practices. For the bigger picture of agents in this architecture, see LVD for AI-agent systems, and for the layer itself, the Layer 6 page.

What the book covers

  • A full MCP server built with the TypeScript SDK and a streamable HTTP transport
  • How Zod schemas from Layer 1 are reused as MCP tool definitions
  • The text, image and resource content types in tool responses
  • Tool-registration patterns that translate between handlers and MCP responses
  • How the MCP layer is tested alongside the API layer