liveBook · Manning

Chapter 4: Tools in AI agents

What you will learn in chapter 4 of Context Engineering

Introduces tools as a way for AI agents to act on external systems and explains how tool use dynamically changes the context window.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces tools as a way for AI agents to act on external systems and explains how tool use dynamically changes the context window.

Key terms: tools, AI agents, external world, context window, tool definitions, tool call, execution output

4.1 Tools

This section explains how tools let agents act beyond the model, feed observations back into context, and introduce risks that require controls.

Key terms: tools, agent loop, agent harness, observations, context injectors, tool definitions, tool calls, tool outputs, context window, function calling

4.2 Function calling

This section explains how an agent harness turns a model’s structured tool request into external execution and a grounded response, and what that exchange costs in context.

Key terms: function calling, external capabilities, probabilistic reasoning, deterministic execution, agent harness, tool definitions, structured tool call, typed arguments, message history, grounded response

4.2.1 Tool definitions as contracts

This section explains how a structured tool definition acts as a contract that lets an agent choose a tool, supply valid inputs, and interpret its results or errors.

Key terms: tool definition, operational contract, unique name, activation description, parameter schema, output schema, actionable error contract, structured error responses

4.2.2 Strengths, limits, and failure modes

This section explains where function calling works well, why schemas do not prevent tool-use mistakes, and what safeguards the execution harness needs.

Key terms: function calling, schema-driven, tool definitions, tool hallucination, schema, malformed calls, harness, validation, authorization, execution path

4.2.3 Built-in functions in AI agents

This section explains how built-in agent functions help acquire, update, preserve, and manage context without developer-defined tools.

Key terms: built-in functions, information retrieval and browsing, code execution and terminal access, sandboxed environments, file and workspace operations, persistent, inspectable context objects, memory read and write operations, interaction control and clarification, control primitives

4.3 Command-line interface

This section explains how a CLI gives an AI agent broad tool access through a shell, with guarded command execution and output fed back into the model’s context.

Key terms: CLI, schema-driven function calling, shell, command line, sandbox, command policy, human approval, harness, standard output, error messages

4.3.1 Strengths and failure modes

This section explains why a shell simplifies agent tooling, what risks shell access creates, and which runtime controls can reduce them.

Key terms: CLI tool architecture, composition, shell, wrappers and schemas, --help, security surface, destructive operations, privilege escalation, secret exposure, data exfiltration

4.3.2 CLI tools in agent skills

Explains when agent skills are useful for guiding an agent’s use of command-line tools and what those skills record.

Key terms: command-line tools, agent skills, permitted commands, confirmation

4.4 Agent protocols

This section maps the communication boundaries in agentic systems to five protocols and identifies MCP as the chapter’s focus.

Key terms: A2A, AG-UI, LSP, ACP, model context protocol, MCP, standardized context interface

4.5 Model context protocol

Introduces MCP as a standard for connecting agents to external capabilities and explains its role as a context federation layer.

Key terms: MCP, open protocol, model-facing mechanism for tool use, context federation layer, independent servers, agent harness, operational context

4.5.1 MCP architecture

Explains MCP’s host-client-server architecture, how clients communicate with servers, and how discovered capabilities become available to an agent.

Key terms: MCP host, MCP client, MCP server, one-to-one session, transport layer, JSON-RPC, STDIO, Streamable HTTP, discovery, single catalog

4.5.2 MCP servers

This section explains the three capabilities MCP servers expose—tools, resources, and prompts—and how each shapes an agent’s actions or context.

Key terms: tools, name, description, parameters, output schema, fully qualified names, namespacing, routing signals, resources, resource type

4.5.3 MCP server ecosystem

This section explains how MCP server registries help people discover servers and how enterprises can limit which servers agents may use.

Key terms: MCP Registry, private registries, approved catalogs, server metadata

4.5.4 MCP in production environments

This section explains why MCP’s runtime flexibility needs controls for security, context use, permissions, and reliability in production.

Key terms: server discoverability, dynamic capability injection, allowlist, approved baseline, context window pressure, tool definitions, JSON schemas, private registry, tool shadowing, scope control

4.6 Hands-on

Introduces hands-on exercises on tools and agent skills and suggests four elements to watch for in each example.

4.6.1 Function calling with an OpenAI model

Shows a basic OpenAI function-calling loop and explains how a tool result changes the context used for the final answer.

Key terms: function calling, tool definition, execution loop, weather value, working context, final response

4.6.2 CLI with an agent skill

Shows how an agent skill gives a CLI-capable agent a reusable, reviewed workflow while leaving safety enforcement to the harness.

Key terms: skill, CLI-capable agent, reusable procedural context, workspace-analyzer skill, SKILL.md, sandboxed working directory, harness, approval step

4.6.3 Using an existing MCP server

The section shows how to connect Goose Desktop to an existing Filesystem MCP server, use its file capabilities, and limit the security risks of the shared folder.

Key terms: Goose Desktop, Filesystem MCP Server, extensions, STDIO, MCP client, capabilities, observations, model context, untrusted input, sandboxed folder

4.6.4 Implementing a custom MCP server

Shows how a minimal MCP server exposes browser tools to an agent, how to run and inspect it, and why its interface and security boundaries matter.

Key terms: MCP server, context gateway, MCP SDK, tool schemas, Selenium, transport layer, get_browser_text, navigate_url, untrusted input, allowlist

4.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 3: External knowledge and retrieval Chapter 5: Memory and state in agentic 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.