Skip to content

Commit 4c3de2d

Browse files
authored
docs: update MCP examples (#3342)
1 parent cf151f9 commit 4c3de2d

7 files changed

Lines changed: 54 additions & 37 deletions

File tree

docs/ja/mcp.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,23 @@ from agents import Agent, HostedMCPTool, Runner
8383
async def main() -> None:
8484
agent = Agent(
8585
name="Assistant",
86+
instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.",
8687
tools=[
8788
HostedMCPTool(
8889
tool_config={
8990
"type": "mcp",
90-
"server_label": "gitmcp",
91-
"server_url": "https://gitmcp.io/openai/codex",
91+
"server_label": "deepwiki",
92+
"server_url": "https://mcp.deepwiki.com/mcp",
9293
"require_approval": "never",
9394
}
9495
)
9596
],
9697
)
9798

98-
result = await Runner.run(agent, "Which language is this repository written in?")
99+
result = await Runner.run(
100+
agent,
101+
"Which language is the repository openai/openai-agents-python written in?",
102+
)
99103
print(result.final_output)
100104

101105
asyncio.run(main())
@@ -124,7 +128,7 @@ print(result.final_output)
124128
```python
125129
from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest
126130

127-
SAFE_TOOLS = {"read_project_metadata"}
131+
SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"}
128132

129133
def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult:
130134
if request.data.name in SAFE_TOOLS:
@@ -137,8 +141,8 @@ agent = Agent(
137141
HostedMCPTool(
138142
tool_config={
139143
"type": "mcp",
140-
"server_label": "gitmcp",
141-
"server_url": "https://gitmcp.io/openai/codex",
144+
"server_label": "deepwiki",
145+
"server_url": "https://mcp.deepwiki.com/mcp",
142146
"require_approval": "always",
143147
},
144148
on_approval_request=approve_tool,
@@ -459,4 +463,4 @@ agent = Agent(
459463

460464
- [Model Context Protocol](https://modelcontextprotocol.io/) – 仕様と設計ガイド。
461465
- [examples/mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp) – 実行可能な stdio、SSE、Streamable HTTP サンプル。
462-
- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 承認とコネクターを含む完全なホスト型 MCP デモ。
466+
- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 承認とコネクターを含む完全なホスト型 MCP デモ。

docs/ko/mcp.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,23 @@ from agents import Agent, HostedMCPTool, Runner
8585
async def main() -> None:
8686
agent = Agent(
8787
name="Assistant",
88+
instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.",
8889
tools=[
8990
HostedMCPTool(
9091
tool_config={
9192
"type": "mcp",
92-
"server_label": "gitmcp",
93-
"server_url": "https://gitmcp.io/openai/codex",
93+
"server_label": "deepwiki",
94+
"server_url": "https://mcp.deepwiki.com/mcp",
9495
"require_approval": "never",
9596
}
9697
)
9798
],
9899
)
99100

100-
result = await Runner.run(agent, "Which language is this repository written in?")
101+
result = await Runner.run(
102+
agent,
103+
"Which language is the repository openai/openai-agents-python written in?",
104+
)
101105
print(result.final_output)
102106

103107
asyncio.run(main())
@@ -126,7 +130,7 @@ print(result.final_output)
126130
```python
127131
from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest
128132

129-
SAFE_TOOLS = {"read_project_metadata"}
133+
SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"}
130134

131135
def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult:
132136
if request.data.name in SAFE_TOOLS:
@@ -139,8 +143,8 @@ agent = Agent(
139143
HostedMCPTool(
140144
tool_config={
141145
"type": "mcp",
142-
"server_label": "gitmcp",
143-
"server_url": "https://gitmcp.io/openai/codex",
146+
"server_label": "deepwiki",
147+
"server_url": "https://mcp.deepwiki.com/mcp",
144148
"require_approval": "always",
145149
},
146150
on_approval_request=approve_tool,
@@ -464,4 +468,4 @@ agent = Agent(
464468

465469
- [Model Context Protocol](https://modelcontextprotocol.io/) – 사양 및 설계 가이드
466470
- [examples/mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp) – 실행 가능한 stdio, SSE, Streamable HTTP 샘플
467-
- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 승인과 커넥터를 포함한 완전한 호스티드 MCP 데모
471+
- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 승인과 커넥터를 포함한 완전한 호스티드 MCP 데모

docs/mcp.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,23 @@ from agents import Agent, HostedMCPTool, Runner
8585
async def main() -> None:
8686
agent = Agent(
8787
name="Assistant",
88+
instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.",
8889
tools=[
8990
HostedMCPTool(
9091
tool_config={
9192
"type": "mcp",
92-
"server_label": "gitmcp",
93-
"server_url": "https://gitmcp.io/openai/codex",
93+
"server_label": "deepwiki",
94+
"server_url": "https://mcp.deepwiki.com/mcp",
9495
"require_approval": "never",
9596
}
9697
)
9798
],
9899
)
99100

100-
result = await Runner.run(agent, "Which language is this repository written in?")
101+
result = await Runner.run(
102+
agent,
103+
"Which language is the repository openai/openai-agents-python written in?",
104+
)
101105
print(result.final_output)
102106

103107
asyncio.run(main())
@@ -129,7 +133,7 @@ policies. To make the decision inside Python, provide an `on_approval_request` c
129133
```python
130134
from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest
131135

132-
SAFE_TOOLS = {"read_project_metadata"}
136+
SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"}
133137

134138
def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult:
135139
if request.data.name in SAFE_TOOLS:
@@ -142,8 +146,8 @@ agent = Agent(
142146
HostedMCPTool(
143147
tool_config={
144148
"type": "mcp",
145-
"server_label": "gitmcp",
146-
"server_url": "https://gitmcp.io/openai/codex",
149+
"server_label": "deepwiki",
150+
"server_url": "https://mcp.deepwiki.com/mcp",
147151
"require_approval": "always",
148152
},
149153
on_approval_request=approve_tool,

docs/zh/mcp.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,23 @@ from agents import Agent, HostedMCPTool, Runner
8484
async def main() -> None:
8585
agent = Agent(
8686
name="Assistant",
87+
instructions="Use the DeepWiki hosted MCP server to inspect openai/openai-agents-python.",
8788
tools=[
8889
HostedMCPTool(
8990
tool_config={
9091
"type": "mcp",
91-
"server_label": "gitmcp",
92-
"server_url": "https://gitmcp.io/openai/codex",
92+
"server_label": "deepwiki",
93+
"server_url": "https://mcp.deepwiki.com/mcp",
9394
"require_approval": "never",
9495
}
9596
)
9697
],
9798
)
9899

99-
result = await Runner.run(agent, "Which language is this repository written in?")
100+
result = await Runner.run(
101+
agent,
102+
"Which language is the repository openai/openai-agents-python written in?",
103+
)
100104
print(result.final_output)
101105

102106
asyncio.run(main())
@@ -126,7 +130,7 @@ print(result.final_output)
126130
```python
127131
from agents import MCPToolApprovalFunctionResult, MCPToolApprovalRequest
128132

129-
SAFE_TOOLS = {"read_project_metadata"}
133+
SAFE_TOOLS = {"read_wiki_structure", "read_wiki_contents", "ask_question"}
130134

131135
def approve_tool(request: MCPToolApprovalRequest) -> MCPToolApprovalFunctionResult:
132136
if request.data.name in SAFE_TOOLS:
@@ -139,8 +143,8 @@ agent = Agent(
139143
HostedMCPTool(
140144
tool_config={
141145
"type": "mcp",
142-
"server_label": "gitmcp",
143-
"server_url": "https://gitmcp.io/openai/codex",
146+
"server_label": "deepwiki",
147+
"server_url": "https://mcp.deepwiki.com/mcp",
144148
"require_approval": "always",
145149
},
146150
on_approval_request=approve_tool,
@@ -466,4 +470,4 @@ agent = Agent(
466470

467471
- [Model Context Protocol](https://modelcontextprotocol.io/) – 规范和设计指南。
468472
- [examples/mcp](https://github.com/openai/openai-agents-python/tree/main/examples/mcp) – 可运行的 stdio、SSE 和 Streamable HTTP 示例。
469-
- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 完整的托管 MCP 演示,包括审批和连接器。
473+
- [examples/hosted_mcp](https://github.com/openai/openai-agents-python/tree/main/examples/hosted_mcp) – 完整的托管 MCP 演示,包括审批和连接器。

examples/hosted_mcp/simple.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ async def main(verbose: bool, stream: bool, repo: str):
1111
question = f"Which language is the repository {repo} written in?"
1212
agent = Agent(
1313
name="Assistant",
14-
instructions=f"You can use the hosted MCP server to inspect {repo}.",
14+
instructions=f"You can use the DeepWiki hosted MCP server to inspect {repo}.",
1515
model_settings=ModelSettings(tool_choice="required"),
1616
tools=[
1717
HostedMCPTool(
1818
tool_config={
1919
"type": "mcp",
20-
"server_label": "gitmcp",
21-
"server_url": "https://gitmcp.io/openai/codex",
20+
"server_label": "deepwiki",
21+
"server_url": "https://mcp.deepwiki.com/mcp",
2222
"require_approval": "never",
2323
}
2424
)
@@ -35,7 +35,7 @@ async def main(verbose: bool, stream: bool, repo: str):
3535
else:
3636
run_result = await Runner.run(agent, question)
3737
print(run_result.final_output)
38-
# The repository is primarily written in multiple languages, including Rust and TypeScript...
38+
# The repository is primarily written in Python...
3939

4040
if verbose:
4141
for item in run_result.new_items:
@@ -49,7 +49,7 @@ async def main(verbose: bool, stream: bool, repo: str):
4949
parser.add_argument(
5050
"--repo",
5151
default="https://github.com/openai/openai-agents-python",
52-
help="Repository URL or slug that the Git MCP server should use.",
52+
help="Repository URL or slug that the DeepWiki MCP server should use.",
5353
)
5454
args = parser.parse_args()
5555

examples/mcp/sse_remote_example/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# MCP SSE Remote Example
22

3-
Python port of the JS `examples/mcp/sse-example.ts`. It connects to a remote MCP
4-
server over SSE (`https://gitmcp.io/openai/codex`) and lets the agent use those tools.
3+
Python port of the JS `examples/mcp/sse-example.ts`. By default it starts the
4+
bundled local SSE MCP server and lets the agent use those tools. Set
5+
`MCP_SSE_REMOTE_URL` to try a compatible remote SSE server instead.
56

67
Run it with:
78

examples/mcp/streamable_http_remote_example/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# MCP Streamable HTTP Remote Example
22

3-
Python port of the JS `examples/mcp/streamable-http-example.ts`. It connects to a
4-
remote MCP server over the Streamable HTTP transport (`https://gitmcp.io/openai/codex`)
5-
and lets the agent use those tools.
3+
Python port of the JS `examples/mcp/streamable-http-example.ts`. It connects to
4+
DeepWiki over the Streamable HTTP transport (`https://mcp.deepwiki.com/mcp`) and
5+
lets the agent use those tools.
66

77
Run it with:
88

0 commit comments

Comments
 (0)