The OpenAI Agents SDK treats MCP as a first-class tool source, so an agent can discover and call a server's tools without you writing a single wrapper. Whether the server runs as a local subprocess or a hosted endpoint, the SDK reads its tool list, input schemas and docs, and puts them in front of the model. Here's how to wire it up — and how to keep a human on the risky calls.
Three ways to connect
Pick the transport that matches where your server runs. MCPServerStdio launches a local subprocess — ideal for development. MCPServerSse, or Streamable HTTP, reaches a remote server over the network. HostedMCPTool hands listing and execution to OpenAI's Responses API when the server is publicly reachable.
pip install openai-agents
from agents import Agent
from agents.mcp import MCPServerStdio
server = MCPServerStdio(params={"command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"]})
agent = Agent(name="Dev", mcp_servers=[server])
Connect many servers safely
When an agent needs several servers, connectMcpServers starts them together, tracks failures and closes them in one place, returning an object with active, failed and error collections so you pass only healthy servers to the agent. That saves you from a single dead server quietly taking down the whole run.
Add tool approvals
For anything that writes, gate it. The SDK's approval hooks pause before a named tool executes and wait for a yes/no — the same pattern you want before an agent posts, deletes or spends money. Treat every write tool as needing a human until you've watched it behave; reading is cheap to trust, writing is not.
Which servers to start with
A support agent pairs well with Slack and a knowledge base; a coding agent with GitHub and filesystem. All of them attach the same way, and all are curated, categorised and vetted in the directory.
Going further
Building for ChatGPT too? See use an MCP server in ChatGPT Developer Mode and MCP Apps vs the OpenAI Apps SDK. Lock down remote servers with the OAuth 2.1 guide and security best practices.