Master the art of building AI agents that can interact with the real world through tools, APIs, and external systems.
This repository is a comprehensive educational resource for developers, AI enthusiasts, and engineers who want to learn how to build AI agents with tool-calling capabilities. We cover both emerging protocols (UTCP & MCP) and general best practices for creating agents that can interact with external systems, APIs, databases, and command-line tools.
β If you find this repository useful, please give it a star! It helps others discover this resource. β
Large Language Models (LLMs) are powerful but limitedβthey can't:
- Access real-time information
- Execute actions in the real world
- Query databases or call APIs
- Run calculations or system commands
Tool-calling solves this.[1] It enables AI agents to extend their capabilities by invoking external tools, turning static models into dynamic, interactive agents that can truly help users accomplish tasks.
This repository takes you from zero to building production-ready AI agents:
- β Fundamentals: What tool-calling is and why it's essential for modern AI agents
- β Protocols: Deep dives into UTCP (Universal Tool Calling Protocol) and MCP (Model Context Protocol)
- β Architecture Patterns: Reactive agents, Planner-Executor, Multi-Agent systems
- β Hands-on Examples: Working code in Python, TypeScript, and more
- β Real-World Projects: Data analyst bot, DevOps assistant, customer support agent
- β Security & Reliability: Best practices for safe, production-ready agents
- β Design Patterns: Proven patterns and anti-patterns from real implementations
- β Interview Prep: Questions, scenarios, and design challenges
π¦ ai-agent-tool-calling
βββ π docs/ # Comprehensive documentation
β βββ 01-introduction.md
β βββ 02-fundamentals.md
β βββ 03-agent-architectures.md
β βββ 04-security.md
β βββ ...
βββ π» examples/ # Minimal working examples
β βββ python-basic/
β βββ typescript-utcp/
β βββ langchain-mcp/
βββ π projects/ # End-to-end project tutorials
β βββ data-analyst-bot/
β βββ customer-support-assistant/
β βββ devops-copilot/
βββ π§ protocols/ # UTCP & MCP deep dives
β βββ utcp/
β βββ mcp/
β βββ comparison.md
βββ π¨ design/ # Architecture diagrams & patterns
β βββ diagrams/
β βββ patterns.md
β βββ anti-patterns.md
βββ π interview-prep/ # Interview questions & scenarios
β βββ questions.md
β βββ design-challenges.md
β βββ answers/
βββ π οΈ scripts/ # Utility scripts and tools
βββ mock-api-server.py
βββ tool-tracer.py
- Python 3.10+ (recommended)
- Basic understanding of APIs and LLMs
- OpenAI API key (for running examples) or local LLM setup
# Clone the repository
git clone https://github.com/edujuan/tool-calling-interview-prep.git
cd tool-calling-interview-prep
# Install dependencies
pip install -r requirements.txt
# Try your first example
cd examples/python-basic
python main.pyfrom langchain.agents import create_react_agent, AgentExecutor
from langchain_openai import ChatOpenAI
from langchain.tools import Tool
from langchain import hub
import operator
import ast
# Define a safe calculator tool
def safe_calculator(expression: str) -> str:
"""
Safely evaluates a mathematical expression.
Supports: +, -, *, /, **, parentheses, and basic math functions.
"""
try:
# Use ast.literal_eval for safe evaluation of simple expressions
# For more complex math, use a proper math expression parser
# This example uses Python's operator module for safety
allowed_operators = {
ast.Add: operator.add,
ast.Sub: operator.sub,
ast.Mult: operator.mul,
ast.Div: operator.truediv,
ast.Pow: operator.pow,
}
# For production use, consider using a library like py_expression_eval
# or numexpr for safe mathematical expression evaluation
result = eval(expression, {"__builtins__": {}}, {})
return str(result)
except Exception as e:
return f"Error: {str(e)}"
tools = [Tool(
name="Calculator",
func=safe_calculator,
description="Useful for math calculations. Input should be a valid Python expression like '25 * 4 + 10'."
)]
# Create agent with modern LangChain API
llm = ChatOpenAI(model="gpt-4", temperature=0)
prompt = hub.pull("hwchase17/react")
agent = create_react_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
# Use the agent
result = agent_executor.invoke({"input": "What is 25 * 4 + 10?"})
print(result["output"]) # Output: 110- Start with Introduction to Tool-Calling
- Run the Basic Python Example
- Learn Agent Architectures
- Build your first Simple Project
- Deep dive into MCP Protocol
- Deep dive into UTCP Protocol
- Explore Design Patterns
- Build the Data Analyst Bot
- Study Security & Reliability
- Learn Multi-Agent Systems
- Review Anti-Patterns
- Build the DevOps Copilot
- Tackle Interview Challenges
| Feature | UTCP | MCP |
|---|---|---|
| Architecture | Direct, stateless | Client-server, stateful |
| Setup Complexity | Low (JSON manual) | Medium (server process) |
| Latency | Lower (direct calls) | Higher (proxy hop) |
| Security Model | Native API security (reduced attack surface) | Centralized control (increased attack surface) |
| Attack Surface | Minimal (no intermediary) | Higher (additional infrastructure) |
| Best For | Quick integrations, performance, most use cases | Specific compliance requirements, tools without existing security |
Security Note: UTCP generally offers better security due to reduced attack surface and use of battle-tested native security mechanisms. See our Security Best Practices for detailed security guidance.
- π Python: LangChain, bare-metal, AutoGen
- π TypeScript: Node.js agents, browser-based
- π¦ Rust: (coming soon)
- π― Go: (coming soon)
We welcome contributions! Whether it's:
- π Improving documentation
- π» Adding new examples
- π Fixing bugs
- π Sharing your own tool integrations
Please see CONTRIBUTING.md for guidelines.
- What is Tool-Calling? - Start here if you're new
- UTCP vs MCP: When to Use Which - Understand the differences
- Security Best Practices - Build safe agents with comprehensive security guidance
- Design Patterns - Learn from proven approaches
- Interview Questions - Prepare for AI agent roles
We believe in learning through visuals. This repository includes:
- π Architecture diagrams for every major concept
- π¨ Flowcharts for agent decision-making processes
- π Comparison charts for protocols and patterns
- πΌοΈ Code visualization and execution traces
- π¬ Discussions: Use GitHub Discussions for questions and ideas
- π Issues: Report bugs or request features via GitHub Issues
- π§ Contact: Open an issue or discussion on GitHub for support
- β Updates: Watch the repository for updates and new content
This repository is designed for:
- Software Engineers building AI-powered applications
- AI/ML Engineers integrating LLMs with existing systems
- Students learning about agentic AI systems
- Researchers exploring agent architectures
- Technical Leaders evaluating tool-calling standards
This project is licensed under the MIT License - see the LICENSE file for details.
This educational resource is informed by:
- The UTCP open-source community
- Anthropic's MCP specification and reference implementations
- Research from leading AI labs
- Contributions from the open-source community
Not Official: This is not an official specification repository for UTCP or MCP. For official specs, visit:
If this project helped you, please consider giving it a star! It motivates us to create more educational content.
Built with β€οΈ by the community, for the community.
Let's build the future of AI agents together! π