Adding an integration
AI applications commonly need to manipulate data from third-party services. You can create your own tools that do this, or use Mastra’s integrations.
Adding API-key based integrations
Mastra’s default integrations are packaged as individually installable modules, which you can add to your project.
You can install an integration by installing the package from npm and then importing it into your Mastra config file.
For example, for Github, you’d run:
terminal
npm install @mastra/github
Add it to your integrations
array:
src/mastra/integrations/index.ts
import { GithubIntegration } from '@mastra/github';
export const integrations = [
new GithubIntegration({
config: {
PERSONAL_ACCESS_TOKEN: process.env.PAT!,
},
}),
];
Then import the integration array into your mastra.config.ts
file:
src/mastra/index.ts
import { integrations } from './integrations';
export const config: Config = {
...restOfConfig,
integrations,
};