OpenAI Agents SDK Integration#

Integrate FirstOps with the OpenAI Agents SDK to govern your OpenAI-powered agents.

Overview#

The OpenAI Agents SDK supports MCP tool connections. FirstOps provides the security and governance layer — identity, policies, credential brokering, and audit — for every tool call your agent makes.

Setup#

1. Create an agent principal#

Create an autonomous agent principal in the FirstOps dashboard. You receive an agent ID and a DPoP private key PEM file.

2. Register connections#

fo connection add --name notion --url https://mcp.notion.com/mcp --auth bearer --token ntn_secret_... --agent <agent-name>

Note the connection ID returned — you need it in your agent code.

3. Install dependencies#

pip install openai-agents firstops

4. Configure and run the agent#

import asyncio
import os
import firstops
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

PROXY_PORT = 9322
NOTION_CONN_ID = "<notion-conn-id>"
GATEWAY_URL = os.environ.get("FIRSTOPS_GATEWAY_URL", "https://api.firstops.dev")

# Start the FirstOps proxy — handles DPoP authentication per request
firstops.init(
    agent_id="<uuid>",
    private_key_pem=open("key.pem").read(),
    port=PROXY_PORT,
    gateway_url=GATEWAY_URL,
)


async def run():
    async with MCPServerStreamableHttp(
        name="Notion MCP",
        params={
            "url": f"http://127.0.0.1:{PROXY_PORT}/mcp/proxy/{NOTION_CONN_ID}",
        },
    ) as server:
        agent = Agent(
            name="my_research_agent",
            instructions="You are a helpful assistant with access to Notion.",
            mcp_servers=[server],
            model="gpt-4o",
        )

        result = await Runner.run(
            agent, "Find the latest design doc in Notion",
        )
        print(result.final_output)


asyncio.run(run())

# Clean up on shutdown
firstops.shutdown()

5. Assign policies#

Ensure the agent's access group has appropriate policies. The SDK handles all DPoP authentication automatically.

Multi-agent workflows#

For OpenAI's multi-agent handoff patterns, each agent can have its own FirstOps principal. Run each agent as a separate process with its own proxy:

Agent 1 — Researcher (process 1, port 9322):

firstops.init(agent_id="<research-uuid>", private_key_pem=research_key, port=9322)

async with MCPServerStreamableHttp(
    name="Notion MCP",
    params={"url": "http://127.0.0.1:9322/mcp/proxy/<notion-conn-id>"},
) as server:
    researcher = Agent(
        name="researcher",
        instructions="You help with research tasks.",
        mcp_servers=[server],
    )

Agent 2 — Writer (process 2, port 9323):

firstops.init(agent_id="<writer-uuid>", private_key_pem=writer_key, port=9323)

async with MCPServerStreamableHttp(
    name="GitHub MCP",
    params={"url": "http://127.0.0.1:9323/mcp/proxy/<github-conn-id>"},
) as server:
    writer = Agent(
        name="writer",
        instructions="You write and commit code.",
        mcp_servers=[server],
    )

Each agent has independent:

  • Identity and permissions
  • Audit trail
  • Policy enforcement