# Connect Mastra to aicharged.io

> Mastra: MCPClient from @mastra/mcp with the key in the requestInit headers.

## At a glance

| Kind | Sign-in | Platforms | Status | Verified |
|---|---|---|---|---|
| SDKs & frameworks | API key (Bearer), OAuth sign-in | macOS, Linux, Windows | works today | 2026-10-22 |

- MCP: `https://aicharged.io/api/v1/mcp`
- Docs: https://mastra.ai/docs/tools-mcp/mcp-overview

## Recipe

Client code:

```ts
import { MCPClient } from '@mastra/mcp';

const mcp = new MCPClient({
  servers: {
    aicharged: {
      url: new URL('https://aicharged.io/api/v1/mcp'),
      requestInit: { headers: { Authorization: `Bearer ${process.env.AICHARGED_API_KEY}` } },
    },
  },
});
const tools = await mcp.listTools();
console.log(Object.keys(tools));
```

Install the package:

```sh
npm install @mastra/mcp
```

[Client documentation](https://mastra.ai/docs/tools-mcp/mcp-overview)

## Authentication

- Send `Authorization: Bearer <API_KEY>` with every request. Create a key at https://aicharged.io/admin/account/api-keys.
- OAuth 2.1 (PKCE S256) is available for clients that cannot send a static key (ChatGPT).
- Without a key the endpoint answers 401 with a WWW-Authenticate header that points to https://aicharged.io/.well-known/oauth-protected-resource.

All 51 clients: https://aicharged.io/connect.md

HTML version: https://aicharged.io/connect/mastra
