# Connect TypeScript (MCP SDK) to aicharged.io

> The official TypeScript MCP SDK (2.3.0 or newer) with the StreamableHTTPClientTransport.

## At a glance

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

- MCP: `https://aicharged.io/api/v1/mcp`
- Docs: https://ts.sdk.modelcontextprotocol.io

## Recipe

Install the package:

```sh
npm install @modelcontextprotocol/client@^2.3.0
```

Use 2.3.0 or newer (security fix for headers re-sent on redirects).

Client code:

```ts
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';

const client = new Client({ name: 'my-app', version: '1.0.0' });
await client.connect(new StreamableHTTPClientTransport(new URL('https://aicharged.io/api/v1/mcp'), {
  requestInit: { headers: { Authorization: `Bearer ${process.env.AICHARGED_API_KEY}` } },
}));
const { tools } = await client.listTools();
console.log(tools.map((tool) => tool.name));
console.log(await client.callTool({ name: 'list_runs', arguments: {} }));
```

[Client documentation](https://ts.sdk.modelcontextprotocol.io)

## 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/typescript-sdk
