Agent Guardrail MCP Server

io.github.JarvisOnM4由 GitHub 帳號 JarvisOnM4 發布v0.1.2更新於 Oct 24, 2026

Action-level governance for AI agents -- control what they DO, not what they SAY

已驗證STDIO僅桌面安全與監控AI 與機器學習

概覽

AI 產生的概覽

一個本機 Python 護欄,讓助理依政策規則評估代理動作,回傳允許、拒絕或需審核的決定並記錄日誌。

可以做什麼
依允許清單、拒絕清單、萬用字元樣式、消費上限與風險門檻評估代理擬執行的動作,回傳允許、拒絕或需審核的決定,並寫入 SQLite 飛行記錄器。註冊代理並套用嚴格、適中或寬鬆的政策範本。管理緊急停止開關,並將高風險動作轉交人工審核。檢視已記錄動作、待審核項目與統計資料,並重播工作階段。可選用本機代理 API,使用依代理分配的金鑰與預付評估額度。
適用情境
當你執行具備 shell、檔案、網路或消費權限的自主代理,並希望在每次工具呼叫前做動作層級檢查,而不只是過濾模型輸出時適用。適合 LangChain、CrewAI 或自建代理,需要消費上限、緊急停止與稽核記錄的情境。
執行需求
以 pip 安裝的 Python 套件形式在本機執行;README 稱僅依賴 Python 標準函式庫與 SQLite。可選的代理模式需要 proxy 附加元件與管理金鑰。可選計費需要 Blockonomics API 金鑰與 webhook 密鑰環境變數。清單未宣告任何憑證。
安裝前請注意
護欄只負責判定,實際攔阻取決於代理程式碼是否呼叫並遵守拒絕結果。它會把動作日誌與目標存入本機 SQLite 資料庫。可選計費涉及比特幣付款與預付額度包;未設定 Blockonomics 變數時計費關閉,評估不計費。代理由管理金鑰與代理 API 金鑰保護。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Agent Guardrail MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Agent Guardrail

Action-level governance for AI agents — control what they DO, not what they SAY.

[PyPI] [License: MIT] [Python 3.10+]


The Problem

AI agents are getting tool access. They can run shell commands, make API calls, read files, spend money. But most "guardrails" only filter what agents say — not what they do.

Real incidents:

  • AutoGPT autonomously spent $10K+ on API calls in a single session
  • ChaosGPT attempted to access military systems and recruit other AI agents
  • Air Canada chatbot invented a refund policy that cost the airline $800+

You need action-level control. Not output filtering.

What Agent Guardrail Does

Agent Framework --> Agent Guardrail --> {allow, deny, require_approval}                                    --> Flight Recorder logs everything
  • Policy Engine — allowlists, denylists, glob patterns for tools and targets
  • Spend Caps — daily and total USD limits per agent
  • Kill Switch — instantly deny all actions for a runaway agent
  • Flight Recorder — every action logged with full replay capability
  • Approval Gates — route risky actions to human review
  • Risk Scoring — automatic risk assessment per action type
  • 3 Templates — restrictive, moderate, permissive (apply in one command)
  • Pay-per-eval Billing — free tier + BTC credit packs via Blockonomics

Zero dependencies. Python stdlib only. SQLite for storage.

30-Second Quickstart

bash
pip install agent-guardrail
# Register an agentagent-guardrail register "my-research-agent" --framework langchain
# Apply the moderate policy templateagent-guardrail apply-template moderate <agent-id>
# Test itagent-guardrail eval <agent-id> bash --target /workspace/test.sh     # -> allowagent-guardrail eval <agent-id> bash --target /etc/shadow             # -> denyagent-guardrail eval <agent-id> sudo                                  # -> deny

Python API

python
from agent_guardrail import GuardrailStore, PolicyEngine, DEFAULT_POLICIES
# Initializestore = GuardrailStore()  # ~/.agent-guardrail/guardrail.dbengine = PolicyEngine(store)
# Register agentagent = store.register_agent("my-agent", framework="langchain")
# Apply policy templatestore.save_policy({    "name": "moderate",    "agent_id": agent["id"],    "rules": DEFAULT_POLICIES["moderate"]["rules"],})
# Evaluate actionsdecision = engine.evaluate(agent["id"], "bash", target="/workspace/run.sh")# -> PolicyDecision(decision="allow", risk_score=0.7)
decision = engine.evaluate(agent["id"], "bash", target="/etc/shadow")# -> PolicyDecision(decision="deny", reason="Target '/etc/shadow' is denied...")
# Evaluate + record to flight recorderdecision = engine.evaluate_and_record(    agent_id=agent["id"],    action_type="api_call",    tool_name="openai_chat",    cost_usd=0.05,    session_id="session-123",)

Framework Integrations

LangChain Callback

python
from agent_guardrail import GuardrailStore, PolicyEngine
class GuardrailCallback:    """Drop into any LangChain agent as a callback handler."""    def __init__(self, agent_id, db_path=None):        self._engine = PolicyEngine(GuardrailStore(db_path=db_path))        self.agent_id = agent_id
    def on_tool_start(self, serialized, input_str, **kwargs):        decision = self._engine.evaluate_and_record(            agent_id=self.agent_id,            action_type="tool_call",            tool_name=serialized.get("name"),            target=input_str[:200],        )        if decision.decision == "deny":            raise PermissionError(f"Guardrail: {decision.reason}")

CrewAI Task Guardrail

python
from agent_guardrail import GuardrailStore, PolicyEngine
def make_guardrail(agent_id, db_path=None):    engine = PolicyEngine(GuardrailStore(db_path=db_path))
    def check(task_output):        decision = engine.evaluate_and_record(            agent_id=agent_id, action_type="task_output",            target=str(task_output)[:200],        )        if decision.decision == "deny":            return (False, f"Blocked: {decision.reason}")        return (True, task_output)    return check
# task = Task(description="...", guardrail=make_guardrail("agent-id"))

Universal Decorator

python
from agent_guardrail import GuardrailStore, PolicyEngineimport functools
def guardrail(agent_id, action_type="function_call", db_path=None):    engine = PolicyEngine(GuardrailStore(db_path=db_path))    def decorator(func):        @functools.wraps(func)        def wrapper(*args, **kwargs):            target = str(args[0])[:200] if args else None            decision = engine.evaluate_and_record(                agent_id=agent_id, action_type=action_type,                tool_name=func.__name__, target=target,            )            if decision.decision == "deny":                raise PermissionError(f"Guardrail: {decision.reason}")            return func(*args, **kwargs)        return wrapper    return decorator
@guardrail("my-agent", action_type="bash")def run_command(cmd):    ...

Hosted API (For Agents)

The library is for humans. The API is for agents.

An orchestrator running 5 sub-agents doesn't pip install — it calls an endpoint.

bash
# Start the proxy serverpip install agent-guardrail[proxy]guardrail-proxy --port 8300 --admin-key YOUR_ADMIN_KEY
bash
# Register an agent (admin)curl -X POST http://localhost:8300/v1/agents \  -H "X-Admin-Key: YOUR_ADMIN_KEY" \  -d '{"name": "research-agent", "framework": "crewai"}'
# Evaluate an action (agent)curl -X POST http://localhost:8300/v1/evaluate \  -H "X-API-Key: gw_agent_key_here" \  -d '{    "agent_id": "...",    "action_type": "bash",    "tool_name": "shell",    "target": "/etc/shadow",    "cost_usd": 0.0  }'# -> {"decision": "deny", "reason": "Target denied...", "risk_score": 0.7}

Full API docs at http://localhost:8300/docs (Swagger UI).

Billing & Pricing

Free tier included. Pay with Bitcoin when you need more.

TierEvaluationsPricePer Eval
Free100/day per agent$0$0
Starter1,000$10$0.010
Growth5,000$40$0.008
Scale25,000$150$0.006

Credits are prepaid and never expire. Admin-authenticated requests bypass billing entirely.

How it works:

bash
# Check your balancecurl http://localhost:8300/v1/billing/balance \  -H "X-API-Key: gw_your_agent_key"
# Buy credits (returns a BTC address + amount)curl -X POST http://localhost:8300/v1/billing/checkout \  -H "X-API-Key: gw_your_agent_key" \  -d '{"pack_id": "pack_1000"}'# -> {"btc_address": "bc1q...", "amount_btc": 0.00015, "amount_satoshi": 15000, ...}
# Pay the BTC address -> webhook confirms -> credits granted automatically

When free tier is exhausted and no credits remain, /v1/evaluate returns 402 Payment Required with a link to available packs.

Self-hosted billing: Set BLOCKONOMICS_API_KEY and BLOCKONOMICS_WEBHOOK_SECRET environment variables. Without these, billing is disabled and all evaluations proceed without metering (backward compatible).

Policy Rules Reference

python
{    "tool_allowlist": ["read_file", "write_file"],    # Only these tools allowed    "tool_denylist": ["sudo", "rm", "delete*"],       # These tools always denied    "target_allowlist": ["/workspace/*"],              # Only these targets allowed    "target_denylist": ["/etc/*", "*.env", "*.key"],   # These targets always denied    "network_allowlist": ["api.openai.com"],           # Allowed network targets    "network_denylist": ["*"],                         # Denied network targets    "spend_cap_daily_usd": 25.0,                      # Daily spend limit    "spend_cap_total_usd": 500.0,                     # Lifetime spend limit    "require_approval": ["bash", "install"],           # Human approval required    "risk_threshold": 0.8,                             # Auto-approval gate}

Patterns support glob matching (*, ?, [abc]).

Decision Flow

Kill switch? ──deny──> DENY      |Agent enabled? ──no──> DENY      |Spend cap? ──exceeded──> DENY      |Tool denylist? ──match──> DENY      |Target denylist? ──match──> DENY      |Approval required? ──match──> REQUIRE_APPROVAL      |Risk threshold? ──exceeded──> REQUIRE_APPROVAL      |Tool allowlist? ──not in list──> DENY      |Target allowlist? ──not in list──> DENY      |DEFAULT ──> ALLOW

Architecture

+-------------------+     +------------------+     +-----------------+|  Agent Framework  |---->|  Billing Check   |---->|  Policy Engine  ||  (LangChain,     |     |  (free tier /    |     |  (evaluate)     ||   CrewAI, custom) |     |   credits)       |     +-----------------++-------------------+     +------------------+            |                                 |                        v                                 |           +------------------------+                          402 if empty       |  Decision:             |                                             |  allow / deny /        |                                             |  require_approval      |                                             +------------------------+                                                         |                                                         v                                             +-----------------+                                             |  Flight Recorder|                                             |  (SQLite)       |                                             +-----------------+
+-------------------+     +------------------+|  BTC Payment      |---->|  Blockonomics    ||  (checkout)       |     |  (xpub-derived   |+-------------------+     |   addresses)     |                          +------------------+                                 |                          webhook (status=2)                                 |                                 v                          +------------------+                          |  Credit Grant    |                          |  (billing_ledger)|                          +------------------+

Comparison

FeatureAgent GuardrailGuardrails AINeMo GuardrailsDIY
Action-level controlYesNo (output only)No (dialogue only)Manual
Spend capsYesNoNoManual
Kill switchYesNoNoManual
Flight recorderYesNoNoManual
Pay-per-eval billingYes (BTC)NoNoManual
Zero dependenciesYesNo (many)No (many)Varies
Framework agnosticYesLangChain-focusedLangChain-focusedYes
Hosted APIYesCloud onlyNoManual

CLI Reference

agent-guardrail agents                      # List registered agentsagent-guardrail register "name"             # Register a new agentagent-guardrail kill <agent_id>             # Emergency kill switchagent-guardrail unkill <agent_id>           # Revoke kill switchagent-guardrail policies                    # List policiesagent-guardrail apply-template <template> <agent_id>agent-guardrail actions [--agent X] [--decision deny]agent-guardrail replay <session_id>         # Session replayagent-guardrail approvals                   # Pending approvalsagent-guardrail approve <id>                # Approve actionagent-guardrail deny <id>                   # Deny actionagent-guardrail eval <agent_id> <type> [--target X] [--cost 0.5]agent-guardrail stats                       # Statistics

Configuration

VariableDefaultPurpose
GUARDRAIL_DB~/.agent-guardrail/guardrail.dbSQLite database path
GUARDRAIL_LOG_DIR~/.agent-guardrail/logsCLI log directory
GUARDRAIL_ADMIN_KEY(none)Admin API key for proxy
BLOCKONOMICS_API_KEY(none)Blockonomics Store API key (enables billing)
BLOCKONOMICS_WEBHOOK_SECRET(none)Secret for webhook verification
GUARDRAIL_BILLING_ENABLEDtrueSet false to disable billing even with API key

License

MIT

來源:README.md,提交 9f74ba7

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分