Openai-agents-mcp

Latest version: v0.0.8

Safety actively analyzes 722460 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.0.8

* Update [mcp-agent](https://github.com/lastmile-ai/mcp-agent) dependency to 0.0.13, which includes various fixes for Windows OS.

0.0.7

* Add cleaner typings for mcp-agent types used in `RunnerContext`

0.0.6

Added tests (95% test coverage), and much better typechecking.

0.0.5

Convert from openai-agents fork to an extension.
Resolves feedback from https://github.com/openai/openai-agents-python/issues/23 and https://github.com/openai/openai-agents-python/pull/40

Installation

bash
uv add openai-agents-mcp


bash
pip install openai-agents-mcp


Quick Start

> [!TIP]
> The [`examples`](/examples) directory has several example applications to get started with.
> To run an example, clone this repo, then:
>
> bash
> cd examples
> cp mcp_agent.secrets.yaml.example mcp_agent.secrets.yaml Update API keys if needed
> uv run hello_world_mcp.py Or any other example
>


In order to use Agents SDK with MCP, simply replace the following import:

diff
- from agents import Agent
+ from agents_mcp import Agent


With that you can instantiate an Agent with `mcp_servers` in addition to `tools` (which continue to work like before).

python
from agents_mcp import Agent

Create an agent with specific MCP servers you want to use
These must be defined in your mcp_agent.config.yaml file
agent = Agent(
name="MCP Agent",
instructions="""You are a helpful assistant with access to both local/OpenAI tools and tools from MCP servers. Use these tools to help the user.""",
Local/OpenAI tools
tools=[get_current_weather],
Specify which MCP servers to use
These must be defined in your mcp_agent config
mcp_servers=["fetch", "filesystem"],
)


Then define an `mcp_agent.config.yaml`, with the MCP server configuration:

yaml
mcp:
servers:
fetch:
command: npx
args: ["-y", "modelcontextprotocol/server-fetch"]
filesystem:
command: npx
args: ["-y", "modelcontextprotocol/server-filesystem", "."]


**That's it**! The rest of the Agents SDK works exactly as before.

Head over to the [examples](./examples) directory to see MCP servers in action with Agents SDK.

Demo

https://github.com/user-attachments/assets/1d2a843d-2f99-41f2-8671-4c7940ec48f5

More details and nuances below.

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.