liveBook · Manning

Chapter 7: Tool integration and MCP

What you will learn in chapter 7 of Building Reliable AI Systems

This introduction explains why connecting AI assistants to external systems becomes fragile at scale and presents MCP as a standardized alternative to one-off integrations.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why connecting AI assistants to external systems becomes fragile at scale and presents MCP as a standardized alternative to one-off integrations.

Key terms: glue code, one-off integrations, Model Context Protocol (MCP), standard, plug-and-play connectivity

7.1 What is MCP?

The section illustrates how custom integrations can make an AI assistant fragile and why integration complexity grows as organizations use many data sources.

Key terms: custom Stripe integration, Slack webhooks, N×M integration nightmare, integration complexity

7.2 The hidden complexity: The N×M problem

This section shows why connecting each AI application separately to every external API creates a growing integration and maintenance burden.

Key terms: N×M problem, custom glue code, custom integrations

7.3 The solution: MCP

This section explains how MCP standardizes connections between AI apps and tools while leaving tool execution and endpoint security to developers.

Key terms: MCP server, MCP client, plug-and-play integration, execution logic, boilerplate, interface, schema validation, error formatting, authentication, authorization

7.4 Building your first real MCP tool with a CSV-powered product catalog

Introduces a CSV-backed product catalog as a practical starting point for building and testing an MCP tool.

Key terms: CSV file, product search tool, product catalog

7.4.1 Loading your product catalog

This subsection sets up a CSV product catalog as a simple source of truth for testing product search.

Key terms: products.csv, source of truth, in-memory database, id, title, price

7.4.2 Setting up the MCP server

This section explains how to expose a CSV-backed product search as an MCP tool and return results in a format an LLM can use.

Key terms: FastMCP, pandas, MCP-compatible tools, search_products, DataFrame, search query, price limit, list of dictionaries, JSON-like data

7.5 Running and testing your server

This section shows how to start the MCP server and test its product-search tool from a command-line prompt.

Key terms: FastMCP, Server-Sent Events (SSE) server, MCP clients, tool calls, mcp-dev, MCP tools, empty list, in stock

7.5.1 Why this matters

This section explains why a data-backed MCP product-search tool is a foundation for an AI shopping assistant.

Key terms: MCP tool, search_products, product data, max price

7.5.2 Next steps

The section establishes that the completed MCP server serves real product data to MCP-compatible AI models, then previews model-driven tool use.

Key terms: MCP server, MCP standard, product data

7.6 Teaching your AI to use MCP tools

This section explains why an MCP tool needs a clear, standardized interface before an LLM can use it effectively.

Key terms: LLMs, tools, MCP

7.6.1 How models learn what tools they can use

This section explains how an MCP server makes its tools discoverable to a model without manually supplying each tool’s schema.

Key terms: MCP server, /tools/list, tools array, schemas, declarative tool provider

7.6.2 A complete example: Model > MCP > answer

The section traces a product-search request from plain language through MCP tool discovery and execution to a grounded answer, while warning about unapproved tool calls.

Key terms: MCP server, /tools/list, schema, search_products, tool call, OpenAI runtime, require_approval, never, always, custom approval logic

7.6.3 What you didn’t have to write

This subsection contrasts manual tool integration with hosted MCP’s declarative tool exposure and automatic discovery.

Key terms: hosted MCP support, glue code, discover, permission, expose capabilities declaratively

7.6.4 Tool design becomes interface design

This section explains why an MCP tool schema is an interface for a language model, not just a definition of a backend service.

Key terms: MCP server, language-model API surface, tool schema, self-documenting

7.7 Adding a second tool: Inventory status

The section distinguishes product search from inventory lookup and shows how the two MCP tools can serve a customer’s question together.

Key terms: search_products, check_inventory, MCP server

7.7.1 How models chain tools

Shows how a model answers a two-part product question by calling search and inventory tools in sequence, without hand-written orchestration.

Key terms: tool chaining, search_products, check_inventory, tool descriptions, orchestration code

7.7.2 Tool descriptions guide model behavior

Clear, specific tool descriptions help a model choose the right tool for a task.

Key terms: tool descriptions, search_products, check_inventory, discovery, verification, routing instructions

7.8 Handling failures gracefully

This section explains why MCP tools need clear, structured failure responses so an AI model can respond helpfully when tools fail.

Key terms: MCP tools, structured information, clear error responses, Python stack trace

7.8.1 Catching and communicating errors

7.8.2 Why structured responses matter

The section explains how consistent, structured tool responses help a model recognize outcomes, communicate with users, and choose a next step.

Key terms: structured responses, success, message, error codes

7.8.3 Handling empty results vs. errors

The section distinguishes an unsuccessful search from a failed tool call and explains how the model should respond to each.

Key terms: empty results, error, success: True, success: False

7.8.4 Timeout and rate-limiting

This section explains how MCP tools can remain useful when external APIs are slow or fail by using timeouts, retries, and clear error responses.

Key terms: timeouts, retry logic, exponential backoff, transient network error, error path, raw exceptions, structured response, MCP tools

7.9 Beyond tools: Production agent harnesses and OpenClaw

The section introduces the agent harness as the component that makes MCP tools useful to an agent.

Key terms: MCP tools, agent harness

7.9.1 Why harnesses matter

This section explains how an agent harness makes an LLM operational by managing tools and state while keeping code execution isolated.

Key terms: harness, session and state management, memory mechanisms, tool system, output channels, control plane, compute plane, sandbox, checkpoint, MCP tools

7.9.2 Designing agent-legible environments

The section explains how to make an agent’s working environment legible so it can find instructions, use information, respond to failures, and work reliably.

Key terms: agent legibility, environment, AGENTS.md, docs/, structured skills files, MCP tool descriptions, repository, system of record, versioned artifacts, structured JSON

7.9.3 The security gap

This section explains why production agents need security boundaries around their tools and execution environments, not just well-designed tools.

Key terms: harness/sandbox separation, prompt-injection, data-exfiltration, MCP tools, attack surface, input validation, structured error handling, harnesses, sandboxes, state management

7.10 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 6: Creating effective AI agents Chapter 8: Multi-agent systems →

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.