Overview

3 Actions with Model Context Protocol for AI agents

The chapter introduces the Model Context Protocol as a standardized way for AI agents and LLM applications to connect to external tools, data sources, and even other agent workflows. It frames MCP as a kind of universal connector that reduces the friction of custom integrations, improves consistency, and makes agent systems easier to assemble, extend, and secure. By separating tool access from agent logic, MCP helps developers focus on building capabilities rather than reworking connectors for each model or platform.

It then explains the basic MCP ecosystem: clients discover and use capabilities exposed by servers, while servers mediate access to tools, resources, and prompts through JSON-RPC 2.0. The chapter contrasts local STDIO-based deployment, where a server runs as a subprocess with low latency and tight coupling to one client, with remote SSE-based deployment, where servers are network-addressable and can support shared access and distributed architectures. It also shows how MCP can support more than action tools alone, extending across reasoning, memory, and feedback layers in agent design.

Finally, the chapter demonstrates how to use MCP in practice by connecting Claude Desktop and OpenAI Agents SDK workflows to MCP servers, inspecting servers with the MCP inspector, and building simple servers that expose tools such as research sources or filesystem access. It shows how an existing agent with internal functions can be refactored into a reusable MCP server, then consumed locally or remotely with only minor code changes. Throughout, the chapter emphasizes control, validation, and safety, reminding developers that powerful tools require careful understanding because agents may act more broadly than intended if given unrestricted access.

The leading challenges AI Agent developers face when building agents include fragmented tool integration, inconsistant data access, complicated multiple-agent orchestration, and security and control.
A typical problem agent/LLM developers face when connecting to multiple services and resources is the lack of standardized connections and the need to support multiple different connectors to whatever services they need access to.
Implementing MCP as a service layer abstracts access to the various services that agent may want to connect to and use.
The basic components of MCP architecture are the client, server, and services. Here you can see some common clients (agents, LLM applications, Claude desktop, and VS code) and potential services (file operations, database queries, web APIs, and other agents) that the clients might connect to.
The main components of an MCP server include prompts, specialized system instructions; resources (used for access to files), configuration, and databases; and Tools, which are extensions of an internals agent’s ability to consume and use tools
The various deployment patterns that may be used to connect MCP servers to agents. From running locally and within a child process on the same machine, running remotely and accessible over HTTP to include hybrid architectures that blend local and remote MCP servers to single agent.
MCP can be used to add functionality in the form of tools to all the functional agent layers.
Claude desktop may consume multiple MCP servers deployed locally or remotely. The LLM that powers Claude then uses the MCP components (generally tools) to enhance its capabilities.
Shows the MCP server settings for Python file
Shows the MCP hosted tool being executed within Claude desktop
Shows the MCP Inspector interface examing available tools and executing them
The key differences between MCP tool execution from an LLM application (Claude Desktop) or through using an agent include; assistants require human supervision while agents are autonomous, assistants are interactive to agents programmatic, agents perform more complex multi-step workflows and assistants typically are limited to performing simple plans.
Shows the various ways an agent may interact with and consume MCP servers
The time tracker agent will record time events using internal function tools as it processes the events in a loop. After the loop finishes the agent is asked to summarize the events and it will use the Load Journal Evants tool to load the journal of events and summarize
The separation of tools from the agent into a standalone MCP server that could be hosted locally or remotely and access through STDIO (local) or SSE (remote). Now the agent registers the MCP server instead of individual tools and then internally discovers the tools the server supports and how to use those tools.

Summary

  • MCP = “USB-C for LLMs & agents.” A JSON-RPC-2.0 spec that erases bespoke glue code for tools, data sources, and even other agents.
  • MCP solves fragmentation (multiple tool schemas), brittle data access, ad-hoc orchestration, and uneven security by giving every capability a uniform interface.
  • MCP supports three components: Tools (actions), Resources (data/objects), and Prompts (re-usable templates). Agents can treat any of them as callable verbs.
  • MCP Architecture is in 3 parts: MCP Client, Server, and the Service/Resource it fronts. An agent is just one kind of client.
  • STDIO – sub-process, zero-latency, single caller (great for local development).
  • SSE – HTTP + Server-Sent Events, multi-client, cloud-friendly. Switching is literally a constructor swap.
  • MCP is not just for tools/actions but can support the other functional layers (Reasoning & Planning, Knowledge & Memory, Evaluation & Feedback)
  • MCP can be deployed using a mixture of patterns: Local, remote, or hybrid — mix and match to keep sensitive operations local while sharing heavy APIs remotely.
  • The MCP Inspector gives a live, clickable view of any server—perfect for debugging tool schemas and outputs before wiring agents to them.
  • MCP reference servers are available for use or inspection and include: filesystem, brave-search, google-calendar, github, etc.—all installable with a single npx or mcp run.
  • Agents themselves can be wrapped as servers, turning an entire reasoning pipeline into a reusable, strongly typed tool.
  • Typed Pydantic I/O flows end-to-end, eliminating fragile string parsing in multi-agent chains.
  • MCP enables LEGO-style composition of agent systems—each block isolated, testable, and instantly swappable without touching the others.

FAQ

What is Model Context Protocol (MCP) and why is it important for AI agents?MCP is an open standard, based on JSON-RPC 2.0, that lets AI systems connect to external services in a consistent, secure, and efficient way. It is important because it standardizes tool access, reduces custom integrations, and makes agent development more modular and reusable.
What problems did MCP solve for agent developers?Before MCP, developers faced fragmented tool integrations, inconsistent data access, complex multi-agent orchestration, and weak security/control across tools. MCP solves these issues by providing a unified protocol for connecting agents to external systems.
What are the main components of MCP architecture?The three core components are the MCP client, MCP server, and the service/resource. The client connects to the server, the server handles requests and exposes tools/resources/prompts, and the service is the underlying application or data source the server wraps.
What types of components can an MCP server expose?An MCP server can expose tools, resources, and prompts. Tools are actionable capabilities, resources represent external data or entities like files or databases, and prompts are predefined templates that guide interactions with tools and resources.
What deployment patterns are supported by MCP servers?MCP servers can be deployed locally using STDIO, remotely using SSE over HTTP, or in a hybrid setup that combines both. Local deployment is useful for low-latency single-machine use, while remote deployment is better for distributed and cloud-native systems.
How does Claude Desktop use MCP servers?Claude Desktop can connect to multiple MCP servers and consume their tools, resources, and prompts to enhance its capabilities. It requires human approval before executing tools, making it useful for exploring and testing MCP servers interactively.
How can you build a simple MCP server for Claude Desktop?You can use the FastMCP class, define a tool with the @mcp.tool() decorator, and install the server into Claude using the MCP CLI. Once configured, Claude Desktop can discover and run the tool from the server.
What is the difference between STDIO and SSE transport in MCP?STDIO runs the MCP server as a subprocess and communicates through stdin/stdout, which is ideal for local, private, low-latency use. SSE runs the server as an HTTP service and supports network access, multiple clients, and remote deployment.
How can an agent consume an MCP server locally or remotely?An agent can use MCPServerStdio to launch and consume a local server as a subprocess, or MCPServerSse to connect to a remote or separately running server over HTTP. In both cases, the agent registers the server and uses its discovered tools.
Why would you convert an agent’s internal tools into an MCP server?Converting internal tools into an MCP server separates concerns, improves reuse, and makes it easier to share the same capabilities across multiple agents. It also helps isolate actions and gives you more control over what the agent can do.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free