liveBook · Manning

LLMAgentBuilder

As explained in Build a Multi-Agent System (from Scratch)

LLMAgentBuilder is a book-specific framework class that discovers tools from selected MCP servers and constructs an LLMAgent with them.

LLMAgentBuilder constructs an LLMAgent from configured model, tools, templates, and MCP providers. Its main convenience is discovering MCP tools during construction, avoiding manual discovery for each server. section 5.3

Configure and build an agent in three stages:

  • Set or add inputs with the constructor or chainable with_* methods; with_tools() and with_mcp_providers() extend their lists. section 5.3.1
  • Call the asynchronous build() method. It validates that an LLM is set, discovers tools from each MCPToolProvider, and constructs the LLMAgent. section 5.3.1

Build an agent with a Hailstone tool

Configure an MCPToolProvider for the Hailstone server, add it and an LLM to the builder, then await build(). The resulting agent can call the discovered hailstone_step_fn tool to evaluate hailstone_step_fn(5), which returns 16. section 5.3.1 section 5.3

# Included in examples/ch05.ipynb #A
from llm_agents_from_scratch.notebook_utils import make_llm
from llm_agents_from_scratch.agent.builder import LLMAgentBuilder
 
provider = MCPToolProvider(
    name="hailstone",
    stdio_params=server_params,
)
llm = make_llm()
 
llm_agent = await LLMAgentBuilder()\
    .with_llm(llm)\
    .with_mcp_provider(provider)\
    .build() #B

Shows fluent configuration of an MCP provider and LLM followed by asynchronous construction. section 5.3.1

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Implements constructor, chainable with_* methods, lightweight validation, and asynchronous discovery across providers.
Examples
Builds an agent with a Hailstone MCP provider and calls hailstone_step_fn(5) to obtain 16.
What you can do after
Build an LLMAgent by configuring the builder, discovering MCP tools, and awaiting build().
How it connects
Connects LLMAgent construction with MCPToolProvider, MCPTool, and MCP tool discovery.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.