Repository navigation
openai_agents: add require_approval to stateless_mcp_server() and stateful_mcp_server() - #220
Merged
campoy merged 2 commits intoOct 28, 2026
Conversation
…teful_mcp_server() The deprecated MCP helpers had no way to require tool approval. The agent reads the approval policy from the server it holds, which in a workflow is the plugin's reference, and a policy set on the factory's server is never read. temporal_mcp_server() already takes require_approval; the stateful helper is still the only route with a persistent MCP session, and the deprecated helpers are the only ones that run with MCP Python SDK v1. Pass the new option to the workflow-side reference. Callers that omit it are unchanged.
campoy
marked this pull request as ready for review
October 28, 2026 21:48
xumaple
approved these changes
Oct 28, 2026
campoy
deleted the
fix/openai-agents-python-mcp-require-approval-ignored
branch
October 28, 2026 22:25
This was referenced Oct 29, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
stateless_mcp_server()andstateful_mcp_server()take a newrequire_approvaloption and pass it to the Workflow-side reference, so the agent pauses before the server's tools run, as it does natively and withtemporal_mcp_server(require_approval=...).MCPServerStdio(require_approval=...). A callable policy runs in the Workflow and must be deterministic; the docstrings say so.require_approvalthere, and that a policy on the factory's server is not used.API change: one new keyword argument on each deprecated helper, defaulting to
None. Existing code is unchanged. Arequire_approvalset on the factory's server is still ignored, as withtemporal_mcp_server(); callers move it to the new option.Replay and rollback: a reference built without the option is the same as before (
MCPServer.__init__(require_approval=None)is the default), so no gate is needed. Code that passes the new option cannot run on an earlier release, which lacks the argument; that is a code dependency, not a replay difference.Why?
See #219. The agent reads the approval policy from the server it holds, which in a Workflow is the plugin's reference, and the deprecated helpers gave the reference no policy. The policy on the factory's server is never read, so an MCP tool meant to wait for approval runs at once with no error or warning.
temporal_mcp_server()already covers this, butstateful_mcp_server()is still the only route with a persistent MCP session, and the deprecated helpers are the only ones that run with MCP Python SDK v1.Checklist
Closes [Bug] openai_agents: stateless_mcp_server() and stateful_mcp_server() can't require tool approval #219
How was this tested:
test_mcp_serverintests/test_openai.pygainsstateful-approvalandstateless-approvalcases: the Workflow must return the interruption forSay-Helloand the server'scall_toolmust not run. The two test Workflows take the policy as a new argument, sotest_mcp_server_factory_argumentandtest_stateful_mcp_server_no_workerpassNonefor it. Onmainall eight MCP Workflow tests fail withTypeError: ... got an unexpected keyword argument 'require_approval'; with the change all eight pass.main's 382 and the two new cases), andruff check --select I,ruff format --check,pyright,mypy,basedpyrightandpydocstylepass. These ran with uv 0.13.1, outside the plugin'srequired-version, so not throughmake. CI coversmake lintandmake test.mainatc664a34. With the change it exits 0: both helpers pause beforewireruns, like the native run andtemporal_mcp_server().mainreplay onmainand with the change (3 of 3 each);main(3 of 3); with the option (stateless and stateful) they replay with the change, and onmainfail with the missing-argumentTypeError, not a nondeterminism error;mainfinishes with the change, and the one started with the change finishes onmain, with no failed Workflow Task;[TMPRL1100]on all 8 histories.Any docs updates needed?
The README's paragraph on the deprecated MCP APIs is updated here.
Not covered:
require_approvalortool_meta_resolverset on the factory's server is still silently ignored, on these helpers and ontemporal_mcp_server(). The plugin already rejects a callabletool_filterthere. Rejecting these too would make the mistake visible, but it would fail runs that complete today, so it is left for a separate change.tool_meta_resolveralready works when assigned to the returned reference's public attribute, so it gets no new option here.temporalio1.34.x still bundles the old helpers astemporalio.contrib.openai_agents. No backport here.Open questions:
tool_filter?Draft while these questions are open.