Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions app/en/get-started/quickstarts/call-tool-agent/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ description: "Learn how to call tools in your agent"
import { Steps, Tabs, Callout } from "nextra/components";
import { SignupLink } from "@/app/_components/analytics";

<!-- Editorial: Voice and Tone - Changed "gives your AI agents the power to act" to more direct language; Structure - Converted to 10/20/70 format with proper intro -->

# Calling tools in your agent with Arcade

Arcade gives your AI agents the power to act. With Arcade-hosted tools, your AI-powered apps can send Gmail, update Notion, message in Slack, and more.
Learn how to install and use the Arcade client to call Arcade-hosted tools from your AI agent.

With Arcade-hosted tools, your AI-powered apps can send Gmail, update Notion, message in Slack, and more. This quickstart shows you how to chain multiple tools together to create a workflow that searches for news, creates a Google Doc, and emails the results to a user.

You'll need an Arcade account and API key to get started. The example demonstrates handling OAuth authorization flows and executing tools that require user permissions.

<GuideOverview>
<GuideOverview.Outcomes>
Expand Down Expand Up @@ -81,7 +87,7 @@ bun install @arcadeai/arcadejs

</Tabs>

### Setup the client
### Set up the client

<Tabs items={["Python", "TypeScript"]} storageKey="preferredLanguage">

Expand Down Expand Up @@ -125,7 +131,7 @@ let userId = "{arcade_user_id}";

### Write a helper function to authorize and run tools

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

<Tabs items={["Python", "JavaScript"]} storageKey="preferredLanguage">

Expand Down Expand Up @@ -195,7 +201,7 @@ async function authorize_and_run_tool({

### Implement the workflow

In this example workflow, we:
In this example workflow, you:

- Get the latest news about MCP URL mode elicitation
- Create a Google Doc with the news
Expand All @@ -207,7 +213,7 @@ In this example workflow, we:

```python filename="main.py"
# This tool does not require authorization, so it will return the results
# without prompting the user to authorize the tool call.
# without prompting for authorization.
response_search = authorize_and_run_tool(
tool_name="GoogleNews.SearchNewsStories",
input={
Expand All @@ -226,7 +232,7 @@ for search_result in news:
output += f"{search_result['link']}\n\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.
# If the user has not previously authorized the Google Docs tool, the system prompts for authorization.
response_create_doc = authorize_and_run_tool(
tool_name="GoogleDocs.CreateDocumentFromText",
input={
Expand All @@ -253,7 +259,7 @@ response_send_email = authorize_and_run_tool(
)

# Print the response from the tool call
print(f"Success! Check your email at {user_id}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:")
print(f"Success Check your email at {user_id}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:")
print(response_send_email.output.value)
```

Expand All @@ -263,7 +269,7 @@ print(response_send_email.output.value)

```typescript filename="example.ts"
// This tool does not require authorization, so it will return the results
// without prompting the user to authorize the app.
// without prompting for authorization.
const response_search = await authorize_and_run_tool({
tool_name: "GoogleNews.SearchNewsStories",
input: {
Expand All @@ -284,7 +290,7 @@ for (const search_result of news) {
}

// 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.
// If the user has not previously authorized the Google Docs tool, the system prompts for authorization.
const respose_create_doc = await authorize_and_run_tool({
tool_name: "GoogleDocs.CreateDocumentFromText",
input: {
Expand All @@ -299,7 +305,7 @@ const google_doc = respose_create_doc.output?.value;
// Send an email with the link to the Google Doc
const email_body = `You can find the news about MCP URL mode elicitation in the following Google Doc: ${google_doc.documentUrl}`;

// Here again, if the user has not previously authorized the Gmail tool, they will be prompted to authorize the tool call.
// Here again, if the user has not previously authorized the Gmail tool, the system prompts for authorization.
const respose_send_email = await authorize_and_run_tool({
tool_name: "Gmail.SendEmail",
input: {
Expand All @@ -312,7 +318,7 @@ const respose_send_email = await authorize_and_run_tool({

// Print the response from the tool call
console.log(
`Success! Check your email at ${userId}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:`
`Success Check your email at ${userId}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:`
);
console.log(respose_send_email.output?.value);
```
Expand All @@ -332,7 +338,7 @@ console.log(respose_send_email.output?.value);
```

```text
Success! Check your email at {arcade_user_id}
Success Check your email at {arcade_user_id}

You just chained 3 tools together:
1. Searched Google News for stories about MCP URL mode elicitation
Expand All @@ -351,7 +357,7 @@ console.log(respose_send_email.output?.value);
```

```text
Success! Check your email at {arcade_user_id}
Success Check your email at {arcade_user_id}

You just chained 3 tools together:
1. Searched Google News for stories about MCP URL mode elicitation
Expand All @@ -372,11 +378,11 @@ console.log(respose_send_email.output?.value);

</Steps>

## Next Steps
## Next steps

In this simple example, we call the tool methods directly. In your real applications and agents, you'll likely be letting the LLM decide which tools to call. Learn more about using Arcade with Frameworks in the [Frameworks](/get-started/agent-frameworks) section, or [how to build your own tools](/guides/create-tools/tool-basics/build-mcp-server).
In this example, you call the tool methods directly. In your real applications and agents, you'll likely be letting the LLM decide which tools to call. Learn more about using Arcade with frameworks in the [Frameworks](/get-started/agent-frameworks) section, or [how to build your own tools](/guides/create-tools/tool-basics/build-mcp-server).

## Example Code
## Example code

<Tabs items={["Python", "TypeScript"]} storageKey="preferredLanguage">

Expand Down Expand Up @@ -413,7 +419,7 @@ def authorize_and_run_tool(tool_name, input, user_id):
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.
# without prompting for authorization.
response_search = authorize_and_run_tool(
tool_name="GoogleNews.SearchNewsStories",
input={
Expand All @@ -433,7 +439,7 @@ for search_result in news:
output += f"{search_result['link']}\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.
# If the user has not previously authorized the Google Docs tool, the system prompts for authorization.
response_create_doc = authorize_and_run_tool(
tool_name="GoogleDocs.CreateDocumentFromText",
input={
Expand All @@ -460,7 +466,7 @@ response_send_email = authorize_and_run_tool(
)

# Print the response from the tool call
print(f"Success! Check your email at {user_id}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:")
print(f"Success Check your email at {user_id}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:")
print(response_send_email.output.value)
```
</details>
Expand Down Expand Up @@ -520,7 +526,7 @@ async function authorize_and_run_tool({
}

// This tool does not require authorization, so it will return the results
// without prompting the user to authorize the app.
// without prompting for authorization.
const response_search = await authorize_and_run_tool({
tool_name: "GoogleNews.SearchNewsStories",
input: {
Expand All @@ -541,7 +547,7 @@ for (const search_result of news) {
}

// 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.
// If the user has not previously authorized the Google Docs tool, the system prompts for authorization.
const respose_create_doc = await authorize_and_run_tool({
tool_name: "GoogleDocs.CreateDocumentFromText",
input: {
Expand All @@ -556,7 +562,7 @@ const google_doc = respose_create_doc.output?.value;
// Send an email with the link to the Google Doc
const email_body = `You can find the news about MCP URL mode elicitation in the following Google Doc: ${google_doc.documentUrl}`;

// Here again, if the user has not previously authorized the Gmail tool, they will be prompted to authorize the tool call.
// Here again, if the user has not previously authorized the Gmail tool, the system prompts for authorization.
const respose_send_email = await authorize_and_run_tool({
tool_name: "Gmail.SendEmail",
input: {
Expand All @@ -569,11 +575,11 @@ const respose_send_email = await authorize_and_run_tool({

// Print the response from the tool call
console.log(
`Success! Check your email at ${userId}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:`
`Success Check your email at ${userId}\n\nYou just chained 3 tools together:\n 1. Searched Google News for stories about MCP URL mode elicitation\n 2. Created a Google Doc with the results\n 3. Sent yourself an email with the document link\n\nEmail metadata:`
);
console.log(respose_send_email.output?.value);
```
</details>

</Tabs.Tab>
</Tabs>
</Tabs>
Loading