How MCP servers and tools work with Agents SDK
mainThe openai-agents-mcp extension allows you to connect OpenAI Agents to MCP servers. When you use the Agent class from agents_mcp, the agent automatically aggregates tools from the specified mcp_servers alongside any local tools you provide. This creates a single, unified list of tools that the agent can use seamlessly.
To use this extension, replace the standard import:
# Instead of:
# from agents import Agent
# Use:
from agents_mcp import Agentfrom agents_mcp import Agent
agent = Agent(
name="MCP Agent",
instructions="You are a helpful assistant.",
tools=[get_current_weather], # Local tools
mcp_servers=["fetch", "filesystem"], # MCP servers defined in config
)