Agentic AI (Part II) -- Tools and function calling
Overview
Using Tools
Reference:
OpenAI tool guide
Lil’Log LLM Powered Autonomous Agents
马克的技术工作坊
Use tools like remote MCP servers or web search to extend the model’s capabilities.
Model Context Protocol (MCP)
Model Context Protocol regulates how an agent access external tools/resources/data to enhance LLM capability. It’s very important to understand that it doesn’t specify how an agent interacts with the model itself though it is named by “Model”.
Key Components
| Component | What It Is |
|---|---|
| MCP host | It is the application you directly interact with and the overall container for the session. It provides the runtime environment but does not handle the MCP protocol itself. |
| MCP client | It is the protocol communication component embedded inside VS Code. Cline is responsible for establishing connections to various MCP Servers, sending requests, and receiving results. It gives VS Code (the Host) the ability to “speak” the MCP language with external tools. |
| MCP server | These are independent lightweight programs that provide specific functionalities, such as a filesystem server or a database server. Cline, acting as the Client, connects to and invokes these servers. |
</br>
Function calling
Hand-on Experience
This subsection shows how to frame an agent that’s able to call local functions within Python3 from scratch.
The following structure includes only the key components.
deepseek_agent/ # Project root
├── venv/ # Virtual environment (IGNORE, don't commit)
├── src/
│ ├── __init__.py
│ ├── agent.py # Main agent class
│ ├── tools.py # All tool definitions in one file
│ └── config.py # Configuration loading
├── tests/
│ ├── test_agent.py # Agent tests
│ └── test_tools.py # Tool tests
├── scripts/
│ └── run.py # CLI entry point
├── requirements.txt # Dependencies
├── .env # API keys (IGNORE, don't commit)
└── README.md # Project documentation
src and Key Components
The src folder, usually made as a Python Package, covers all the core functional source code.
| File | What It Does |
|---|---|
src/agent.py | Orchestrates the conversation loop, calls LLM API, executes tools |
src/tools.py | Defines available functions and their JSON schemas for the model |
src/config.py | Loads API key from .env and other settings |
Enjoy Reading This Article?
Here are some more articles you might like to read next: