> ## Documentation Index
> Fetch the complete documentation index at: https://docs.askalchemist.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Agents SDK

> Connect Alchemist as an MCP server from the OpenAI Agents SDK (Python or JS).

The [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) acts as an MCP client directly — your app connects to Alchemist over Streamable HTTP and the tools become available to the agent. Authenticate with your API key on the `Authorization` header.

Get a key at [app.askalchemist.com/settings/api-keys](https://app.askalchemist.com/settings/api-keys).

## Python

```python theme={null}
from agents import Agent
from agents.mcp import MCPServerStreamableHttp

async with MCPServerStreamableHttp(
    name="Alchemist",
    params={
        "url": "https://api.askalchemist.com/mcp/",
        "headers": {"Authorization": "Bearer alch_YOUR_KEY"},
    },
) as server:
    agent = Agent(name="Assistant", mcp_servers=[server])
```

## TypeScript / JavaScript

```ts theme={null}
import { Agent, MCPServerStreamableHttp } from '@openai/agents';

const server = new MCPServerStreamableHttp({
  url: 'https://api.askalchemist.com/mcp/',
  name: 'Alchemist',
  requestInit: { headers: { Authorization: 'Bearer alch_YOUR_KEY' } },
});
const agent = new Agent({ name: 'Assistant', mcpServers: [server] });
await server.connect();
```

<Note>
  The JS SDK also accepts an `authProvider` (the MCP TypeScript SDK's `OAuthClientProvider`) if you'd rather run the OAuth flow than pass a static key.
</Note>

To let OpenAI's model call Alchemist server-side instead of connecting from your process, use the [Responses API](/agents/openai-responses) (or the SDK's `HostedMCPTool` / `hostedMcpTool` wrappers).
