Skip to main content
Pydantic AI connects to SAN with MCPToolset from pydantic_ai.mcp. Attach it to any Agent through the toolsets argument.

Prerequisites

  • Python 3.10+
  • A SAN API key
    Create one in the API Quickstart if you don’t have one yet.

Quick Start

1

Install Pydantic AI with the MCP extra

pip install "pydantic-ai-slim[mcp]"
2

Point a toolset at SAN

A URL without an /sse suffix uses streamable HTTP. Pass your key in headers.
from pydantic_ai.mcp import MCPToolset

server = MCPToolset(
    'https://gateway.sanfoundation.com/mcp',
    headers={'x-api-key': 'sk_...'},
)
On Pydantic AI 1.x, this class is MCPServerStreamableHTTP (same arguments). It was renamed to MCPToolset in 2.0.
3

Run an agent with SAN's tools

Pass the toolset via toolsets and open the agent to manage the connection.
import asyncio
from pydantic_ai import Agent

agent = Agent('openai:gpt-4o', toolsets=[server])

async def main() -> None:
    async with agent:
        result = await agent.run('Which SAN agents are available?')
        print(result.output)

asyncio.run(main())