# Connect Python (MCP SDK) to aicharged.io

> The official Python MCP SDK (v1): a Streamable HTTP client with an Authorization header.

## 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://py.sdk.modelcontextprotocol.io

## Recipe

Install the package:

```sh
pip install "mcp<2"
```

Client code:

```python
import asyncio, os
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async def main():
    headers = {"Authorization": f"Bearer {os.environ['AICHARGED_API_KEY']}"}
    async with streamablehttp_client("https://aicharged.io/api/v1/mcp", headers=headers) as (read, write, _):
        async with ClientSession(read, write) as session:
            await session.initialize()
            tools = await session.list_tools()
            print([tool.name for tool in tools.tools])
            print(await session.call_tool("list_runs", {}))

asyncio.run(main())
```

[Client documentation](https://py.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/python-sdk
