Metadata-Version: 2.4
Name: adk-revsec
Version: 0.1.0
Summary: RevSec for Google ADK: stop risky agent actions before they run, catch prompt injection and leaked data, and keep a record of what every agent did.
Author-email: RevSec / RevUp AI LLC <hello@revupai.com>
License-Expression: Apache-2.0
Project-URL: Source, https://github.com/RevUp-AI/adk-revsec
Project-URL: Issues, https://github.com/RevUp-AI/adk-revsec/issues
Project-URL: Start a free trial, https://app.revsec.app/start?from=google-adk
Keywords: google-adk,adk,agent-development-kit,ai-agents,ai-security,guardrails,mcp,tool-calls,governance
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: revsec-sdk<0.6,>=0.5.0
Requires-Dist: google-adk<3,>=1.18
Provides-Extra: mcp
Requires-Dist: mcp<3,>=1.24; extra == "mcp"
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Requires-Dist: pytest-asyncio>=0.23; extra == "test"
Requires-Dist: mcp<3,>=1.24; extra == "test"
Dynamic: license-file

# adk-revsec: RevSec for Google ADK

**Ship ADK agents your customers' security teams will approve.**

Agents built with the Google Agent Development Kit (ADK) take real actions: they refund orders, send emails, change
records and call MCP servers. RevSec decides, before each action runs, whether the agent is allowed to take it, and
keeps a record of what every agent did. Add one plugin to your ADK `App`; your agent code stays the same.

One plugin covers all three things an agent touches: **its actions** (Agent Security), **the MCP servers it calls**
(MCP Governance) and **what reaches its model** (Model Security).

## What it does for your business

- **Stops risky actions before they happen.** Each tool call is checked against your policies before it runs. A
  refund above a limit, a delete, or a call to an MCP server nobody approved is blocked, and the agent is told why,
  so it can answer the user instead of failing.
- **Keeps prompt injection and leaked data away from your model.** RevSec Model Security checks what users ask
  before it reaches the model, and what tools hand back (web pages, documents, MCP replies) before the model reads
  it, for instructions aimed at the model, secrets and personal data. Your organisation's own prompt rules apply too.
- **Governs your MCP servers.** Each MCP call is checked against that server: whether it is approved, its policies
  and its known vulnerabilities.
- **Gives you one view of every agent.** Each agent appears in your RevSec console with the models it uses, its
  tools and MCP servers, its risk rating, and its decisions grouped by conversation. Prompt and tool-result checks
  also show in Model Security.
- **Proves control, action by action.** Replay any session in Activity Explorer: what the user asked, each tool
  and MCP call, and what RevSec decided. Frameworks shows which controls in the EU AI Act, ISO/IEC 42001,
  NIST AI RMF, SOC 2 and more your policies are mapped to, and Evidence Packs gather the evidence for a customer's
  security review or auditor.
- **Covers every agent in the App.** Root agents and sub-agents are checked the same way, with no code in each agent.

## Quick start

```bash
pip install "adk-revsec[mcp]"
```

Get a key from the RevSec console (**Customer accounts → New key** in a builder account, or **Settings → SDK**), then:

```bash
export REVSEC_API_KEY=rsk_...
export REVSEC_BASE_URL=https://app.revsec.app/fcc
```

```python
from google.adk.agents import LlmAgent
from google.adk.apps import App
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService

from adk_revsec import RevSecPlugin, revsec_mcp_toolset


def refund_order(order_id: str, amount: int) -> dict:
    """Refund an order."""
    ...


notes = revsec_mcp_toolset("notes", command="npx", args=["-y", "@acme/notes-mcp"])

agent = LlmAgent(
    name="orders_agent",
    model="gemini-flash-latest",
    instruction="Help customers with their orders.",
    tools=[refund_order, notes],
)

app = App(name="orders_app", root_agent=agent, plugins=[RevSecPlugin()])
runner = Runner(app=app, session_service=InMemorySessionService())
```

That's all. The first request registers the agent in RevSec. From then on its tool calls, prompts and tool results
are checked, and the decisions show in the console.

## What RevSec checks

| When | What | If RevSec stops it |
|---|---|---|
| Before the run | What the user asked | The model is never called and the request is not kept in the session; the user gets a short reply saying it was blocked |
| Before each tool call | The agent's own tools, against the agent's policies | The tool never runs; the model gets a response saying why |
| Before each MCP tool call | The call, against that MCP server: whether it is approved, its policies, its known vulnerabilities | The call never reaches the server; the model gets a response saying why |
| After each tool call | What the tool handed back | The model gets "withheld" instead of the content |

Blocked calls are recorded, and MCP calls record whether they succeeded or failed and how long they took.

## MCP servers

Build each MCP toolset with `revsec_mcp_toolset(name, ...)` so RevSec checks its calls against that server:

```python
github = revsec_mcp_toolset("github", url="https://api.githubcopilot.com/mcp/")
notes = revsec_mcp_toolset("notes", command="npx", args=["-y", "@acme/notes-mcp"])
```

An `McpToolset` you build yourself works too: `note_mcp_server(toolset, "github")`. RevSec never sends the launch
command's other arguments, which can carry tokens.

## Options

```python
RevSecPlugin(
    agent_name="orders-desk",      # default: the root agent's name
    customer_facing=True,          # shown on the agent and used in its risk rating
    description="Handles order questions and refunds",
    owner_email="team@example.com",
    environment="production",
    on_block="message",            # or "raise" to stop the run instead
)
```

With `on_block="raise"`, ADK stops the run with its `RuntimeError`, and `revsec.RevsecBlocked` is its cause.

If RevSec can't be reached, calls go ahead by default, so an outage never stops your product. To block them instead:

```python
import revsec
revsec.mcp.configure(api_key="rsk_...", base_url="https://app.revsec.app/fcc", failure_mode="fail_closed")
```

If your model calls go through the RevSec AI gateway, the gateway already checks prompts, so turn that check off here:

```python
import revsec
revsec.mcp.configure(check_prompts=False)
```

## Requirements

- Python 3.11 or later, and Google ADK 1.18 or later (1.x and 2.x are both tested)
- A RevSec account: [start a free 30-day trial](https://app.revsec.app/start?from=google-adk), no card needed

## Links

- RevSec: https://app.revsec.app/start?from=google-adk
- Source and issues: https://github.com/RevUp-AI/adk-revsec
- The RevSec Python SDK: https://pypi.org/project/revsec-sdk/

Licensed under Apache 2.0. RevSec is a product of RevUp AI LLC.
