Home
Build tools
Tool Context

Understanding ToolContext

What is ToolContext?

ToolContext is a crucial component in Arcade AI that manages authorization and user information for tools requiring authentication. Let's explore how it works and how you can use it in your projects.

ToolContext is a class that holds two main pieces of information:

  1. Authorization context: This includes a token for making authenticated requests to external APIs as well as structured user information for providers that support retrieving user information.
  2. User ID: This identifies the user invoking the tool.

Some authorization providers may also include additional structured user information in the ToolContext.

How ToolContext Works

When you invoke a tool that requires authorization, Arcade AI's Tool SDK automatically:

  1. Creates a ToolContext object
  2. Passes this object to your tool

You can then use the ToolContext object to make authenticated requests to external APIs.

Next Steps

Now that you understand the basics of ToolContext, you're ready to apply this knowledge in creating your own authorized tools. To learn how to build a custom tool that requires user authorization, check out our guide on Adding user authorization to your tools.