arcade-mcp/examples/mastra
Ray Smets c7c485152f
[Mastra] example toolkit project updated (#561)
## Summary

Updated the Mastra example project to include leveraging multiple
toolkits into one Mastra agent. Additionally, the `package.json`
versions were pinned to the latest versions to avoid potential issues
with breaking changes as Mastra progresses through v0.x.x packages.
Also, by pinning the version, it demonstrates the latest confirmed
arcade-js compatibility version.

These changes were initiated when trying to debug an
[issue](https://github.com/ArcadeAI/arcade-ai/issues/560) using Arcade
toolkits with Mastra agents. Notably, I confirmed that there is no flaw
in arcade-js, which was suspected in the issue, by successfully using
the toolkits with the latest Mastra packages.

## Changes

* inboxTravelAgent created showcasing `GoogleFlights`, `GoogleHotels`,
and `Gmail` Arcade toolkits together
* package.json versions pinned to the latest working versions. 

## Testing

Ran the Mastra project locally and invoked the tools via the agent chat
interface.
2025-09-15 13:02:49 -03:00
..
src/mastra [Mastra] example toolkit project updated (#561) 2025-09-15 13:02:49 -03:00
.env.example Add Mastra Integration Example (#397) 2025-05-12 14:35:47 -03:00
.gitignore Add Mastra Integration Example (#397) 2025-05-12 14:35:47 -03:00
LICENSE Add Mastra Integration Example (#397) 2025-05-12 14:35:47 -03:00
package.json [Mastra] example toolkit project updated (#561) 2025-09-15 13:02:49 -03:00
pnpm-lock.yaml [Mastra] example toolkit project updated (#561) 2025-09-15 13:02:49 -03:00
README.md Update examples (#516) 2025-07-28 09:49:00 -07:00
tsconfig.json Add Mastra Integration Example (#397) 2025-05-12 14:35:47 -03:00

Arcade - Mastra Example

License

Arcade DocumentationIntegrationsArcade JS ClientMastra

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

Installation

  1. Install dependencies:
pnpm install
  1. Set up environment variables:
    • Copy .env.example to .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 Gmail toolkit with Mastra to create an AI agent that can help users manage their email. The agent will access your Google account (after authorization) and perform various tasks based on user requests.

To get started:

  1. Start the Mastra playground:
pnpm dev
  1. 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:

  1. Click on the authorization URL provided in the chat/execution interface
  2. Complete the authorization flow in your browser
  3. 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:

  1. Update the userId in agents/gmail.ts with your application's user identification
  2. Modify the toolkit parameter in arcade.tools.list() to access different tools. Available toolkits include:
    • "gmail" - Gmail
    • "slack" - Slack messaging and channels
    • "github" - GitHub repositories and issues
    • And more in Arcade Integrations documentation

Security

  • Never commit your .env file
  • Use appropriate user identification in production

License

This project is licensed under the MIT License - see the LICENSE file for details.