The OpenAI Agents SDK is a Python SDK for building agent-based AI applications.
It focuses on connecting tools to an LLM, organizing context, and handling user requests in a structured way.
With the recent integration of Model Context Protocol (MCP), agents can connect to external servers to obtain context and tool information.
This article introduces the SDK's structure and concepts, then covers MCP integration and practical code examples.
An agent is an intelligent execution unit that receives instructions, uses tools to achieve a goal, and continues a conversation.
The OpenAI Agents SDK provides a high-level API for implementing this in code.
Its main capabilities include:
Interpreting user instructions and establishing a goal.
Connecting to tools such as search, calculators, and external APIs.
Planning execution and invoking tools.
Organizing results and returning them to the user.
Context management is central to this process, and the recently introduced MCP enables it in a more structured way.
MCP, or Model Context Protocol, structures context into layers such as system, user, and files.
The Agents SDK is designed to load tools through communication with MCP servers and produce responses appropriate to that context.
The official example uses the @modelcontextprotocol/server-filesystem MCP server to interact with the file system.
Tools such as opening and listing files are registered automatically.
from agents import Agentagent = Agent( name="FileAssistant", instructions="파일 시스템 도구를 사용해 작업을 도와주세요.", mcp_servers=[mcp_server])
You can now run it.
from agents import Runnerasync def main(): result = await Runner.run(agent, "현재 디렉토리의 모든 파일을 보여줘") print(result.final_output)
Internally, the agent loads the tool list through the MCP server's list_tools() and uses appropriate tools to return results based on the user's instructions.
The Agents SDK can connect to MCP servers in two ways.
MCPServerStdio
: Connects to an MCP server running locally.
MCPServerSse
: Connects to an HTTP-based remote MCP server using Server-Sent Events.
The Stdio approach is convenient for local development, while Sse is useful for remote deployments.
The OpenAI Agents SDK is a powerful tool for implementing AI agents in code.
Combining it with MCP improves connectivity to external systems, context extensibility, and tool reuse.
Developers can implement their own MCP servers or use existing ones to build flexible, extensible agents.