Skip to content

Commit a4acb12

Browse files
authored
[chore] update Mastra example docs to better match the example repo (#444)
* [chore] update Mastra example docs to better match the example repo * [docs] toolkit cli usage mention * [fix] variable refactor missed updates * [chore] update agent directive
1 parent 2fb33ee commit a4acb12

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

pages/home/mastra/use-arcade-tools.mdx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ import {
8484
// Initialize Arcade
8585
const arcade = new Arcade();
8686

87+
// Get Gmail toolkit
88+
// Toolkit names can be found in the Arcade dashboard via Tools > view > Toolkit or via the CLI `arcade workers list`
89+
const gmailToolkit = await arcade.tools.list({ toolkit: "Gmail", limit: 30 });
90+
8791
// Get Gmail tools
88-
const googleToolkit = await arcade.tools.list({ toolkit: "gmail", limit: 30 });
89-
export const googleTools = toZodToolSet({
90-
tools: googleToolkit.items,
92+
export const gmailTools = toZodToolSet({
93+
tools: gmailToolkit.items,
9194
client: arcade,
9295
userId: "<YOUR_USER_ID>", // Your app's internal ID for the user (an email, UUID, etc). It's used internally to identify your user in Arcade
9396
executeFactory: executeOrAuthorizeZodTool, // Checks if tool is authorized and executes it, or returns authorization URL if needed
@@ -104,13 +107,19 @@ import { Agent } from "@mastra/core/agent";
104107
import { anthropic } from "@ai-sdk/anthropic";
105108

106109
// Create the Mastra agent with Arcade tools
107-
export const googleAgent = new Agent({
108-
name: "googleAgent",
109-
instructions: `You are a Google assistant that helps users manage their Google services (Gmail, Calendar, Sheets, Drive, and Contacts).
110-
If a tool requires authorization, you will receive an authorization URL.
111-
When that happens, clearly present this URL to the user and ask them to visit it to grant permissions.`,
110+
export const gmailAgent = new Agent({
111+
name: "gmailAgent",
112+
instructions: `You are a Gmail assistant that helps users manage their inbox.
113+
114+
When helping users:
115+
- Always verify their intent before performing actions
116+
- Keep responses clear and concise
117+
- Confirm important actions before executing them
118+
- Respect user privacy and data security
119+
120+
Use the gmailTools to interact with various Gmail services and perform related tasks.`,
112121
model: anthropic("claude-3-7-sonnet-20250219"),
113-
tools: googleTools,
122+
tools: gmailTools,
114123
});
115124
```
116125

@@ -126,21 +135,21 @@ Start the Mastra development server:
126135
npm run dev
127136
```
128137

129-
This will launch a local development playground, typically accessible at `http://localhost:4111`. Open this URL in your browser, select the `googleAgent` from the list of available agents, and start chatting with it directly in the UI.
138+
This will launch a local development playground, typically accessible at `http://localhost:4111`. Open this URL in your browser, select the `gmailAgent` from the list of available agents, and start chatting with it directly in the UI.
130139

131140
**2. Programmatically:**
132141

133142
Alternatively, you can interact with the agent directly in your code:
134143

135144
```typescript
136145
// Generate a response from the agent
137-
const response = await googleAgent.generate(
146+
const response = await gmailAgent.generate(
138147
"Read my last email and summarize it in a few sentences",
139148
);
140149
console.log(response.text);
141150

142151
// Or stream the response for a more interactive experience
143-
const stream = await googleAgent.stream("Send an email to [email protected] with the subject 'Hello from Mastra'");
152+
const stream = await gmailAgent.stream("Send an email to [email protected] with the subject 'Hello from Mastra'");
144153

145154
for await (const chunk of stream.textStream) {
146155
process.stdout.write(chunk);

0 commit comments

Comments
 (0)