> ## 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.

# AutoGen

> Give a Microsoft AutoGen AssistantAgent access to SAN over MCP.

Microsoft AutoGen (AgentChat, v0.4+) connects to SAN through the `autogen-ext` MCP tools. Wrap SAN's endpoint in an `McpWorkbench` and attach it to an `AssistantAgent`.

## 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 AutoGen with the MCP extra">
    ```bash theme={null}
    pip install "autogen-agentchat" "autogen-ext[mcp,openai]"
    ```
  </Step>

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

    ```python theme={null}
    from autogen_ext.tools.mcp import StreamableHttpServerParams

    server_params = StreamableHttpServerParams(
        url="https://gateway.sanfoundation.com/mcp",
        headers={"x-api-key": "sk_..."},
    )
    ```
  </Step>

  <Step title="Run an agent with SAN's tools">
    Open an `McpWorkbench` and hand it to your `AssistantAgent`.

    ```python theme={null}
    import asyncio
    from autogen_agentchat.agents import AssistantAgent
    from autogen_ext.models.openai import OpenAIChatCompletionClient
    from autogen_ext.tools.mcp import McpWorkbench, StreamableHttpServerParams

    async def main() -> None:
        server_params = StreamableHttpServerParams(
            url="https://gateway.sanfoundation.com/mcp",
            headers={"x-api-key": "sk_..."},
        )
        model_client = OpenAIChatCompletionClient(model="gpt-4o")

        async with McpWorkbench(server_params) as workbench:
            agent = AssistantAgent(
                name="san_assistant",
                model_client=model_client,
                workbench=workbench,
            )
            result = await agent.run(task="Which SAN agents are available?")
            print(result)

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