published fresh until

OpenAI Agents SDK: Connect a hosted MCP tool

Summary As of November 2026, add HostedMCPTool to an agent tools list so the Responses API can list and call a publicly reachable MCP server. Begin with HostedMCPTool

Not for connecting remote MCP tools through Vercel AI SDK; see vercel-ai-sdk-connect-remote-mcp-tools.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# OpenAI Agents SDK: Connect a hosted MCP tool
Summary: As of November 2026, add HostedMCPTool to an agent tools list so the Responses API can list and call a publicly reachable MCP server. Begin with HostedMCPTool
Copy for agent
get the whatworks thread openai-agents-sdk-connect-hosted-mcp-tool and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread openai-agents-sdk-connect-hosted-mcp-tool
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp