From 4c3de2df650dbbe60fcb7f35195b642fb13cbef1 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 11 May 2026 11:34:56 +0900 Subject: [PATCH] docs: update MCP examples (#3342) --- docs/ja/mcp.md | 18 +++++++++++------- docs/ko/mcp.md | 18 +++++++++++------- docs/mcp.md | 16 ++++++++++------ docs/zh/mcp.md | 18 +++++++++++------- examples/hosted_mcp/simple.py | 10 +++++----- examples/mcp/sse_remote_example/README.md | 5 +++-- .../streamable_http_remote_example/README.md | 6 +++--- 7 files changed, 54 insertions(+), 37 deletions(-) diff --git a/docs/ja/mcp.md b/docs/ja/mcp.md index 525baa2e..b077db8f 100644 --- a/docs/ja/mcp.md +++ b/docs/ja/mcp.md @@ -83,19 +83,23 @@ from agents import Agent, HostedMCPTool, Runner async def main() -> None: agent = Agent( name="Assistant", + instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.", tools=[ HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never", } ) ], ) - result = await Runner.run(agent, "Which language is this repository written in?") + result = await Runner.run( + agent, + "Which language is the repository openai/openai-agents-python written in?", + ) print(result.final_output) asyncio.run(main()) @@ -124,7 +128,7 @@ print(result.final_output) ```python from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest -SAFE_TOOLS = {"read_project_metadata"} +SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"} def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult: if request.data.name in SAFE_TOOLS: @@ -137,8 +141,8 @@ agent = Agent( HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "always", }, on_approval_request=approve_tool, @@ -459,4 +463,4 @@ agent = Agent( - [Model Context Protocol](https://modelcontextprotocol.io/) – 仕様と設計ガイド。 - [examples/mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp) – 実行可能な stdio、SSE、Streamable HTTP サンプル。 -- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 承認とコネクターを含む完全なホスト型 MCP デモ。 \ No newline at end of file +- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 承認とコネクターを含む完全なホスト型 MCP デモ。 diff --git a/docs/ko/mcp.md b/docs/ko/mcp.md index 46e414f3..4015b896 100644 --- a/docs/ko/mcp.md +++ b/docs/ko/mcp.md @@ -85,19 +85,23 @@ from agents import Agent, HostedMCPTool, Runner async def main() -> None: agent = Agent( name="Assistant", + instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.", tools=[ HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never", } ) ], ) - result = await Runner.run(agent, "Which language is this repository written in?") + result = await Runner.run( + agent, + "Which language is the repository openai/openai-agents-python written in?", + ) print(result.final_output) asyncio.run(main()) @@ -126,7 +130,7 @@ print(result.final_output) ```python from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest -SAFE_TOOLS = {"read_project_metadata"} +SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"} def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult: if request.data.name in SAFE_TOOLS: @@ -139,8 +143,8 @@ agent = Agent( HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "always", }, on_approval_request=approve_tool, @@ -464,4 +468,4 @@ agent = Agent( - [Model Context Protocol](https://modelcontextprotocol.io/) – 사양 및 설계 가이드 - [examples/mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp) – 실행 가능한 stdio, SSE, Streamable HTTP 샘플 -- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 승인과 커넥터를 포함한 완전한 호스티드 MCP 데모 \ No newline at end of file +- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 승인과 커넥터를 포함한 완전한 호스티드 MCP 데모 diff --git a/docs/mcp.md b/docs/mcp.md index cd6f538e..4990585d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -85,19 +85,23 @@ from agents import Agent, HostedMCPTool, Runner async def main() -> None: agent = Agent( name="Assistant", + instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.", tools=[ HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never", } ) ], ) - result = await Runner.run(agent, "Which language is this repository written in?") + result = await Runner.run( + agent, + "Which language is the repository openai/openai-agents-python written in?", + ) print(result.final_output) asyncio.run(main()) @@ -129,7 +133,7 @@ policies. To make the decision inside Python, provide an `on_approval_request` c ```python from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest -SAFE_TOOLS = {"read_project_metadata"} +SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"} def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult: if request.data.name in SAFE_TOOLS: @@ -142,8 +146,8 @@ agent = Agent( HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "always", }, on_approval_request=approve_tool, diff --git a/docs/zh/mcp.md b/docs/zh/mcp.md index 2c14d3f5..6380976f 100644 --- a/docs/zh/mcp.md +++ b/docs/zh/mcp.md @@ -84,19 +84,23 @@ from agents import Agent, HostedMCPTool, Runner async def main() -> None: agent = Agent( name="Assistant", + instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.", tools=[ HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never", } ) ], ) - result = await Runner.run(agent, "Which language is this repository written in?") + result = await Runner.run( + agent, + "Which language is the repository openai/openai-agents-python written in?", + ) print(result.final_output) asyncio.run(main()) @@ -126,7 +130,7 @@ print(result.final_output) ```python from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest -SAFE_TOOLS = {"read_project_metadata"} +SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"} def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult: if request.data.name in SAFE_TOOLS: @@ -139,8 +143,8 @@ agent = Agent( HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "always", }, on_approval_request=approve_tool, @@ -466,4 +470,4 @@ agent = Agent( - [Model Context Protocol](https://modelcontextprotocol.io/) – 规范和设计指南。 - [examples/mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp) – 可运行的 stdio、SSE 和 Streamable HTTP 示例。 -- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 完整的托管 MCP 演示,包括审批和连接器。 \ No newline at end of file +- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 完整的托管 MCP 演示,包括审批和连接器。 diff --git a/examples/hosted_mcp/simple.py b/examples/hosted_mcp/simple.py index 26c49448..4401079f 100644 --- a/examples/hosted_mcp/simple.py +++ b/examples/hosted_mcp/simple.py @@ -11,14 +11,14 @@ async def main(verbose: bool, stream: bool, repo: str): question = f"Which language is the repository {repo} written in?" agent = Agent( name="Assistant", - instructions=f"You can use the hosted MCP server to inspect {repo}.", + instructions=f"You can use the DeepWiki hosted MCP server to inspect {repo}.", model_settings=ModelSettings(tool_choice="required"), tools=[ HostedMCPTool( tool_config={ "type": "mcp", - "server_label": "gitmcp", - "server_url": "https://gitmcp.io/openai/codex", + "server_label": "deepwiki", + "server_url": "https://mcp.deepwiki.com/mcp", "require_approval": "never", } ) @@ -35,7 +35,7 @@ async def main(verbose: bool, stream: bool, repo: str): else: run_result = await Runner.run(agent, question) print(run_result.final_output) - # The repository is primarily written in multiple languages, including Rust and TypeScript... + # The repository is primarily written in Python... if verbose: for item in run_result.new_items: @@ -49,7 +49,7 @@ if __name__ == "__main__": parser.add_argument( "--repo", default="https://github.com/openai/openai-agents-python", - help="Repository URL or slug that the Git MCP server should use.", + help="Repository URL or slug that the DeepWiki MCP server should use.", ) args = parser.parse_args() diff --git a/examples/mcp/sse_remote_example/README.md b/examples/mcp/sse_remote_example/README.md index 58e48356..fc03da76 100644 --- a/examples/mcp/sse_remote_example/README.md +++ b/examples/mcp/sse_remote_example/README.md @@ -1,7 +1,8 @@ # MCP SSE Remote Example -Python port of the JS `examples/mcp/sse-example.ts`. It connects to a remote MCP -server over SSE (`https://gitmcp.io/openai/codex`) and lets the agent use those tools. +Python port of the JS `examples/mcp/sse-example.ts`. By default it starts the +bundled local SSE MCP server and lets the agent use those tools. Set +`MCP_SSE_REMOTE_URL` to try a compatible remote SSE server instead. Run it with: diff --git a/examples/mcp/streamable_http_remote_example/README.md b/examples/mcp/streamable_http_remote_example/README.md index e7d52e74..174e7fac 100644 --- a/examples/mcp/streamable_http_remote_example/README.md +++ b/examples/mcp/streamable_http_remote_example/README.md @@ -1,8 +1,8 @@ # MCP Streamable HTTP Remote Example -Python port of the JS `examples/mcp/streamable-http-example.ts`. It connects to a -remote MCP server over the Streamable HTTP transport (`https://gitmcp.io/openai/codex`) -and lets the agent use those tools. +Python port of the JS `examples/mcp/streamable-http-example.ts`. It connects to +DeepWiki over the Streamable HTTP transport (`https://mcp.deepwiki.com/mcp`) and +lets the agent use those tools. Run it with: