OpenAI Agents SDK
Integrate BlueNexus MCP tools into the OpenAI Agents SDK.
Install
pip install openai-agents mcp
Setup
import asyncio
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHTTP
BLUENEXUS_TOKEN = "your-personal-access-token"
async def main():
# Create MCP server connection to BlueNexus
bluenexus = MCPServerStreamableHTTP(
url="https://api.bluenexus.ai/mcp",
headers={"Authorization": f"Bearer {BLUENEXUS_TOKEN}"}
)
# Create an agent with BlueNexus tools
agent = Agent(
name="Assistant",
instructions="You help users interact with their connected services via BlueNexus.",
mcp_servers=[bluenexus]
)
# Run the agent
result = await Runner.run(
agent,
"What's on my Google Calendar today?"
)
print(result.final_output)
asyncio.run(main())
With Streaming
async def main():
bluenexus = MCPServerStreamableHTTP(
url="https://api.bluenexus.ai/mcp",
headers={"Authorization": f"Bearer {BLUENEXUS_TOKEN}"}
)
agent = Agent(
name="Assistant",
instructions="Help users with their connected services.",
mcp_servers=[bluenexus]
)
result = Runner.run_streamed(
agent,
"Summarize my unread Slack messages and create a Notion page with the summary"
)
async for event in result.stream_events():
if event.type == "raw_response_event":
print(event.data, end="", flush=True)
Multi-Agent Setup
# Agent focused on reading data
reader = Agent(
name="DataReader",
instructions="You read and summarize data from connected services.",
mcp_servers=[bluenexus]
)
# Agent focused on taking actions
writer = Agent(
name="ActionTaker",
instructions="You create and update items in connected services.",
mcp_servers=[bluenexus]
)
# Orchestrator that delegates
orchestrator = Agent(
name="Orchestrator",
instructions="Delegate reading tasks to DataReader and writing tasks to ActionTaker.",
handoffs=[reader, writer]
)
result = await Runner.run(
orchestrator,
"Check my Jira tickets and post a summary to Slack #standup"
)
Next Steps
- Custom MCP — Raw MCP SDK usage
- MCP Endpoint Reference — Full specification