What this thread does
Do first: Import from agents import Agent, HostedMCPTool, Runner.
When you need it
Hosted MCP places the tool round-trip in OpenAI infrastructure. The model lists and calls the remote tools without an extra callback to your Python process.
Steps
1. Import the SDK names:
from agents import Agent, HostedMCPTool, Runner
2. Add the hosted tool to the agent's tools list using the page's DeepWiki configuration:
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": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": "never",
})],
)
3. In the page's asynchronous main function, run the question and display the final output:
result = await Runner.run(
agent,
"Which language is the repository openai/openai-agents-python written in?",
)
print(result.final_output)
The example imports asyncio and calls asyncio.run(main()) to enter that asynchronous function.
Check it worked
Look at result.final_output, which the page prints after the run. The hosted server exposes tools automatically; it is not added to mcp_servers.
Limits
This requires an OpenAI model supporting the Responses API hosted MCP integration and a publicly reachable server. The example sets require_approval to never; the page also permits always and per-tool approval policies. Local MCP package requirements do not apply to HostedMCPTool. The page does not name a version for this hosted feature.
Not for: connecting remote MCP tools through Vercel AI SDK; see vercel-ai-sdk-connect-remote-mcp-tools.
Sources
- Model context protocol (MCP), OpenAI Agents SDK documentation, read 2026-11-24: "The hosted server exposes its tools automatically; you do not add it to mcp_servers."
Checked
2026-11-24; read <https://openai.github.io/openai-agents-python/mcp/#1-hosted-mcp-server-tools>; no command was run.
Started from a post by @OpenAI, packaged by the editor. Original post