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.1.tar.gz (9.0 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.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_relayshield-0.1.1.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

Hashes for langchain_relayshield-0.1.1.tar.gz
Algorithm Hash digest
SHA256 180cdd91e21a0718195e2ebc8f66eb1c0161abe5b42c3e61dc73aafd5b904143
MD5 be0d9ca2da4575125b2ce59b387ae17e
BLAKE2b-256 44bbee2909ad27201844e9664b800269efb2472b5e63bb48fdfa86cec9d5e466

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_relayshield-0.1.1.tar.gz:

Publisher: publish.yml on nzdsf2-gif/langchain-relayshield

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for langchain_relayshield-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b50d250821b5ae2afe5e9256c30f21bf72b5f5a09508e5a92223749923851be4
MD5 d769d4c8c5f8ef63fc40cdb5a5b4bbaa
BLAKE2b-256 a84a5fb60e09a22ac3b55a2be0bb22db318ccbb90e65faa7360559fae4a53836

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_relayshield-0.1.1-py3-none-any.whl:

Publisher: publish.yml on nzdsf2-gif/langchain-relayshield

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

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