liveBook · Manning

Chapter 13: Building and consuming MCP servers

What you will learn in chapter 13 of AI Agents and Applications

The chapter introduction explains why integrating external context into agents is difficult and presents MCP as a shared way to expose and use remote tools.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduction explains why integrating external context into agents is difficult and presents MCP as a shared way to expose and use remote tools.

Key terms: external context, tools, protocols, Model Context Protocol (MCP), MCP servers, MCP hosts, MCP clients, remote tools, public MCP portals

13.1 Introduction to MCP servers

The section explains why custom tool wrappers make external context integrations costly and how MCP offers a reusable alternative.

Key terms: external sources of context, tools, ad hoc protocols, wrappers, MCP, context providers, common protocol, custom glue code

13.1.1 The problem: Context integration at scale

This section explains why integrating external context sources into LLM agents becomes repetitive and difficult to scale.

Key terms: LLM agents, context source, wrapper tool

13.1.2 The solution: The Model Context Protocol

This section explains how MCP lets agents use tools exposed by servers through a standard client/server architecture.

Key terms: Model Context Protocol, MCP servers, tools, MCP host, MCP client, MCP server, remote MCP servers, Streamable HTTP, local MCP servers, STDIO

13.1.3 The MCP ecosystem

This section describes how growing adoption of MCP, service-provider servers, and public directories give agents access to a widening pool of tools.

Key terms: MCP servers, MCP server portals, shared library of tools

13.2 How to build MCP servers

This section introduces the upcoming guidance on resources, tools, and practices for building and integrating MCP servers.

13.2.1 Essential resources for MCP server development

The section identifies the official MCP documentation and SDKs as the starting resources for server development.

Key terms: official hub, MCP protocol specification, technology-agnostic, official language-specific SDKs, implementing MCP from scratch

13.2.2 Official language-specific MCP SDKs

This section identifies the official language-specific MCP SDKs and explains why the book uses FastMCP 2 for its Python examples.

Key terms: official SDKs, Python, FastMCP 1, FastMCP 2, Python SDK

13.2.3 Consuming MCP servers in LLM applications and agents

This section explains how applications can consume public MCP tools through OpenAI’s Responses API and what to use when MCP servers are accessible only within an organization.

Key terms: Responses API, public MCP servers, authorization strategy, FastMCP client, LangChain MCP client library, MultiServerMCPClient

13.3 Building a weather MCP server

This section previews replacing a mock weather tool with an AccuWeather-based MCP server, then testing and connecting it to an existing agent.

13.3.1 Implementing the MCP server

This subsection sets up and starts an AccuWeather MCP server to replace a mock weather tool, and explains its basic weather-lookup flow.

Key terms: AccuWeather API key, .env, mcp, accuweather_mcp.py, virtual environment, fastmcp, FastMCP 2, AccuWeather locations REST endpoint, current weather conditions

13.3.2 Trying out the MCP server with MCP Inspector

This section shows how to use MCP Inspector to connect to a Weather MCP server and verify its tool without writing client code.

Key terms: MCP Inspector, Node.js, npx, Streamable HTTP, Via Proxy, Authentication, Connected, Tools tab, List Tools, get_weather_conditions

13.3.3 Consuming the MCP server from a test MCP host

This section uses a lightweight MCP host to test that the weather server exposes a tool and returns a protocol-compliant result.

Key terms: MCP host, MCP client, MCP server endpoint, available tools, get_ weather_conditions, CallToolResult, tool-calling protocol

13.4 Integrating the Weather MCP tool into an agent

This section introduces the planned replacement of the travel agent’s mock weather tool with a live tool from a remote MCP server.

13.4.1 Preparing the travel agent for live weather data

This section prepares the travel agent to replace its made-up weather forecasts with a tool from an AccuWeather MCP server, using the mock agent’s behavior as a baseline.

Key terms: weather_forecast tool, WeatherForecastService, AccuWeather MCP server, remote tool, main_03_01.py, main_07_01.py, debug mode, mock data

13.4.2 Integrating the AccuWeather MCP tool

13.4.3 Updating the agent chat loop

13.4.4 Combining local and remote tools

This subsection brings AccuWeather MCP tools and a local semantic search tool together in an asynchronous agent.

Key terms: async main(), AccuWeather tools, local semantic search tool, MCP tools, chat loop

13.4.5 Testing and verification

This section shows how to verify that a travel agent has both local and remote tools available and actually calls its AccuWeather MCP tool.

Key terms: tools list, local and remote tools, AccuWeather MCP server, LangSmith trace

13.4.6 Using the agent for complex queries

This section suggests testing the travel agent with queries that combine travel information and live weather, and explains the value of its MCP weather tool.

Key terms: MCP server, weather tool, live weather data, local agent skills

13.5 Summary

The section summarizes how MCP standardizes agent access to external tools, how to build and test MCP servers, and how agents consume their tools alongside local ones.

Where this is used later

Concepts explained in this chapter

← Chapter 12: Multi-agent systems Chapter 14: Productionizing AI agents: Memory, guardrails, and beyond →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.