OpenAI Agents SDK
Integrate Unizo MCP with OpenAI Agents SDK to create sophisticated AI agents with built-in MCP server support.
Overview
OpenAI Agents SDK includes native MCP support via MCPServerStreamableHttp, enabling direct integration with Unizo's MCP server for unified access to all the categories.
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 OpenAI Agents SDK
- OpenAI API Key: For the underlying LLM
Installation
pip install openai-agents
Or with uv:
uv add openai-agents
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 OpenAI Agents 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 OpenAI Agents 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 use tools with OpenAI agents:
import os
import asyncio
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
async def main():
# Create MCP server connection for Unizo
async with MCPServerStreamableHttp(
name="Unizo MCP Server",
params={
"url": "https://api.unizo.ai/mcp",
"headers": {
"servicekey": os.getenv('UNIZO_SERVICE_KEY'),
"x-mcp-scopes": "TICKETING" # Comma-separated scopes (TICKETING, VMS, etc.)
},
"timeout": 10,
},
) as server:
# Create agent with Unizo MCP tools
agent = Agent(
name="unizo-assistant",
instructions="Use the Unizo MCP tools to answer questions about integrations and ticketing.",
mcp_servers=[server],
)
# Run agent with Unizo tools
result = await Runner.run(agent, "List all available ticketing connectors")
print(result.final_output)
# Run the async main function
if __name__ == "__main__":
asyncio.run(main())
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. |
Advanced Configuration
Connection Options
async with MCPServerStreamableHttp(
name="Unizo MCP Server",
params={
"url": "https://api.unizo.ai/mcp",
"headers": {
"servicekey": os.getenv('UNIZO_SERVICE_KEY'),
"x-mcp-scopes": "TICKETING,PLATFORM"
},
"timeout": 30, # Request timeout in seconds
},
cache_tools_list=True, # Cache available tools for performance
max_retry_attempts=3, # Retry failed requests
) as server:
# Your agent code here