arcade-mcp/examples/ai-sdk
Sergio Serrano dfe3005fe6
Update example with the last version of arcade-js (#396)
Update our example with the latest version of `arcade-js`. This means we
can delete all the utility functions we created here, since we now have
first-class `Zod` support and they are no longer needed.

> [!WARNING]
> Don't merge until this
[PR](https://github.com/ArcadeAI/arcade-js/pull/127) is merged.
2025-05-12 14:02:11 -03:00
..
.env.example Add an example for the AI SDK (#343) 2025-04-03 12:42:14 -03:00
.gitignore Add an example for the AI SDK (#343) 2025-04-03 12:42:14 -03:00
generateText.js Update example with the last version of arcade-js (#396) 2025-05-12 14:02:11 -03:00
index.js Update example with the last version of arcade-js (#396) 2025-05-12 14:02:11 -03:00
LICENSE Add an example for the AI SDK (#343) 2025-04-03 12:42:14 -03:00
package.json Update example with the last version of arcade-js (#396) 2025-05-12 14:02:11 -03:00
pnpm-lock.yaml Update example with the last version of arcade-js (#396) 2025-05-12 14:02:11 -03:00
README.md Update example with the last version of arcade-js (#396) 2025-05-12 14:02:11 -03:00

Fallback image description

Arcade AI SDK Example

License

Arcade DocumentationIntegrationsArcade JS ClientAI SDK

Arcade - AI SDK

This example demonstrates how to integrate Arcade with the Vercel AI SDK to create powerful AI agents. Arcade provides access to a wide range of tools including Gmail, Slack, LinkedIn, and more. You can also develop custom tools using the Tool SDK.

For a list of all hosted tools and auth providers, see the Arcade Integrations 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 Google toolkit to create an AI agent that can read and summarize emails. The agent will access your Gmail account (after authorization) and process your most recent email.

To get started, run the development server:

pnpm dev

If you haven't authorized Arcade with Google yet, you'll see a message like this:

> pnpm dev
Authorization Required: Please visit this link to connect your Google account: https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&client_id=....

Visit the provided URL in your browser to authorize Arcade with Google. Once authorized, run the script again.

You can also wait for authorization to complete before running the script using the helper methods in arcade.js.

Once you've authorized Arcade with a tool, you can use it in your agent by passing the user_id and won't need to authenticate for that specific tool again.

Development

To modify or extend the functionality:

  1. Update the USER_ID constant in index.js with your application's user identification
  2. Modify the toolkit parameter in getArcadeTools 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 .env file
  • Keep your API keys secure
  • Use appropriate user identification in production

License

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