Skip to main content

langchain-revsec

RevSec for LangChain agents. Add one middleware and RevSec checks each tool call before it runs: a call to an MCP tool against that MCP server, a call to one of the agent's own tools against the agent's own rules. A blocked call never runs, and the model is told why. What the user asks is checked before it reaches the model, and what each tool hands back before the model reads it. What happened is recorded, and the agent is listed in your RevSec console with its model and tools.

Your rules live in RevSec, not in your code. If you ship agents to customers, each customer account gets its own rules, approvals and evidence.

Get a key

  • Shipping agents to your customers? Start a free trial and choose "AI we ship to our customers". Your Sandbox key is shown once, when you sign up.
  • Building agents for your own company? Book a demo.
pip install langchain-revsec
export REVSEC_API_KEY="<your key>"
export REVSEC_BASE_URL="https://app.revsec.app/fcc"

Add it to your agent

Load your MCP tools with get_mcp_tools (in place of client.get_tools()) and add the middleware:

from langchain.agents import create_agent
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain_revsec import RevSecMiddleware, get_mcp_tools

client = MultiServerMCPClient({
    "github": {"transport": "streamable_http", "url": "https://api.githubcopilot.com/mcp/"},
})
tools = await get_mcp_tools(client)
agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=tools + [lookup_order],
    middleware=[RevSecMiddleware(agent_name="orders-agent")],
)

That's all. Block a tool in RevSec and run the agent: the call doesn't run, and the model gets a tool message saying Blocked by RevSec: <the reason>, so it can tell the user or try something else.

  • MCP tools are checked against their MCP server: the server's approval, your MCP policies and its known vulnerabilities.
  • The agent's own tools (functions in your code, like lookup_order) are checked as the agent's: its status (a quarantined agent is stopped) and its tool-call policies, such as "block refund_order". They are recorded with the agent's tool calls, never as an MCP server.
  • What a tool sends out (secrets, personal data) is scanned by your data protection policies when you turn it on: revsec.mcp.configure(..., dlp=True).
  • What a tool hands back (a web page, a file, an MCP server's reply) is checked before the model reads it: instructions hidden in it, secrets, personal data. A result RevSec stops is replaced with a tool message saying Withheld by RevSec: ...; the call itself ran.
  • Calls RevSec stops, holds or flags reach your SIEM, if one is connected in the RevSec console.

pip install "langchain-revsec[mcp]" installs LangChain's MCP adapter. RevSec is told each server's address, or for a local server the package it runs; never the rest of its launch command. Tools loaded with client.get_tools() can't be told apart from the agent's own tools, so they are checked as the agent's own; load them with get_mcp_tools to check them as MCP calls.

Prompts

What the user asks is checked before each model call, with the same Model Security check RevSec runs for coding tools on a laptop: your prompt rules and the built-in checks (prompt injection, secrets, personal data). A prompt RevSec stops never reaches the model; the agent answers Blocked by RevSec: <the reason> instead. Each check is kept on the agent in RevSec, in the same conversation as its tool calls, and the model it was about to call is listed on the agent. No AI gateway is needed.

If your model calls go through the RevSec AI gateway (Settings → AI gateway in the console), it checks prompts there; turn the check here off so each prompt is checked once:

from revsec import mcp
mcp.configure(api_key=os.environ["REVSEC_API_KEY"], check_prompts=False)

check_tool_results=False turns off the tool-result check.

A graph you build yourself

In a LangGraph graph of your own, give its ToolNode the same checks:

from langgraph.prebuilt import ToolNode

revsec = RevSecMiddleware(agent_name="orders-agent")
tools_node = ToolNode(tools, wrap_tool_call=revsec.wrap_tool_call, awrap_tool_call=revsec.awrap_tool_call)
revsec.register_agent(models=["claude-sonnet-5-5"], tools=[t.name for t in tools])  # optional

Options

Option Default What it does
agent_name required The agent's name in RevSec. Registering again updates the same agent.
api_key REVSEC_API_KEY Your RevSec key.
base_url REVSEC_BASE_URL Your RevSec address, ending in /fcc.
register True List the agent in RevSec on its first model call, with its model and tools.
description, owner_email, environment none Shown on the agent in RevSec.
on_block "message" "raise" raises revsec.RevsecBlocked instead of telling the model (a blocked call, a withheld tool result or a stopped prompt).

A customer account key, such as the Sandbox key you get when you sign up, checks the agent's tool calls and registers the agent in that customer account.

Calls and checks in one conversation (one LangGraph thread_id) are grouped into one chain in RevSec's Activity Explorer.

When RevSec can't be reached

By default a call is allowed when RevSec can't be reached, so an outage never stops your agent. To block instead:

from revsec import mcp
mcp.configure(api_key=os.environ["REVSEC_API_KEY"], failure_mode="fail_closed")

mcp.configure(api_key=..., enabled=False) turns the checks off. This package is built on revsec-sdk; its README covers these settings.

License

Copyright (c) 2026 RevUp AI LLC. Use is subject to the RevSec terms of service.

Metadata

Release files for langchain-revsec 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-revsec 0.1.1
File Size Uploaded Provenance Actions
langchain_revsec-0.1.1.tar.gz 18.6 kB Without provenance Details for langchain_revsec-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-revsec 0.1.1
File Interpreter ABI Platform Actions
langchain_revsec-0.1.1-py3-none-any.whl Python 3 none any Details for langchain_revsec-0.1.1-py3-none-any.whl

Total release size: 30.4 kB

Release files / langchain_revsec-0.1.1.tar.gz

Download URL langchain_revsec-0.1.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d94d6c0a1edd4c85571c61dd0be0414152c256fcc5dbc6aac029274a0aebaf85
BLAKE2b-256 checksum
How to use checksums
9e2a65e05308acaa700ec5b1b8e5cf67951dd16a48269826f99d963311f03d4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / langchain_revsec-0.1.1-py3-none-any.whl

Download URL langchain_revsec-0.1.1-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f13f537a9185b1cac608f4b5fc85d80d11694fed7696cb8b3d8a60c38825add5
BLAKE2b-256 checksum
How to use checksums
cca688e13d4144fc54cc8f0618ce70ad1db39634e9047b81757d227e11ab23a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for langchain-revsec 0.1.1

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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