You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: openai_agents/mcp/README.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,23 @@ Integration with hosted MCP (Model Context Protocol) servers using OpenAI agents
6
6
7
7
Before running these examples, be sure to review the [prerequisites and background on the integration](../README.md).
8
8
9
+
## MCP Server Dependencies
10
+
11
+
All examples use self-contained MCP servers in the `servers/` directory. The servers require these dependencies:
12
+
13
+
```bash
14
+
pip install mcp requests
15
+
# or
16
+
uv add mcp requests
17
+
```
18
+
19
+
## Server Implementations
20
+
21
+
The `servers/` directory contains self-contained MCP server implementations:
22
+
23
+
-**`tools_server.py`** - Multi-transport MCP server with tools for arithmetic, weather, and random words. Supports both `--transport=streamable-http` and `--transport=sse`
24
+
-**`prompt_server.py`** - MCP server that provides prompts for generating agent instructions (code review example)
25
+
9
26
## Running the Examples
10
27
11
28
### File System MCP - Stateless
@@ -32,4 +49,55 @@ uv run openai_agents/mcp/run_file_system_stateful_worker.py
32
49
Connect to a hosted MCP server for file system operations:
33
50
```bash
34
51
uv run openai_agents/mcp/run_file_system_stateful_workflow.py
52
+
```
53
+
54
+
### Streamable HTTP MCP - Stateless
55
+
56
+
First, start the MCP server:
57
+
```bash
58
+
uv run openai_agents/mcp/servers/tools_server.py --transport=streamable-http
59
+
```
60
+
61
+
Then start the worker:
62
+
```bash
63
+
uv run openai_agents/mcp/run_streamable_http_stateless_worker.py
64
+
```
65
+
66
+
Finally, run the workflow:
67
+
```bash
68
+
uv run openai_agents/mcp/run_streamable_http_stateless_workflow.py
69
+
```
70
+
71
+
### SSE MCP - Stateless
72
+
73
+
First, start the MCP server:
74
+
```bash
75
+
uv run openai_agents/mcp/servers/tools_server.py --transport=sse
76
+
```
77
+
78
+
Then start the worker:
79
+
```bash
80
+
uv run openai_agents/mcp/run_sse_stateless_worker.py
81
+
```
82
+
83
+
Finally, run the workflow:
84
+
```bash
85
+
uv run openai_agents/mcp/run_sse_stateless_workflow.py
86
+
```
87
+
88
+
### Prompt Server MCP - Stateless
89
+
90
+
First, start the MCP server:
91
+
```bash
92
+
uv run openai_agents/mcp/servers/prompt_server.py
93
+
```
94
+
95
+
Then start the worker:
96
+
```bash
97
+
uv run openai_agents/mcp/run_prompt_server_stateless_worker.py
98
+
```
99
+
100
+
Finally, run the workflow:
101
+
```bash
102
+
uv run openai_agents/mcp/run_prompt_server_stateless_workflow.py
0 commit comments