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
- Install the Agents SDK.
- Construct a streamable-HTTP MCP server pointing at the endpoint, with your key as a header.
- 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
- Get a key at console.unzoi.com, if you have not.
- The tool reference — what the model is reading when it chooses between the six tools.
- Stories for context windows — the one habit that most changes how well an agent works against this API.
- Limits — an agent that loops can spend a monthly quota faster than you expect.
- OpenAI Agents SDK's own MCP documentation — authoritative for anything about the client itself, including config paths, which move.
Endpoint, for copying: https://api.unzoi.com/mcp