Skip to content

edujuan/tool-calling-interview-prep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI Agent Tool-Calling: The Complete Guide

Master the art of building AI agents that can interact with the real world through tools, APIs, and external systems.

License: MIT PRs Welcome


🌟 What is This Repository?

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. ⭐

Why Tool-Calling Matters

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.


πŸ“š What You'll Learn

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

πŸ—‚οΈ Repository Structure

πŸ“¦ 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

πŸš€ Quick Start

Prerequisites

  • Python 3.10+ (recommended)
  • Basic understanding of APIs and LLMs
  • OpenAI API key (for running examples) or local LLM setup

Installation

# 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.py

Your First Tool-Calling Agent (3 minutes)

from 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

🎯 Learning Pathways

🌱 Beginner Path

  1. Start with Introduction to Tool-Calling
  2. Run the Basic Python Example
  3. Learn Agent Architectures
  4. Build your first Simple Project

🌿 Intermediate Path

  1. Deep dive into MCP Protocol
  2. Deep dive into UTCP Protocol
  3. Explore Design Patterns
  4. Build the Data Analyst Bot

🌳 Advanced Path

  1. Study Security & Reliability
  2. Learn Multi-Agent Systems
  3. Review Anti-Patterns
  4. Build the DevOps Copilot
  5. Tackle Interview Challenges

πŸ”₯ Key Features

Protocol Coverage

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.

Comprehensive Examples

  • 🐍 Python: LangChain, bare-metal, AutoGen
  • πŸ“˜ TypeScript: Node.js agents, browser-based
  • πŸ¦€ Rust: (coming soon)
  • 🎯 Go: (coming soon)

🀝 Contributing

We welcome contributions! Whether it's:

  • πŸ“ Improving documentation
  • πŸ’» Adding new examples
  • πŸ› Fixing bugs
  • 🌟 Sharing your own tool integrations

Please see CONTRIBUTING.md for guidelines.


πŸ“– Documentation Highlights

Popular Topics

Visual Learning

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

🌐 Community & Support

  • πŸ’¬ 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

πŸŽ“ Who Is This For?

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

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

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:


⭐ Star History

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! πŸš€

About

Comprehensive interview prep guide to learn about Agents, AI and tool-calling

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages