Environment:Openai Openai agents python MCP Dependencies
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, MCP |
| Last Updated | 2026-02-11 14:00 GMT |
Overview
Model Context Protocol (MCP) server integration requiring the `mcp` package, available only on Python 3.10+.
Description
MCP support enables agents to connect to external tool servers via the Model Context Protocol. The SDK provides `MCPServerStdio`, `MCPServerSse`, and `MCPServerStreamableHttp` transport implementations. The `mcp` package is a core dependency but is gated behind a Python 3.10+ version check in pyproject.toml. On Python 3.9, all MCP imports silently fail.
Usage
Use this environment when agents need to connect to MCP tool servers using `MCPServerStdio`, `MCPServerSse`, or `MCPServerStreamableHttp`. Also required for the `HostedMCPTool` hosted tool type.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| Python | >= 3.10 | MCP package requires Python 3.10+ |
| Network | Depends on transport | SSE and StreamableHTTP need network access |
Dependencies
Python Packages
- `mcp` >= 1.19.0, < 2 (auto-installed on Python 3.10+)
- `exceptiongroup` (backport, auto-installed on Python 3.10; native in 3.11+)
Credentials
No additional credentials beyond the core `OPENAI_API_KEY`.
Quick Install
# MCP is included in the base install on Python 3.10+
pip install openai-agents
# Verify MCP is available
python -c "from agents.mcp import MCPServerStdio; print('MCP OK')"
Code Evidence
Version gate in `pyproject.toml:16`:
"mcp>=1.19.0, <2; python_version >= '3.10'",
Silent failure on Python 3.9 from `mcp/__init__.py:1-13`:
try:
from .manager import MCPServerManager
from .server import (
MCPServer,
MCPServerSse,
MCPServerSseParams,
MCPServerStdio,
MCPServerStdioParams,
MCPServerStreamableHttp,
MCPServerStreamableHttpParams,
)
except ImportError:
pass
ExceptionGroup backport for Python < 3.11 from `mcp/server.py:15-16`:
if sys.version_info < (3, 11):
from exceptiongroup import BaseExceptionGroup
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ImportError: cannot import name 'MCPServerStdio'` | Python 3.9 (MCP unavailable) | Upgrade to Python 3.10+ |
| `RuntimeError: Failed to connect MCP server '{name}'` | MCP server connection failure | Check server is running and accessible |
| `Error during cleanup of MCP server '{name}'` | Cleanup failure on server disconnect | Usually non-fatal; check server logs |
Compatibility Notes
- Python 3.9: MCP features are completely unavailable. MCP imports silently return nothing.
- Python 3.10: Full MCP support; `exceptiongroup` backport package is used.
- Python 3.11+: Full MCP support with native `ExceptionGroup`.