openai-agents-relayshield
OpenAI Agents SDK tools and a mandatory pre-execution gate for RelayShield's agentic-security endpoints — MCP server registry risk and AI-agent-sourced credential breach detection.
Install
pip install openai-agents-relayshield
Tools
from agents import Agent, Runner
from openai_agents_relayshield import check_mcp_server_risk, check_prompt_injection_breach
agent = Agent(
name="Assistant",
tools=[check_mcp_server_risk, check_prompt_injection_breach],
)
result = await Runner.run(
agent,
"Is it safe to connect to the MCP server at https://mcp.example.com/sse? My RelayShield key is rs_live_...",
)
check_mcp_server_risk— flags known-malicious IOC matches, typosquat domains, and newly-registered domains hosting an MCP server, before an agent connects to or installs it.check_prompt_injection_breach— checks whether an email appears in RelayShield's stolen-session corpus with a suspected-agentic-source marker (a session/token exposure that shows signs of having been captured via a compromised AI agent).
Both tools take api_key as a call argument rather than reading it from the environment implicitly — a shared agent process can act safely on behalf of multiple callers with different RelayShield keys.
Get a key at api.relayshield.net/developers.
Mandatory gate
Most "AI agent security" checks are optional — the agent can call them, but nothing stops it skipping the call and taking the risky action anyway. relayshield_mcp_gate is the other kind: a gate the framework enforces before a protected action (connecting to or installing an MCP server) can happen at all, built on the SDK's @tool_input_guardrail hook.
from openai_agents_relayshield.guardrail import relayshield_mcp_gate
# Attach directly to your own connect/install tool(s) — the guardrail is
# scoped by which tools you assign it to, not by matching tool names inside it.
connect_mcp_server.tool_input_guardrails = [relayshield_mcp_gate]
Properties, all non-negotiable by design:
- A hook exception defaults to
defer(blocked, with an explanatory message), never silently toallow— a gate failure must not become a pass. - Bounded retry applies only to transient upstream failures (timeout/429/5xx) — auth failures, malformed responses, and payment-required states are terminal after one attempt.
- The gate logs the decision, reason codes, check version, target, and timestamp — never keys, payment proofs, or session material.
- The raw connect/install tool should never be bound to the model directly in a real deployment — only route access to it through the gate.
Same normalized policy as langchain-relayshield's RelayShieldMCPGateMiddleware and its original standalone reference implementation, relayshield-langchain-gate — ported rather than imported, so this package has no dependency on LangChain/LangGraph.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openai_agents_relayshield-0.1.0.tar.gz.
File metadata
- Download URL: openai_agents_relayshield-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73290cf432d8de0de5612745ec17ab6dd68ae3a329c9152965575563fe0a100f
|
|
| MD5 |
85b49bd84a55e4066e6dc9e52225d828
|
|
| BLAKE2b-256 |
30b85519c82dfaafc67ab734f93a7b90883067f3ac124534b4fdca257750f497
|
Provenance
The following attestation bundles were made for openai_agents_relayshield-0.1.0.tar.gz:
Publisher:
publish.yml on nzdsf2-gif/openai-agents-relayshield
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openai_agents_relayshield-0.1.0.tar.gz -
Subject digest:
73290cf432d8de0de5612745ec17ab6dd68ae3a329c9152965575563fe0a100f - Sigstore transparency entry: 2226688572
- Sigstore integration time:
-
Permalink:
nzdsf2-gif/openai-agents-relayshield@1e6d1556cf11b66289dbfcc73255fdef46a9a248 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nzdsf2-gif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e6d1556cf11b66289dbfcc73255fdef46a9a248 -
Trigger Event:
release
-
Statement type:
File details
Details for the file openai_agents_relayshield-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openai_agents_relayshield-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93e2526ac4926077cf9ae6f3bf69d243fceb3f4f7ee7fbf45c306993fbbd0173
|
|
| MD5 |
517ed8fccbe2d379a4dfa2cefc1bffde
|
|
| BLAKE2b-256 |
6c3f0cf47050e6985664d5264b45e7b11d4890cd4d8ae16af2cb75d67a84c000
|
Provenance
The following attestation bundles were made for openai_agents_relayshield-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on nzdsf2-gif/openai-agents-relayshield
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openai_agents_relayshield-0.1.0-py3-none-any.whl -
Subject digest:
93e2526ac4926077cf9ae6f3bf69d243fceb3f4f7ee7fbf45c306993fbbd0173 - Sigstore transparency entry: 2226689253
- Sigstore integration time:
-
Permalink:
nzdsf2-gif/openai-agents-relayshield@1e6d1556cf11b66289dbfcc73255fdef46a9a248 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nzdsf2-gif
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e6d1556cf11b66289dbfcc73255fdef46a9a248 -
Trigger Event:
release
-
Statement type: