Skip to main content

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 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

Project details


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.0.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.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

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

Hashes for langchain_relayshield-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f721b0c2940e871121918cbbb197a3cb84178bfbf382aad937c9c8a9a6f7eaf
MD5 11f9a9cb41c5dafdeb3efda4f989a19c
BLAKE2b-256 e9c10973667c141ef2c0c0a28e67c9f7029da0b2ca4ad75b1a6f237f327def88

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_relayshield-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_relayshield-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf3579f2aa9274e5e1d1d6397f0a34de2ce73e27a01eeb6dcde2cc657e917e7d
MD5 833ef685008dfa2d535f1530d9c8c54f
BLAKE2b-256 8264230d0c2c014a9c90bce683c18f9a289ff173ba0c95efa6cc0a5e0ffde70a

See more details on using hashes here.

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

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page