recusal-openai-agents-mcp
The Recusal gate for MCP tools on an OpenAI Agents SDK agent: every call to a local MCP server, and every hosted MCP call OpenAI asks approval for, is judged by your policy first.
This is a separate distribution from recusal. The kernel has zero runtime dependencies
and a frozen compatibility perimeter; this package carries the SDK and MCP dependencies
and its own version, so a release of either never forces a release of the kernel.
It builds on
recusal-openai-agents,
the function-tool gate, and depends on that package.
Status: not yet published to PyPI. Until it is, install both from the repository,
recusal-openai-agents first since this package requires it:
pip install "recusal-openai-agents @ git+https://github.com/philpaz/recusal#subdirectory=adapters/openai-agents"
pip install "recusal-openai-agents-mcp @ git+https://github.com/philpaz/recusal#subdirectory=adapters/openai-agents-mcp"
Requires Python 3.10+, recusal>=0.14.0, recusal-openai-agents>=0.1.0,
openai-agents>=0.24.0 and mcp>=2.3.0. It is tested on every pull request against
exactly openai-agents==0.24.0 with openai==3.34.0, and weekly against the newest
releases.
Use
from agents import Agent
from recusal import Finding
from recusal_openai_agents_mcp import gated_agent
def policy(tool_name, tool_input):
sql = tool_input.get("sql", "")
if tool_name == "run_sql" and sql.lstrip().upper().startswith("DELETE"):
return [Finding.fail("no_deletes", severity="CRITICAL", message="DELETE is not allowed")]
return []
agent = gated_agent(Agent(name="assistant", tools=[...], mcp_servers=[server]), policy)
gated_agent gates all three kinds of tool at once: function tools (through
recusal-openai-agents), every server in mcp_servers, and every HostedMCPTool.
gate_mcp_server(server, policy) and gate_hosted_mcp(tool, policy) gate one of each.
Local MCP servers are gated in place, at server.call_tool. That is the one point
where the SDK hands the server its own tool name and the exact arguments it will run,
after any approval a person gave. A refusal returns an MCP error result carrying
Recusal's reason, and the server is never reached. The policy sees the name the server
executes under, whatever public name the model called it by, so a policy keyed by tool
name must name the server's own tools.
A server carries one policy. The gate is installed on the server object, so every
agent that lists that object shares it. Gating it again with the same policy is a no-op;
gating it with a different policy raises ValueError. Use a separate server object per
policy.
Hosted MCP is approval-gated, not execution-gated. Those calls run on OpenAI's
servers. gate_hosted_mcp returns a copy whose require_approval is "always" and
whose approval callback is Recusal's: a refusal answers {"approve": False, "reason": ...}, so the hosted call is not made. A hosted tool whose require_approval is anything
but "always" is reported as ungated.
Put every decision on the record
from recusal.audit import AuditLog
from recusal_openai_agents_mcp import audited_agent
log = AuditLog(path="decisions.jsonl")
agent = audited_agent(Agent(name="assistant", mcp_servers=[server]), policy, log)
One log covers the three seams, each under its own surface label:
| Seam | Surface | Call id on the entry |
|---|---|---|
| Function tools | openai_agents.tool_input_guardrail |
the SDK's tool call id |
| Local MCP server | openai_agents.mcp.call_tool |
none: the SDK hands call_tool no id; the server is control.mcp_server |
| Hosted MCP | openai_agents.hosted_mcp.approval |
the approval request id; the server label is control.mcp_server |
Each entry holds a SHA-256 fingerprint of the arguments, never the arguments. If the log
cannot be written the call is refused. Check the log with
recusal audit verify decisions.jsonl.
What the gate does not see
- A hosted call OpenAI does not ask approval for. That is why the gate sets
require_approvalto"always". - What the tool's own approval callback answered after Recusal allowed a call. The entry records Recusal's decision, not that callback's.
- Handoffs, an ungated sub-agent behind
as_tool, andAgentsubclasses.gated_agentraises for these at construction.
Compatibility
This package is outside the kernel's frozen perimeter (STABILITY.md, Integrations). Its
public names are the ones in recusal_openai_agents_mcp.__all__. It uses only the public
names of recusal-openai-agents.
A runnable offline demonstration, with an in-process MCP server and no API key, is
examples/openai_agents_mcp_gate.py
and
examples/openai_agents_mcp_audit.py.
Metadata
Release files for recusal-openai-agents-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| recusal_openai_agents_mcp-0.1.0.tar.gz | 16.7 kB | With provenance | Details for recusal_openai_agents_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| recusal_openai_agents_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for recusal_openai_agents_mcp-0.1.0-py3-none-any.whl |
Total release size: 32.6 kB
Release files / recusal_openai_agents_mcp-0.1.0.tar.gz
| Download URL | recusal_openai_agents_mcp-0.1.0.tar.gz |
|---|---|
| Size | 16.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc439978039ffbdeaa8a362fba7d3dec2b11e45c83685974f9aa49046ec1f750
|
|
BLAKE2b-256 checksum How to use checksums |
5ed6330639cd803e19191a7d5ce7c0b35bbe956e27805613bd977a6b47441a8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / recusal_openai_agents_mcp-0.1.0-py3-none-any.whl
| Download URL | recusal_openai_agents_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba7cfadb4cb42e5395ba70a93260e45a1916fbe75921b2eefa1949196386d877
|
|
BLAKE2b-256 checksum How to use checksums |
8428a9a9804252d13b0f707ae099c79a2507f8d5cec0e1134fb0469c7f5d5c0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for recusal-openai-agents-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for recusal_openai_agents_mcp-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.