strands-revsec
RevSec for Strands Agents. Add RevSecHooks to
your agent and RevSec checks each tool call before it runs: a call to an MCP
server's 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 strands-revsec
export REVSEC_API_KEY="<your key>"
export REVSEC_BASE_URL="https://app.revsec.app/fcc"
Add it to your agent
Build your MCP clients with revsec_mcp_client (in place of MCPClient) and
add RevSecHooks:
from strands import Agent, tool
from strands_revsec import RevSecHooks, revsec_mcp_client
github = revsec_mcp_client("github", url="https://api.githubcopilot.com/mcp/")
notes = revsec_mcp_client("notes", command="npx", args=["-y", "@acme/notes-mcp"])
@tool
def lookup_order(order_id: str) -> str:
"""Look up an order."""
...
agent = Agent(
tools=[github, notes, lookup_order],
hooks=[RevSecHooks(agent_name="orders-agent")],
)
agent("Where is order A1?")
That's all. Block a tool in RevSec and run the agent: the call doesn't run,
and the model gets a tool result 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 "blockrefund_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 one 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.
MCP servers
RevSec files each MCP server under the name you give it, and is told its address, or for a local server the package it runs; never the rest of its launch command (which can carry tokens).
revsec_mcp_client(name, url=...)for a remote server, orrevsec_mcp_client(name, command=..., args=..., env=...)for a local one. Other keyword arguments go toMCPClient(prefix=,startup_timeout=, ...).revsec_mcp_servers("mcp.json")in place ofMCPClient.load_servers(...): each server is filed under its key in themcpServersconfig.- An
MCPClientyou build yourself:note_mcp_server(client, "github", url=...).
Calls to an MCP client RevSec can't name are still checked as MCP calls, under
unnamed-mcp-server, and a warning says how to name it.
Strands' MCP router tool reaches servers through one tool of the agent's
(mcp_router), so RevSec checks those calls as that one tool. Give the agent
the MCP clients themselves to check each server's calls.
Prompts
What the user asks is checked before it reaches the model, 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 and isn't kept in the conversation; the
agent answers Blocked by RevSec: <the reason> instead, and the conversation
carries on. 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.
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 request, with its model and tools. |
description, owner_email, environment |
none | Shown on the agent in RevSec. |
customer_facing |
none | True when the agent talks to your customers; shown on the agent and used in its setup rating. |
on_block |
"message" |
"raise" raises instead of telling the model or the user: revsec.RevsecBlocked for a stopped prompt, and Strands' EventLoopException for a blocked tool call (the RevsecBlocked is its original_exception). A tool result RevSec stops is always withheld, since Strands doesn't pass on an error raised after a tool has run. |
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 Agent, or one session when you use
a Strands session manager) 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.
Works with strands-agents 1.54 and later.
License
Apache License 2.0; see LICENSE. This package calls the RevSec service through revsec-sdk; use of the service is subject to the RevSec terms of service.
Metadata
Release files for strands-revsec 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strands_revsec-0.1.2.tar.gz | 25.1 kB | Without provenance | Details for strands_revsec-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strands_revsec-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for strands_revsec-0.1.2-py3-none-any.whl |
Total release size: 42.2 kB
Release files / strands_revsec-0.1.2.tar.gz
| Download URL | strands_revsec-0.1.2.tar.gz |
|---|---|
| Size | 25.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16f5a80b2aa729867e72bc869723acd03aae4d9573ecde568fa91063f1af6e46
|
|
BLAKE2b-256 checksum How to use checksums |
647fbb2220ce31fbd98426b6046e808922d56621114d8cb2b4710a014482b9de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Release files / strands_revsec-0.1.2-py3-none-any.whl
| Download URL | strands_revsec-0.1.2-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9f373d708a729eb877298b6f9ea6378e163166ebc459435b882ceff7c64a646a
|
|
BLAKE2b-256 checksum How to use checksums |
445ca22c87c3580f8332c397fa3702d2836edc1175a593578a67fd494870033c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.0
|
Security for strands-revsec 0.1.2
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.