OpenAI Agents
Connect Unizo MCP to OpenAI Agents SDK 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:
UNIZO_SERVICE_KEY=your_service_key_from_displayId
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"
},
"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())
You can enable multiple scopes by separating them with commas:
"x-mcp-scopes": "platform,ticketing,vms,observability,infra"
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": "platform,ticketing"
},
"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
Multi-Turn Conversation
import os
import asyncio
from dotenv import load_dotenv
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
load_dotenv()
async def main():
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"
},
},
) as server:
agent = Agent(
name="unizo-assistant",
instructions="You are a helpful assistant with access to Unizo ticketing tools.",
mcp_servers=[server],
)
# First query
result = await Runner.run(agent, "List all Jira integrations")
print("First response:", result.final_output)
# Continue conversation with context
result = await Runner.run(
agent,
"Create a ticket in the first integration",
context=result.context
)
print("Second response:", result.final_output)
if __name__ == "__main__":
asyncio.run(main())
Example Use Cases
List Available Integrations
result = await Runner.run(agent, "List all available integrations")
Create a Jira Ticket
result = await Runner.run(
agent,
"Create a Jira ticket with title 'Bug: Login page not loading' and priority high"
)
Search Tickets
result = await Runner.run(
agent,
"Search for all open tickets assigned to me"
)