Pydantic AI
Connect Unizo MCP to Pydantic AI with built-in MCP server support.
Overview
Pydantic AI includes native MCP integration via the mcp_servers parameter, enabling seamless connection to Unizo's MCP server.
Prerequisites
Before setting up the MCP integration, you'll need:
- Unizo API Key: Used for authentication (found in the Unizo Console)
- Python 3.10+: Required for Pydantic AI
- OpenAI API Key: For the underlying LLM
Installation
uv add pydantic-ai python-dotenv openai
Or using pip:
pip install pydantic-ai python-dotenv openai
Authentication
Step 1: Generate a Service Key
Use your Unizo API key to generate a service key for MCP authentication:
curl --location 'https://api.unizo.ai/api/v1/serviceKeys' \
--header "apiKey: {unizo_api_key}" \
--header "Content-Type: application/json" \
--data '{
"name": "MCP LangChain Integration",
"subOrganization": {
"name": "{YOUR_CUSTOMER_NAME}",
"externalKey": "{YOUR_CUSTOMER_UNIQUE_IDENTIFIER}"
},
"integration": {
"target": {
"categorySelectors": [
{
"type": "TICKETING"
}
]
}
}
}'
Required Parameters:
| Parameter | Description |
|---|---|
apiKey | Your Unizo API key (found in the Unizo Console) |
name | Descriptive name for the integration (e.g., "MCP LangChain Integration") |
subOrganization.name | Your organization name (e.g., "Acme Inc") |
subOrganization.externalKey | Unique identifier (UUID format recommended) |
Response:
{
"state": "ACTIVE",
"displayId": "{UNIZO_SERVICE_KEY}",
...
}
Important: Save the displayId from the response - this is your service key for authenticating with the MCP server.
Step 2: Configure Environment Variables
Create a .env file in your project root:
OPENAI_API_KEY=your_openai_api_key
Quick Start
Connect to Unizo MCP and create an agent:
import os
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStreamableHTTP
from dotenv import load_dotenv
load_dotenv()
# Create agent with Unizo MCP server
agent = Agent(
model="openai:gpt-5",
mcp_servers=[
MCPServerStreamableHTTP(
url="https://api.unizo.ai/mcp",
headers={
"servicekey": os.getenv('UNIZO_SERVICE_KEY'),
"x-mcp-scopes": "TICKETING" # Comma-separated scopes (TICKETING, VMS, etc.)
}
)
]
)
# Query the agent
result = agent.run_sync("List available ticketing connectors from Unizo")
print(result.data)
Headers
| Header | Description |
|---|---|
servicekey | Your Unizo service key (from the authentication step) |
x-mcp-scopes (optional) | Supported scopes include TICKETING, VMS, INCIDENT, SCM, PCR, COMMS, IDENTITY, OBSERVABILITY, KEY_MANAGEMENT, INFRA, EDR, STORAGE, and PLATFORM. Note: If x-mcp-scopes is not specified, all scopes are enabled by default. |