Build an LLM agent, equipped with MCP, from scratch.
Project description
LLM Agents From Scratch
The companion library for Build a Multi-Agent System — With MCP and A2A (Manning). Learn how LLM agents work by building one yourself, from first principles, step by step.
Available now through Manning's Early Access Program (MEAP) — buy today and get each chapter as it's completed. Buy the Book →
About
Multi-agent systems and the LLM agents that power them are among the most discussed topics in AI today. There are already many capable frameworks out there — the goal of this book isn't to replace them, but to help you deeply understand how they work by having you build one yourself, from scratch.
All the code lives in the book's own hand-rolled agent framework, primarily designed for educational purposes rather than production deployment. It will give you the foundation to work more confidently with any other LLM agent framework of your choosing, or even to build your own specialised solutions.
From the Book
Each chapter builds on the last, progressively deepening your understanding from core concepts to full multi-agent systems.
Part 1 — Build Your First LLM Agent
| Ch | Title | Notebook |
|---|---|---|
| 1 | What Are LLM Agents and Multi-Agent Systems? | — |
| 2 | Working with Tools | Ch 2 |
| 3 | Working with LLMs | Ch 3 |
| 4 | The LLM Agent Class | Ch 4 |
Part 2 — Enhance Your LLM Agent
| Ch | Title | Notebook |
|---|---|---|
| 5 | MCP Tools | Ch 5 |
| 6 | Skills | — |
| 7 | Memory | — |
| 8 | Human in the Loop | — |
Part 3 — Building Multi-Agent Systems
| Ch | Title | Notebook |
|---|---|---|
| 9 | Multi-Agent Systems with Agent2Agent | — |
Capstone Projects
Capstones are larger, end-to-end projects that pull together what you have built in the book and apply it to something closer to a real-world system.
| Capstone | Description | Notebook |
|---|---|---|
| Monte Carlo Estimation of Pi | Orchestrate parallel tool calls to estimate π using the Monte Carlo method. | Open |
| Deep Research Agent | Coming soon. | — |
| OpenClaw Personal Assistant | Coming soon. | — |
Getting Started
Prerequisites
Installation
Clone the repository:
# SSH
git clone git@github.com:nerdai/llm-agents-from-scratch.git
# HTTPS
git clone https://github.com/nerdai/llm-agents-from-scratch.git
cd llm-agents-from-scratch
Install dependencies:
uv sync --all-extras --dev
Quick Start
from llm_agents_from_scratch.llms import OllamaLLM
from llm_agents_from_scratch.agent import LLMAgentBuilder
from llm_agents_from_scratch.tools import SimpleFunctionTool
def add(a: int, b: int) -> int:
return a + b
llm = OllamaLLM(model="llama3.2")
tool = SimpleFunctionTool(fn=add)
agent = (
LLMAgentBuilder()
.with_llm(llm)
.with_tools([tool])
.build()
)
result = await agent.run("What is 3 + 5?")
print(result)
Development
# Run all tests
make test
# Lint and format
make lint
make format
# Coverage report
make coverage-report
See CLAUDE.md for full development guidance.
Contributing
Bug reports, feature requests, and community project submissions are welcome. See CONTRIBUTING.md for details.
- Found a bug? Open an issue
- Built something cool? Share it on GitHub Discussions
License
Apache 2.0 — see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_agents_from_scratch-0.0.15.tar.gz.
File metadata
- Download URL: llm_agents_from_scratch-0.0.15.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cda53e354300205d700c5c38012c7fb3bf008a9ccd2213f1c860f9b475bca4f
|
|
| MD5 |
e3a7c0bb9af3ed69656a122bf35a138d
|
|
| BLAKE2b-256 |
6c2731a6ca8d4e3f26908e8dae3a2cea95427d70863037ef5624e3e56e24ca4d
|
File details
Details for the file llm_agents_from_scratch-0.0.15-py3-none-any.whl.
File metadata
- Download URL: llm_agents_from_scratch-0.0.15-py3-none-any.whl
- Upload date:
- Size: 54.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62d2900a17e6d7fdd6f6de77654bff320ca73ad7994f8f7dd5abcea509c3de1f
|
|
| MD5 |
9540e25dbdfb2281797293af39c84246
|
|
| BLAKE2b-256 |
4a127c6415d3fb289fa411e75ebcd671f969cba2366fbb38e0b1ed1ba85acdae
|