|
| 1 | +# MCP Examples |
| 2 | + |
| 3 | +Integration with MCP (Model Context Protocol) servers using OpenAI agents in Temporal workflows. |
| 4 | + |
| 5 | +*Adapted from [OpenAI Agents SDK MCP examples](https://github.com/openai/openai-agents-python/tree/main/examples/mcp)* |
| 6 | + |
| 7 | +Before running these examples, be sure to review the [prerequisites and background on the integration](../README.md). |
| 8 | + |
| 9 | + |
| 10 | +## Running the Examples |
| 11 | + |
| 12 | +### Stdio MCP |
| 13 | + |
| 14 | +First, start the worker: |
| 15 | +```bash |
| 16 | +uv run openai_agents/mcp/run_file_system_worker.py |
| 17 | +``` |
| 18 | + |
| 19 | +Run the workflow: |
| 20 | +```bash |
| 21 | +uv run openai_agents/mcp/run_file_system_workflow.py |
| 22 | +``` |
| 23 | + |
| 24 | +This sample assumes that the worker and `run_file_system_workflow.py` are on the same machine. |
| 25 | + |
| 26 | + |
| 27 | +### Streamable HTTP MCP |
| 28 | + |
| 29 | +First, start the worker: |
| 30 | +```bash |
| 31 | +uv run openai_agents/mcp/servers/tools_server.py --transport=streamable-http |
| 32 | +``` |
| 33 | + |
| 34 | +Then start the worker: |
| 35 | +```bash |
| 36 | +uv run openai_agents/mcp/run_streamable_http_worker.py |
| 37 | +``` |
| 38 | + |
| 39 | +Finally, run the workflow: |
| 40 | +```bash |
| 41 | +uv run openai_agents/mcp/run_streamable_http_workflow.py |
| 42 | +``` |
| 43 | + |
| 44 | +### SSE MCP |
| 45 | + |
| 46 | +First, start the MCP server: |
| 47 | +```bash |
| 48 | +uv run openai_agents/mcp/servers/tools_server.py --transport=sse |
| 49 | +``` |
| 50 | + |
| 51 | +Then start the worker: |
| 52 | +```bash |
| 53 | +uv run openai_agents/mcp/run_sse_worker.py |
| 54 | +``` |
| 55 | + |
| 56 | +Finally, run the workflow: |
| 57 | +```bash |
| 58 | +uv run openai_agents/mcp/run_sse_workflow.py |
| 59 | +``` |
| 60 | + |
| 61 | +### Prompt Server MCP |
| 62 | + |
| 63 | +First, start the MCP server: |
| 64 | +```bash |
| 65 | +uv run openai_agents/mcp/servers/prompt_server.py |
| 66 | +``` |
| 67 | + |
| 68 | +Then start the worker: |
| 69 | +```bash |
| 70 | +uv run openai_agents/mcp/run_prompt_server_worker.py |
| 71 | +``` |
| 72 | + |
| 73 | +Finally, run the workflow: |
| 74 | +```bash |
| 75 | +uv run openai_agents/mcp/run_prompt_server_workflow.py |
| 76 | +``` |
| 77 | + |
| 78 | + |
| 79 | +### Memory MCP (Research Scratchpad) |
| 80 | + |
| 81 | +Demonstrates durable note-taking with the Memory MCP server: write seed notes, query by tags, synthesize a brief with citations, then update and delete notes. |
| 82 | + |
| 83 | +Start the worker: |
| 84 | +```bash |
| 85 | +uv run openai_agents/mcp/run_memory_research_scratchpad_worker.py |
| 86 | +``` |
| 87 | + |
| 88 | +Run the research scratchpad workflow: |
| 89 | +```bash |
| 90 | +uv run openai_agents/mcp/run_memory_research_scratchpad_workflow.py |
| 91 | +``` |
0 commit comments