Skip to Content
HomeCalling tools in your agent

Calling tools in your agent with Arcade

Arcade gives your AI the power to act. With Arcade-hosted , your AI-powered apps can send Gmail, update Notion, message in Slack, and more.

Outcomes

Install and use the to call Arcade Hosted .

You will Learn

  • Install the
  • Build a simple workflow that uses to:
    • search for news with Google News
    • Create a Google Doc with the news
    • Sends a link to the Google Doc to a Slack
  • Present an OAuth URL to the user when the requires authorization

Prerequisites

Install the Arcade client

In your terminal, run the following command to install the Python client package arcadepy:

Terminal
uv pip install arcadepy

Setup the client

Create a new script called example.py:

Python
example.py
# You can also set the `ARCADE_API_KEY` environment variable instead of passing it as a parameter. client = Arcade(api_key="{arcade_api_key}") # Arcade needs a unique identifier for your application user (this could be an email address, a UUID, etc). # In this example, use the email you used to sign up for Arcade.dev: user_id = "{arcade_user_id}"

Write a helper function to authorize and run tools

This helper function will check if a requires authorization and if so, it will print the authorization URL and wait for the to authorize the tool call. If the tool does not require authorization, it will run the tool directly without interrupting the flow.

Python
example.py
# Helper function to authorize and run any tool def authorize_and_run_tool(tool_name, input, user_id): # Start the authorization process auth_response = client.tools.authorize( tool_name=tool_name, user_id=user_id, ) # If the authorization is not completed, print the authorization URL and wait for the user to authorize the app. # Tools that do not require authorization will have the status "completed" already. if auth_response.status != "completed": print(f"Click this link to authorize {tool_name}: {auth_response.url}. The process will continue once you have authorized the app.") client.auth.wait_for_completion(auth_response.id) # Run the tool return client.tools.execute(tool_name=tool_name, input=input, user_id=user_id)

Implement the workflow

In this example workflow, we:

  • Get the latest news about URL mode elicitation
  • Create a Google Doc with the news
  • Send a link to the Google Doc to the
Python
example.py
# This tool does not require authorization, so it will return the results # without prompting the user to authorize the tool call. response_search = authorize_and_run_tool( tool_name="GoogleNews.SearchNewsStories", input={ "keywords": "MCP URL mode elicitation", }, user_id=user_id, ) # Get the news results from the response news = response_search.output.value["news_results"] # Format the news results into a string output = "latest news about MCP URL mode elicitation:\n" for search_result in news: output += f"{search_result['source']} - {search_result['title']}\n" output += f"{search_result['snippet']}\n" # Create a Google Doc with the news results # If the user has not previously authorized the Google Docs tool, they will be prompted to authorize the tool call. response_create_doc = authorize_and_run_tool( tool_name="GoogleDocs.CreateDocumentFromText", input={ "title": "News about MCP URL mode elicitation", "text_content": output, }, user_id=user_id, ) # Get the Google Doc from the response google_doc = response_create_doc.output.value email_body = f"You can find the news about MCP URL mode elicitation in the following Google Doc: {google_doc['documentUrl']}" # Send an email with the link to the Google Doc response_send_email = authorize_and_run_tool( tool_name="Gmail.SendEmail", input={ "recipient": user_id, "subject": "News about MCP URL mode elicitation", "body": email_body, }, user_id=user_id, ) # Print the response from the tool call print(response_send_email.output.value)

Run the code

Terminal
uv run example.py > The square root of 625 is 25 > Successfully starred the repository ArcadeAI/arcade-mcp

Next Steps

In this simple example, we call the tool methods directly. In your real applications and , you’ll likely be letting the LLM decide which to call. Learn more about using Arcade with Frameworks in the Frameworks section, or how to build your own tools.

Example Code

Python
example.py
from arcadepy import Arcade # You can also set the `ARCADE_API_KEY` environment variable instead of passing it as a parameter. client = Arcade(api_key="{arcade_api_key}") # Arcade needs a unique identifier for your application user (this could be an email address, a UUID, etc). # In this example, use the email you used to sign up for Arcade.dev: user_id = "{arcade_user_id}" # Helper function to authorize and run any tool def authorize_and_run_tool(tool_name, input, user_id): # Start the authorization process auth_response = client.tools.authorize( tool_name=tool_name, user_id=user_id, ) # If the authorization is not completed, print the authorization URL and wait for the user to authorize the app. # Tools that do not require authorization will have the status "completed" already. if auth_response.status != "completed": print(f"Click this link to authorize {tool_name}: {auth_response.url}. The process will continue once you have authorized the app.") client.auth.wait_for_completion(auth_response.id) # Run the tool return client.tools.execute(tool_name=tool_name, input=input, user_id=user_id) # This tool does not require authorization, so it will return the results # without prompting the user to authorize the tool call. response_search = authorize_and_run_tool( tool_name="GoogleNews.SearchNewsStories", input={ "keywords": "MCP URL mode elicitation", }, user_id=user_id, ) # Get the news results from the response news = response_search.output.value["news_results"] # Format the news results into a string output = "latest news about MCP URL mode elicitation:\n" for search_result in news: output += f"{search_result['source']} - {search_result['title']}\n" output += f"{search_result['snippet']}\n" # Create a Google Doc with the news results # If the user has not previously authorized the Google Docs tool, they will be prompted to authorize the tool call. response_create_doc = authorize_and_run_tool( tool_name="GoogleDocs.CreateDocumentFromText", input={ "title": "News about MCP URL mode elicitation", "text_content": output, }, user_id=user_id, ) # Get the Google Doc from the response google_doc = response_create_doc.output.value email_body = f"You can find the news about MCP URL mode elicitation in the following Google Doc: {google_doc['documentUrl']}" # Send an email with the link to the Google Doc response_send_email = authorize_and_run_tool( tool_name="Gmail.SendEmail", input={ "recipient": user_id, "subject": "News about MCP URL mode elicitation", "body": email_body, }, user_id=user_id, ) # Print the response from the tool call print(response_send_email.output.value)
Last updated on

Calling tools in your agent | Arcade Docs