Skip to main content

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 policy
  • approve(approval_id) — Approve a pending action
  • deny(approval_id) — Deny a pending action
  • wait_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.3.0.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentguardproxy-0.3.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file agentguardproxy-0.3.0.tar.gz.

File metadata

  • Download URL: agentguardproxy-0.3.0.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agentguardproxy-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1f938783af43afc1a0f3594c0bfea57a81118216c5b19ad6ff8d178963cec6cb
MD5 c87776a29f968d347645bc6cfae365bd
BLAKE2b-256 e400302c7fe33661d30c4b8a1e6929ab3f6bf0ab876c1b9d46f1b91b334e4daf

See more details on using hashes here.

File details

Details for the file agentguardproxy-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentguardproxy-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 723267271058395c03be749b104ec850353c8eba9b0e2bab92a54e9165376654
MD5 06527f01717a10e547e3024a26daad33
BLAKE2b-256 e12f0d7bb4d4bd8641635a050496119be6c22ba38adc181bc74bd321494f9e21

See more details on using hashes here.

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