mcp-and-hosted-tools
Integrate local and hosted MCP tools in openai-agents-python, including stdio, SSE, Streamable HTTP, filtering, approvals, caching, metadata, retries, and structured content.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- mcp-and-hosted-tools
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Integrate local and hosted MCP tools in openai-agents-python, including stdio, SSE, Streamable HTTP, filtering, approvals, caching, metadata, retries, and structured content.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md13.7 KB
- 参考文档references/troubleshooting.md9.8 KB
- 参考文档references/workflows.md11.8 KB
- 脚本scripts/check_mcp_config.py16.7 KB
03 SKILL.md 正文
MCP and Hosted Tools
Use this sub-skill when a task mentions MCPServerStdio, MCPServerSse, MCPServerStreamableHttp, HostedMCPTool, tool_filter, require_approval, MCP auth, streamable HTTP, server managers, or hosted MCP connectors.
Start Here
- Read references/api-reference.md for constructor options, local transport differences, approval/filter forms, metadata hooks, and hosted MCP tool shape.
- Read references/workflows.md for copyable integration patterns: stdio, Streamable HTTP, server manager, filtering, approval, hosted MCP, metadata, caching, and fake-server tests.
- Read references/troubleshooting.md for missing MCP imports, command failures, auth/session problems, stale cached tools, approval/structured-content surprises, and remote network restrictions.
- Run scripts/check_mcp_config.py to validate a JSON MCP config and import MCP classes without starting remote servers by default.
Routing Boundaries
- Stay here for local MCP server lifecycle, stdio/SSE/Streamable HTTP params,
MCPServerManager,MCPUtil, tool caching/filtering, MCP approvals,_metaresolvers, message handlers, structured content, hosted MCPtool_config, hosted approval callbacks, and MCP retry/error handling. - Route generic
@function_tool, function-tool guardrails,handoff(...), and non-MCP approval declarations to ../tools-handoffs-guardrails/SKILL.md. - Route model/provider support, Responses versus Chat Completions compatibility,
OpenAIProvider, websocket provider setup, and feature validation to ../models-providers/SKILL.md. - Route core runner semantics,
RunStateresume mechanics, sessions, streaming event interpretation, andRunConfigorchestration to ../core-runtime/SKILL.md.
Fast Decisions
- Use local MCP servers in
Agent(mcp_servers=[...])when the MCP server is local, private, needs custom auth/client behavior, or should execute tool calls in the application process. - Use
HostedMCPToolinAgent(tools=[...])when an OpenAI Responses model should call a public or connector-backed MCP server directly. - Prefer Streamable HTTP for new HTTP MCP servers; keep SSE only for legacy servers, and use stdio when the server is a local subprocess.
- Enable
cache_tools_list=Trueonly when tool definitions are stable, and callinvalidate_tools_cache()after capabilities change. - Combine
tool_filterwithrequire_approvalfor least-privilege MCP exposure: hide irrelevant tools first, then approval-gate sensitive remaining calls.
Safety Notes
- Do not put secrets, bearer tokens, local checkout paths, or machine-specific command paths in public skill content or logged config dumps.
- Do not start remote servers, invoke configured commands, or perform network checks just to validate configuration unless the user explicitly asks.
- Treat hosted MCP as Responses-only hosted-tool configuration; route provider/model feature questions before assuming a non-OpenAI provider supports it.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).