liveBook · Manning

Chapter 5: MCP Tools

What you will learn in chapter 5 of Build a Multi-Agent System (from Scratch)

This introduction situates MCP as a standard for connecting agents to external systems and enabling access to third-party tools.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction situates MCP as a standard for connecting agents to external systems and enabling access to third-party tools.

Key terms: Model Context Protocol, MCP, external systems, third-party tools

5.1 Introducing MCP

This section previews the foundational MCP concepts needed to integrate MCP into the framework.

5.1.1 The MCP ecosystem

Introduces MCP tool suppliers and consumers and distinguishes tools from the other MCP primitives.

Key terms: MCP ecosystem, tool suppliers, tool consumers, MCP tools, MCP primitives, tools, resources, prompts

5.1.2 The tool-calling process for an MCP tool

This section explains how MCP adapts the familiar tool-calling process by executing tool logic in an external system.

Key terms: tool-calling process, tool-call request, MCP tool, MCP tools

5.1.3 The MCP architecture

This section explains MCP’s host-client-server architecture, connection representation, and local and remote transports for tool calls.

Key terms: MCP host, MCP client, MCP server, session, server-side definition, MCP 2.0, client sessions, mcp Python library, standard IO, stdio

5.2 Integrating MCP into our framework

This section outlines how asynchronous MCP tools and a connection-managing provider integrate MCP servers into the framework.

Key terms: MCPTool, AsyncBaseTool, MCPToolProvider, provider, tool-discovery phase, provider reference, stdio_params, streamable_http_url, streamable_http_headers

5.2.1 Implementing MCPToolProvider

This section implements MCPToolProvider to manage MCP server sessions and discover server-side tools as MCPTool objects.

Key terms: stdio_params, streamable_http_url, mcp.StdioServerParameters, session(), _create_session(), close(), mcp.ClientSession, asyncio.create_task(), asyncio.wait(), _session_ready

5.2.2 Implementing MCPTool

This section implements MCPTool as an asynchronous framework tool that is discovered through a provider and forwards calls to an MCP server.

Key terms: MCPTool, AsyncBaseTool, MCPToolProvider.get_tools(), mcp.Tool, parameters_json_schema, __call__(), call_tool(), MCP server, ToolCallResult

5.3 LLMAgentBuilder: a dynamic builder of LLMAgent

This section contrasts manual MCP tool setup with using LLMAgentBuilder to discover tools and construct an agent.

Key terms: MCP tools, LLMAgent constructor, tool discovery, LLMAgentBuilder, llm, tools, templates, mcp_providers, MCPToolProvider

5.3.1 Implementing LLMAgentBuilder

This section implements and demonstrates an LLMAgentBuilder that configures an agent and discovers MCP tools during construction.

Key terms: LLMAgentBuilder, LLMAgent, mcp_providers, MCPToolProvider, build(), with_, fluent methods, with_tools(), with_mcp_providers(), Self

5.4 Extending to MAS: MCP Tools

This section explains selective MCP tool assignment in multi-agent systems and why a shared provider guards concurrent session creation.

Key terms: MCP tool, MAS, MCPToolProvider, session(), _session_task, session-creation task

5.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 4: The LLMAgent Class Chapter 6: Skills →

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.