Python SDK for AgentGuard — the firewall for AI agents
Project description
AgentGuard Python SDK
Lightweight Python client for AgentGuard — the firewall for AI agents.
Install
pip install agentguardproxy
# With framework adapters
pip install agentguardproxy[langchain]
pip install agentguardproxy[crewai]
pip install agentguardproxy[browser-use]
pip install agentguardproxy[all]
Quick Start
from agentguard import Guard
guard = Guard("http://localhost:8080", agent_id="my-agent")
# Check before executing
result = guard.check("shell", command="rm -rf ./old_data")
if result.allowed:
execute(command)
elif result.needs_approval:
print(f"Approve at: {result.approval_url}")
else:
print(f"Blocked: {result.reason}")
Framework Adapters
LangChain
from agentguard.adapters.langchain import GuardedToolkit
toolkit = GuardedToolkit(
tools=my_tools,
guard_url="http://localhost:8080",
agent_id="langchain-agent",
)
agent = create_react_agent(llm, toolkit.tools, prompt)
CrewAI
from agentguard.adapters.crewai import guard_crew_tools
guarded_tools = guard_crew_tools(
tools=my_crew_tools,
guard_url="http://localhost:8080",
agent_id="crew-agent",
)
browser-use
from agentguard.adapters.browseruse import GuardedBrowser
browser = GuardedBrowser(guard_url="http://localhost:8080")
result = browser.check_navigation("https://example.com")
if result.allowed:
await page.goto("https://example.com")
MCP
from agentguard.adapters.mcp import GuardedMCPServer
server = GuardedMCPServer(guard_url="http://localhost:8080")
server.add_tool("my_tool", "Description", handler=my_handler)
server.run() # Starts stdio MCP server
API Reference
Guard(base_url, agent_id="")
check(scope, *, action, command, path, domain, url, meta)— Check an action against policyapprove(approval_id)— Approve a pending actiondeny(approval_id)— Deny a pending actionwait_for_approval(approval_id, timeout=300)— Block until resolved
CheckResult
.allowed— True if action is permitted.denied— True if action is blocked.needs_approval— True if human approval required.decision— Raw decision string.reason— Explanation.approval_url— URL to approve (when applicable)
@guarded(scope, guard=None) decorator
Wraps a function so it's checked before execution.
License
Apache 2.0
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
agentguardproxy-0.4.0.tar.gz
(14.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentguardproxy-0.4.0.tar.gz.
File metadata
- Download URL: agentguardproxy-0.4.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faec3bd6c33b674796aafd471a34b1d06ba0152b310b4f90c740ffe6a8a87ddf
|
|
| MD5 |
0d749279299630ec0a0981d96eb9bb2f
|
|
| BLAKE2b-256 |
8c9c081ededf33283fcdc83fa9470bf560b1115d9f9dd6d7081f74c68df97d90
|
File details
Details for the file agentguardproxy-0.4.0-py3-none-any.whl.
File metadata
- Download URL: agentguardproxy-0.4.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ead1c169bc4e48b79463a7a3c5410b9e95a262e16a14cf1d422cb3b7cda08eab
|
|
| MD5 |
29a36167708d4e0c38d5f7f286f62690
|
|
| BLAKE2b-256 |
ec960873c1a423c328616ccb0c306a4af186fe5e52eeda27c3a1525fb5940fc3
|