| .. | ||
| src/mastra | ||
| .env.example | ||
| .gitignore | ||
| LICENSE | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| tsconfig.json | ||
Arcade - Mastra Integration
This example demonstrates how to integrate Arcade with Mastra to create powerful AI agents. Arcade provides access to a wide range of tools including Gmail, Slack, LinkedIn, and more, while Mastra provides a robust framework for building AI agents with TypeScript.
For a list of all available tools and authentication options, see the Arcade Integrations documentation. You can also build custom tools with the Tool SDK as described in our documentation.
Prerequisites
- Node.js (v20.0 or higher)
- pnpm (v9.15.9 or higher)
- OpenAI API key
- Arcade API key
Installation
- Install dependencies:
pnpm install
- Set up environment variables:
-
Copy
.env.exampleto.env -
Fill in your API keys:
OPENAI_API_KEY=your_openai_api_key ARCADE_API_KEY=your_arcade_api_key
-
Basic Usage
This example demonstrates how to use Arcade's Google toolkit with Mastra to create an AI agent that can help users manage their Google services (Gmail, Calendar, Sheets, Drive, and Contacts). The agent will access your Google account (after authorization) and perform various tasks based on user requests.
To get started:
- Start the Mastra playground:
pnpm dev
- Open your browser and navigate to http://localhost:4111/
The Mastra playground provides an interactive interface where you can:
- Chat with your agent
- Execute specific tools
Authorization
When using tools that require authorization, the agent will provide an authorization URL. You'll need to:
- Click on the authorization URL provided in the chat/execution interface
- Complete the authorization flow in your browser
- Return to the Mastra playground to continue your interaction
This authorization process is handled by the executeOrAuthorizeZodTool helper function, which checks if a tool requires authorization and returns the appropriate URL when needed. Once authorized, the tool will execute normally in subsequent requests without requiring re-authorization.
Development
To modify or extend the functionality:
- Update the
userIdinagents/google.tswith your application's user identification - Modify the
toolkitparameter inarcade.tools.list()to access different tools. Available toolkits include:"google"- Gmail, Google Calendar, Google Drive"slack"- Slack messaging and channels"github"- GitHub repositories and issues- And more in Arcade Integrations documentation
Security
- Never commit your
.envfile - Use appropriate user identification in production
License
This project is licensed under the MIT License - see the LICENSE file for details.