Overview
Tools extend agent capabilities beyond text processing, enabling interaction with external systems and data sources. They act as specialized modules that extend the agent’s abilities, allowing it to interact with external systems, access information, and execute actions in response to user queries.Supported in Python and TypeScript.
| Tool | Description |
|---|---|
| MCP | Discover and use tools exposed by arbitrary MCP Server |
| Think | Gives an agent a place to think |
| Handoff | Delegates a task to an expert agent |
| OpenAPI | Consume external APIs with an ease |
| OpenMeteo | Retrieve weather information for specific locations and dates |
| DuckDuckGo | Search for data on DuckDuckGo |
| Wikipedia | Search for data on Wikipedia |
| VectorStoreSearch | Search for documents in a vector database |
| Python | Let agent run an arbitrary Python code in a sandboxed environment |
| Sandbox | Run custom Python functions in a sandboxed environment |
| Shell | Run a command and capture its output (with pluggable backend) |
| FileRead | Read a text file via a pluggable file backend |
| FileEdit | Overwrite or search-and-replace a text file with a unified diff |
| Glob | List files matching a glob pattern |
| Grep | Recursively search files for a regex (uses ripgrep when available) |
Usage
Basic usage
The simplest way to use a tool is to instantiate it directly and call itsrun() method with appropriate input:
Advanced usage
Tools often support additional configuration options to customize their behavior:Using tools with agents
The true power of tools emerges when integrating them with agents. Tools extend the agent’s capabilities, allowing it to perform actions beyond text generation:Creating a tool
For simpler tools, you can use thetool decorator to quickly create a tool from a function:
Python
Built-in Tools
DuckDuckGo search tool
Use the DuckDuckGo search tool to retrieve real-time search results from across the internet, including news, current events, or content from specific websites or domains.OpenMeteo weather tool
Use the OpenMeteo tool to retrieve real-time weather forecasts including detailed information on temperature, wind speed, and precipitation. Access forecasts predicting weather up to 16 days in the future and archived forecasts for weather up to 30 days in the past. Ideal for obtaining up-to-date weather predictions and recent historical weather trends.Wikipedia tool
Use the Wikipedia tool to retrieve detailed information from Wikipedia.org on a wide range of topics, including famous individuals, locations, organizations, and historical events. Ideal for obtaining comprehensive overviews or specific details on well-documented subjects. May not be suitable for lesser-known or more recent topics. The information is subject to community edits which can be inaccurate.Vector Store Search Tool
Use the VectorStoreSearchTool to perform semantic search against pre-populated vector stores. This tool enables agents to retrieve relevant documents from knowledge bases using semantic similarity, making it ideal for RAG (Retrieval-Augmented Generation) applications and knowledge-based question answering.This tool requires a pre-populated vector store. Vector store population (loading and chunking documents) is typically handled offline in production applications.
Python
MCP Tool
Leverage the Model Context Protocol (MCP) to define, initialize, and utilize tools on compatible MCP servers. These servers expose executable functionalities, enabling AI models to perform tasks such as computations, API calls, or system operations.Using stdio transport
Using stdio transport
Using streamable-http transport
Using streamable-http transport
Python
Using sse transport
Using sse transport
Python
Currently, the client does not support Roots, Sampling, or Elicitation. Feel free to open a GitHub issue if needed.
OpenAPI Tool
Many APIs are described using the OpenAPI Specification, and a framework can read this specification to generate a set of tools that allow an agent to communicate with the API.Python Tool
The Python tool allows AI agents to execute Python code within a secure, sandboxed environment. This tool enables access to files that are either provided by the user or created during execution. This enables agents to:- Perform calculations and data analysis
- Create and modify files
- Process and transform user data
- Generate visualizations and reports
- And more
This tool requires beeai-code-interpreter to use.
Get started quickly with the BeeAI Framework starter template for Python
or TypeScript.
LocalPythonStorage– Handles where Python code is stored and run.local_working_dir– A temporary folder where the code is saved before running.interpreter_working_dir– The folder where the code actually runs, set by theCODE_INTERPRETER_TMPDIRsetting.
PythonTool– Connects to an external Python interpreter to run code.code_interpreter_url– The web address where the code gets executed (default:http://127.0.0.1:50081).storage— Controls where the code is stored. By default, it saves files locally usingLocalPythonStorage. You can set up a different storage option, like cloud storage, if needed.
Sandbox tool
The Sandbox tool provides a way to define and run custom Python functions in a secure, sandboxed environment. It’s ideal when you need to encapsulate specific functionality that can be called by the agent.This tool requires beeai-code-interpreter to use.
Get started quickly with beeai-framework-py-starter.
Only
PythonTool can access files.Coding-agent tool primitives
The framework ships a set of protocol-agnostic primitives for building coding agents. These tools work without any extra setup against the local filesystem and a local subprocess — but their I/O is dispatched throughContextVar-backed backends, which means a serve adapter (like the Zed ACP adapter) can transparently route them through an editor’s filesystem and terminal capabilities for the duration of a turn.
| Primitive | Default backend | Pluggable via |
|---|---|---|
ShellTool | LocalShellBackend (asyncio.subprocess) | setup_shell_backend(...) |
FileReadTool | LocalFileBackend (pathlib) | setup_file_backend(...) |
FileEditTool | LocalFileBackend (pathlib) | setup_file_backend(...) |
GlobTool | local — pathlib.Path.glob | not pluggable |
GrepTool | local — ripgrep if on $PATH, else stdlib | not pluggable |
Shell tool
Run a command (as a list of arguments — not through a shell) and return its exit code, stdout, stderr, and timeout/truncation flags.Python
command(list[str], required) — argv list. Useshlex.splitif you only have a string.cwd,env— working directory and extra env vars merged overos.environ.timeout_seconds(default60) — kills the process if it runs longer; set toNoneto disable.input_text— piped to stdin. Some backends (e.g. ACP terminals) don’t support stdin and will raise.
FileRead tool
Read a text file via the activeFileBackend. Path must be absolute. Optional line (1-based) and limit slice the file without loading the whole thing.
Python
FileEdit tool
Edit a file in one of two modes, returning a unified diff in the output:mode="overwrite"— writecontentverbatim. Creates the file if missing.mode="replace"— exact-text search-and-replace. Fails (without writing) if the number of occurrences ofolddoesn’t matchexpected_occurrences(default1), preventing the most common agent edit footgun: silent over-matching.
Python
Glob tool
List paths matching a glob pattern under a root directory. Hidden files (.foo) are excluded by default.
Python
Grep tool
Recursively search files for a regex. Usesripgrep (rg) when it’s on $PATH for speed and .gitignore honoring; falls back to a pure-Python walk that skips common ignored directories (.git, node_modules, .venv, …) when it isn’t.
Python
used_ripgrep flag tells you which one did.
Creating custom tools
Custom tools allow you to build your own specialized tools to extend agent capabilities. To create a new tool, implement the baseTool class. The framework provides flexible options for tool creation, from simple to complex implementations.
Initiate the
Tool by passing your own handler (function) with the name, description and input schema.Basic custom tool
Here’s an example of a simple custom tool that provides riddles:Advanced custom tool
For more complex scenarios, you can implement tools with robust input validation, error handling, and structured outputs:Implementation guidelines
When creating custom tools, follow these key requirements: 1. Implement theTool class
To create a custom tool, you need to extend the base Tool class and implement several required components. The output must be an implementation of the ToolOutput interface, such as StringToolOutput for text responses or JSONToolOutput for structured data.
2. Create a descriptive name
Your tool needs a clear, descriptive name that follows naming conventions:
Python
Python
Python
MyNewToolInput class. Keep your tool input schema simple and provide schema descriptions to help the agent to interpret fields.
5. Implement the _run() method
This method contains the core functionality of your tool, processing the input and returning the appropriate output.
Python
Best practices
1. Data minimization
If your tool is providing data to the agent, try to ensure that the data is relevant and free of extraneous metatdata. Preprocessing data to improve relevance and minimize unnecessary data conserves agent memory, improving overall performance.2. Provide hints
If your tool encounters an error that is fixable, you can return a hint to the agent; the agent will try to reuse the tool in the context of the hint. This can improve the agent’s ability to recover from errors.3. Security and stability
When building tools, consider that the tool is being invoked by a somewhat unpredictable third party (the agent). You should ensure that sufficient guardrails are in place to prevent adverse outcomes.Examples
Python
Explore reference tool implementations in Python
TypeScript
Explore reference tool implementations in TypeScript