chapter three

3 Enabling actions: Tool use

 

This chapter covers

  • Understanding the limitations of LLMs and why they need tools
  • Calling and executing tools
  • Building and integrating custom tools
  • Using MCP for tool standardization

On their own, large language models (LLMs) can’t access external data or interact with external systems. They need tools and the ability to select and use those tools, which is central to implementing agents. A basic agent performs tasks step by step by repeatedly selecting the next action to take, and tools make this possible.

First, we’ll explore how to build tools and inform the LLM how to use them. We’ll also learn how the LLM chooses the appropriate tool for a given task and relays tool executions back to the LLM. Then we’ll examine the Model Context Protocol (MCP) by Anthropic, an initiative that standardizes the development and use of tools, as shown in figure 3.1.

Figure 3.1 Book structure overview: chapter 3

3.1 LLM tools

3.1.1 Why do we need LLM tools?

3.1.2 Types of LLM tools

3.2 How LLMs use tools

3.2.1 How tool calling works

3.2.2 How an LLM chooses tools

3.2.3 Guidelines for effective tool calling

3.3 Building tools and tool definitions for LLMs

3.3.1 Implementing a web search tool

3.3.2 Converting to tool definitions

3.3.3 End-to-end tool execution

3.3.4 The challenges of custom tools

3.4 MCP: Standardizing tools

3.4.1 The core of MCP: Server–client architecture

3.4.2 Hands-on: Running an MCP server

3.4.3 Understanding the MCP client

3.4.4 Hands-on: Implementing an MCP server

Summary