Skip to content
unzoi docs

OpenAI Agents SDK

Attach the endpoint to an Agent, in Python or TypeScript.

Kind Framework
Transport An MCP server object attached to the Agent.
Config

Setup

  1. Install the Agents SDK.
  2. Construct a streamable-HTTP MCP server pointing at the endpoint, with your key as a header.
  3. Pass it to the Agent in mcp_servers.
import os, asyncio
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="unzoi",
        params={
            "url": "https://api.unzoi.com/mcp",
            "headers": {"x-api-key": os.environ["UNZOI_KEY"]},
        },
        # The tool list never changes between calls, so caching it saves a
        # round trip on every turn.
        cache_tools_list=True,
    ) as unzoi:
        agent = Agent(
            name="news analyst",
            instructions="Use unzoi for anything about current events. Prefer list_stories when the question is about an event rather than about coverage.",
            mcp_servers=[unzoi],
        )
        result = await Runner.run(agent, "What is happening with lithium supply?")
        print(result.final_output)

asyncio.run(main())

What differs here

  • cache_tools_list is safe here: this server’s tool list is static, and the endpoint is stateless so there is no session that caching could outlive.
  • The SDK holds the server open for the life of the context manager. Construct it once per process rather than per request — not for connection reuse, since the transport is stateless, but to avoid re-listing tools on every turn.
  • If you also want the hosted-tool route, the endpoint works as a remote MCP server from the Responses API without the SDK managing the connection at all.

Next

Endpoint, for copying: https://api.unzoi.com/mcp