LangChain tools and a mandatory pre-execution gate for RelayShield's MCP registry risk and prompt-injection breach checks.
Project description
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
Project details
Release history Release notifications | RSS feed
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 langchain_relayshield-0.1.0.tar.gz.
File metadata
- Download URL: langchain_relayshield-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f721b0c2940e871121918cbbb197a3cb84178bfbf382aad937c9c8a9a6f7eaf
|
|
| MD5 |
11f9a9cb41c5dafdeb3efda4f989a19c
|
|
| BLAKE2b-256 |
e9c10973667c141ef2c0c0a28e67c9f7029da0b2ca4ad75b1a6f237f327def88
|
Provenance
The following attestation bundles were made for langchain_relayshield-0.1.0.tar.gz:
Publisher:
publish.yml on nzdsf2-gif/langchain-relayshield
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_relayshield-0.1.0.tar.gz -
Subject digest:
4f721b0c2940e871121918cbbb197a3cb84178bfbf382aad937c9c8a9a6f7eaf - Sigstore transparency entry: 2221815870
- Sigstore integration time:
-
Permalink:
nzdsf2-gif/langchain-relayshield@15991c5a326c9cdfbd3dc86c11cea1e91aa50504 -
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@15991c5a326c9cdfbd3dc86c11cea1e91aa50504 -
Trigger Event:
release
-
Statement type:
File details
Details for the file langchain_relayshield-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_relayshield-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 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 |
cf3579f2aa9274e5e1d1d6397f0a34de2ce73e27a01eeb6dcde2cc657e917e7d
|
|
| MD5 |
833ef685008dfa2d535f1530d9c8c54f
|
|
| BLAKE2b-256 |
8264230d0c2c014a9c90bce683c18f9a289ff173ba0c95efa6cc0a5e0ffde70a
|
Provenance
The following attestation bundles were made for langchain_relayshield-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on nzdsf2-gif/langchain-relayshield
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_relayshield-0.1.0-py3-none-any.whl -
Subject digest:
cf3579f2aa9274e5e1d1d6397f0a34de2ce73e27a01eeb6dcde2cc657e917e7d - Sigstore transparency entry: 2221816198
- Sigstore integration time:
-
Permalink:
nzdsf2-gif/langchain-relayshield@15991c5a326c9cdfbd3dc86c11cea1e91aa50504 -
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@15991c5a326c9cdfbd3dc86c11cea1e91aa50504 -
Trigger Event:
release
-
Statement type: