# 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. Mastra includes a number of first-party 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:

```bash npm2yarn copy
npm install @mastra/github
```

Add it to your `integrations` array:

```ts filename="src/mastra/integrations/index.ts" showLineNumbers {1, 4-8} copy
import { GithubIntegration } from "@mastra/github";

export const integrations = [
  new GithubIntegration({
    config: {
      PERSONAL_ACCESS_TOKEN: process.env.PAT!,
    },
  }),
];
```

Then import the integration array into your `index.ts` file:

```ts filename="src/mastra/index.ts" showLineNumbers {1,5} copy
import { integrations } from "./integrations";

export const mastra = new Mastra<typeof integrations>({
  agents: [agentTwo, agentOne],
  integrations,
});
```

Now you can access the integration when defining **tools** your agents should use.

```ts filename="src/mastra/tools/index.ts" showLineNumbers copy
import { integrations } from "../integrations";

export const testTool = createTool({
  label: "Test Tool",
  schema: z.object({ name: z.string(), message: z.string() }),
  description: `This is a test tool`,
  executor: async ({ data, integrationsRegistry, agents, engine, llm }) => {
    const GithubIntegration =
      integrationsRegistry<typeof integrations>().get("GITHUB");

    return data;
  },
});
```
