Skip to main content

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 to allow.
  • 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_relayshield-0.1.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_relayshield-0.1.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_relayshield-0.1.2.tar.gz.

File metadata

  • Download URL: langchain_relayshield-0.1.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for langchain_relayshield-0.1.2.tar.gz
Algorithm Hash digest
SHA256 99f7a5da996f549203ed8433282c7570eb327e8286537cb44d93f6160ef5216f
MD5 659a6843b72e55365e77e62abc100b51
BLAKE2b-256 e4cdd5490242d9014b62d1839f55d1b6993406c7680ab5ab01d1dd4bd611b83d

See more details on using hashes here.

File details

Details for the file langchain_relayshield-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_relayshield-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cb14a52863d226489da34d89f95e23ed8b0080f853bcce62cf1460cddb1c96d7
MD5 b96b567712f77783eec95f00fe53fe95
BLAKE2b-256 15d67153d3115f9fa68d1076db2e4234aa2fa267fa93a7220a48431e6051b930

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page