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

# AutoGen

> Connect a Microsoft AutoGen agent to Civic's MCP Hub using streamable HTTP transport

Connect a [Microsoft AutoGen](https://microsoft.github.io/autogen/) agent to Civic using `mcp_server_tools` with Streamable HTTP transport and the native Anthropic model client.

## Prerequisites

* Python 3.11+
* A Civic account at [app.civic.com](https://app.civic.com) with a configured toolkit
* A Civic token and an Anthropic API key

## Installation

```bash theme={null}
pip install "autogen-agentchat" "autogen-ext[mcp,anthropic]" python-dotenv
```

## Environment Variables

```bash theme={null}
CIVIC_URL=https://app.civic.com/hub/mcp?profile=your-toolkit
CIVIC_TOKEN=your-civic-token
ANTHROPIC_API_KEY=your-anthropic-key
```

<Card title="Get Your Credentials" icon="key" href="/civic/quickstart/credentials">
  How to generate a Civic token and configure toolkit URL parameters
</Card>

## Connecting to Civic

Use `mcp_server_tools` to discover and load all Civic tools, then pass them to an `AssistantAgent`:

```python theme={null}
import os
import asyncio
from dotenv import load_dotenv
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.tools.mcp import mcp_server_tools, StreamableHttpServerParams
from autogen_ext.models.anthropic import AnthropicChatCompletionClient

load_dotenv()

async def main():
    server_params = StreamableHttpServerParams(
        url=os.environ["CIVIC_URL"],
        headers={"Authorization": f"Bearer {os.environ['CIVIC_TOKEN']}"},
    )
    tools = await mcp_server_tools(server_params)
    print(f"{len(tools)} tools loaded")

    model_client = AnthropicChatCompletionClient(model="claude-sonnet-4-6")

    agent = AssistantAgent(
        name="civic_assistant",
        model_client=model_client,
        tools=tools,
        system_message="You are a helpful assistant with access to Civic tools.",
    )

    response = await agent.run(task="What events do I have today?")
    print(response.messages[-1].content)

asyncio.run(main())
```

<Note>
  Use `mcp_server_tools(server_params)` — not `StreamableHttpMcpToolAdapter`. The adapter requires a `tool` argument that is not available during initialization.
</Note>

## Production Configuration

For production agents, lock to a specific toolkit using the `profile` URL parameter:

```bash theme={null}
CIVIC_URL=https://app.civic.com/hub/mcp?profile=your-production-toolkit
```

## Reference Implementation

<Card title="autogen-reference-implementation-civic" icon="github" href="https://github.com/civicteam/autogen-reference-implementation-civic">
  Complete implementation with FastAPI chat UI and deployment guide
</Card>

## Next Steps

<CardGroup cols={2}>
  <Card title="Agent Deployment" icon="robot" href="/civic/quickstart/clients/agents">
    Production deployment guide: profile locking, URL params, authentication
  </Card>

  <Card title="Guardrails" icon="shield" href="/civic/concepts/guardrails">
    Constrain what tools your agent can call
  </Card>

  <Card title="Audit Trail" icon="list-check" href="/civic/concepts/audit">
    Query what your agent did via Civic Chat
  </Card>

  <Card title="Get Credentials" icon="key" href="/civic/quickstart/credentials">
    Token generation and URL parameter reference
  </Card>
</CardGroup>
