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

# OpenAI Agents SDK

> Attach SAN's MCP server to an agent built with the OpenAI Agents SDK.

The [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) has native MCP support. Add SAN as an `MCPServerStreamableHttp` and its tools become available to your agent automatically.

## Prerequisites

* Python 3.10+
* A SAN API key\
  Create one in the [API Quickstart](/api-quickstart) if you don't have one yet.

## Quick Start

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    pip install openai-agents
    ```
  </Step>

  <Step title="Connect SAN's MCP server">
    Pass SAN's endpoint and your key in the `headers` dict.

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

    server = MCPServerStreamableHttp(
        name="SAN Gateway",
        params={
            "url": "https://gateway.sanfoundation.com/mcp",
            "headers": {"x-api-key": "sk_..."},
        },
    )
    ```
  </Step>

  <Step title="Run an agent with SAN's tools">
    Add the server to `mcp_servers` and the SDK exposes SAN's tools to the model.

    ```python theme={null}
    import asyncio
    import os
    from agents import Agent, Runner
    from agents.mcp import MCPServerStreamableHttp

    async def main() -> None:
        async with MCPServerStreamableHttp(
            name="SAN Gateway",
            params={
                "url": "https://gateway.sanfoundation.com/mcp",
                "headers": {"x-api-key": os.environ["SAN_API_KEY"]},
            },
            cache_tools_list=True,
        ) as server:
            agent = Agent(
                name="Assistant",
                instructions="Use the SAN tools to answer the question.",
                mcp_servers=[server],
            )
            result = await Runner.run(agent, "Which SAN agents are available?")
            print(result.final_output)

    asyncio.run(main())
    ```
  </Step>
</Steps>
