langchain-relayshield
LangChain 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 langchain-relayshield
The mandatory-gate middleware needs LangChain's agent runtime; install the extra if you want it:
pip install "langchain-relayshield[middleware]"
Tools
from langchain_relayshield import check_mcp_server_risk, check_prompt_injection_breach
result = check_mcp_server_risk.invoke({
"api_key": "rs_live_...",
"server_url": "https://mcp.example.com/sse",
})
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).
Get a key at api.relayshield.net/developers.
Mandatory gate middleware
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. RelayShieldMCPGateMiddleware is the other kind: a gate the agent's framework enforces before a protected action (connecting to or installing an MCP server) can happen at all.
from langchain_relayshield.middleware import RelayShieldMCPGateMiddleware
agent = create_agent(
model=...,
tools=[...],
middleware=[RelayShieldMCPGateMiddleware()],
)
Properties, all non-negotiable by design:
- A hook exception defaults to
defer, never silently toallow. - 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 audit log records 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 — only a composite tool that routes through this gate.
Full design writeup and a 12-case protected-action acceptance suite: relayshield-langchain-gate (this middleware's original standalone reference implementation, now also packaged here).
License
MIT
Metadata
Release files for langchain-relayshield 0.1.2
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 | |
|---|---|---|---|---|
| langchain_relayshield-0.1.2.tar.gz | 8.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_relayshield-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / langchain_relayshield-0.1.2.tar.gz
| Download URL | langchain_relayshield-0.1.2.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99f7a5da996f549203ed8433282c7570eb327e8286537cb44d93f6160ef5216f
|
|
BLAKE2b-256 checksum How to use checksums |
e4cdd5490242d9014b62d1839f55d1b6993406c7680ab5ab01d1dd4bd611b83d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / langchain_relayshield-0.1.2-py3-none-any.whl
| Download URL | langchain_relayshield-0.1.2-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb14a52863d226489da34d89f95e23ed8b0080f853bcce62cf1460cddb1c96d7
|
|
BLAKE2b-256 checksum How to use checksums |
15d67153d3115f9fa68d1076db2e4234aa2fa267fa93a7220a48431e6051b930
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for langchain-relayshield 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.