HomeBuild toolsCreate a toolkit

Creating a Toolkit

In this guide, we’ll walk through the process of creating a custom toolkit for Arcade.

You’ll create a simple arithmetic toolkit with operations like addition, subtraction, multiplication, and more.

Prerequisites

This guide requires a self-hosted installation of the Arcade Engine. It will not work with the Cloud version of Arcade. Ensure you complete the steps below before continuing.

Create a new toolkit

Run the following command to start creating your toolkit:

arcade new

Arcade will prompt you to enter a name and other details for your toolkit. After you provide the information, a skeleton toolkit will be generated for you in a directory named with the toolkit name that you entered.

cd <toolkit_name>

Define your tools

Create a Python file for your tools, e.g., arithmetic.py, in the arcade_<toolkit_name>/tools directory of your new toolkit and import the necessary modules:

from typing import Annotated
from arcade.sdk import tool

Now, define your tools using the @tool decorator:

@tool
def add(
    a: Annotated[int, "The first number"],
    b: Annotated[int, "The second number"]
) -> Annotated[int, "The sum of the two numbers"]:
    """
    Add two numbers together
    """
    return a + b
 
@tool
def subtract(
    a: Annotated[int, "The first number"],
    b: Annotated[int, "The second number"]
) -> Annotated[int, "The difference of the two numbers"]:
    """
    Subtract two numbers
    """
    return a - b
 
@tool
def multiply(
    a: Annotated[int, "The first number"],
    b: Annotated[int, "The second number"]
) -> Annotated[int, "The product of the two numbers"]:
    """
    Multiply two numbers together
    """
    return a * b
 
@tool
def divide(
    a: Annotated[int, "The numerator"],
    b: Annotated[int, "The denominator"]
) -> Annotated[float, "The quotient of the two numbers"]:
    """
    Divide two numbers
    """
    return a / b

Register your tools

To register your tools locally, use the make install command provided in the Makefile created by arcade new. This will install the toolkit locally.

Navigate to the directory created by arcade new (with the pyproject.toml file) and run:

make install

This will load the tool into the local worker environment.

You can run the Engine and Worker to test your new tool with:

arcade dev

Additionally, the Makefile includes other helpful commands such as:

  • make check: Runs all pre-commit checks that must pass.
  • make test: Runs all unit tests in the toolkit’s test directory.

See the Local Installation Guide for setting up arcade dev if you have not done so already.

Use your tools with Arcade

Now that your local Engine and worker are running via the arcade dev command, you can use your custom tools with Arcade in your application.

Here’s an example of how to use your tools:

from arcadepy import Arcade
 
client = Arcade(base_url="http://localhost:9099")
 
# Use the tools in a chat completion
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "What is 6 times 7?"}],
    model="gpt-4o",
    tool_choice="generate",
)
 
print(response.choices[0].message.content)

How it works

By decorating your functions with @tool, you expose them to the Arcade platform.

The Annotated types and docstrings provide metadata that helps the AI understand how to use your tools.

Next steps

Try adding more tools to your toolkit, such as sqrt, sum_list, or sum_range.

Explore advanced features like tool authorization and evaluation to enhance your tools.