Skip to main content

Authorization gateway for AI agent side effects. CapFence lets agents propose tool calls, then enforces deterministic allow, deny, or approval decisions before shell, database, filesystem, payment, API, or MCP execution.

Project description

CapFence

CapFence is the authorization gateway between AI agents and real-world side effects.

Models may propose actions. CapFence decides whether those actions are allowed before execution.

Use CapFence when agents can touch shell commands, databases, filesystems, payment APIs, internal APIs, SaaS admin tools, or MCP servers.

PyPI version Python versions License: MIT CI Status

Agent -> Proposed action -> CapFence -> Gated executor -> Tool

Denied actions do not reach the downstream tool.

Prompts are not security boundaries. CapFence removes the LLM from the authorization path.

First Blocked Action

An ops agent proposes:

rm -rf /var/lib/postgresql

CapFence returns:

Decision: DENY
Reason: destructive production filesystem operation
Tool invoked: false
Replay: capfence replay audit_sample.jsonl --policy policy.yaml

Install

pip install capfence

Try It Locally

Define a policy:

deny:
  - capability: shell.exec.production
    contains: "rm -rf"

allow:
  - capability: shell.exec.readonly

Evaluate before execution:

from capfence import ActionEvent, ActionRuntime

runtime = ActionRuntime.from_policy("policies/shell.yaml")

event = ActionEvent.create(
    actor="ops-agent",
    resource="shell",
    action="exec",
    environment="production",
    payload={"command": "rm -rf /var/lib/postgresql"},
)

verdict = runtime.execute(event)

if not verdict.authorized:
    raise PermissionError(f"Blocked before execution: {verdict.reason}")

Expected result:

decision: DENY
reason: policy_deny
tool_invoked: false

Replay the decision:

capfence replay audit.jsonl --policy policies/shell.yaml

Replay output:

Recorded: shell.exec.production
Original: DENY
Replayed: DENY
Changed:  false

Security Model

CapFence protects the gated tool path.

Recommended architecture:

Agent -> Proposed action -> CapFence -> Gated executor -> Tool

The agent should not hold raw downstream credentials. The executor owns credentials and invokes the tool only after CapFence returns allow.

CapFence is not effective if the agent can call downstream tools directly with raw credentials.

CapFence does not replace sandboxing, secrets management, network controls, IAM, or database-native permissions.

Why Authorization, Not Guardrails?

Prompt guardrails influence what the model says. CapFence controls what the agent is allowed to do.

The security question is not only:

Did the model intend something safe?

The operational question is:

Is this actor authorized to perform this side effect on this resource in this environment?

CapFence is built for that boundary.

How CapFence Is Different

Category What it controls Weakness CapFence difference
Prompt guardrails Model text Soft boundary CapFence controls execution
LLM judges Generated content Probabilistic CapFence uses deterministic policy
Observability Past behavior After the fact CapFence blocks before execution
Sandboxes Process/environment Not business authorization CapFence evaluates action semantics
IAM Service identity Too coarse for agent intent CapFence authorizes each proposed action
Runtime contracts Agent behavior patterns Broad or abstract CapFence focuses on concrete side effects

Use CapFence For

  • shell.exec boundaries before a process is spawned.
  • MCP tool authorization before the upstream server receives a request.
  • Filesystem scope enforcement before secrets or repo-external paths are read.
  • Database write and schema-change controls before queries execute.
  • Payment or API action thresholds before external state changes.

CapFence Is Not

  • An AI governance platform.
  • An observability product.
  • An orchestration framework.
  • A prompt guardrail.
  • An AI judge.
  • A compliance dashboard.

Core Docs

Status

CapFence is pre-1.0 public beta infrastructure. The core local YAML policy runtime is intended for production pilots, while framework adapters, policy packs, external policy backends, and release automation should be validated in your environment before high-risk use.

CapFence controls the gated tool path. It does not replace sandboxing, secrets management, network segmentation, downstream IAM, or database-native controls.

Capability Maturity
Local YAML policy evaluation Beta
Audit hash chaining and replay Beta
LangChain, LangGraph, CrewAI, OpenAI Agents SDK adapters Beta
MCP, PydanticAI, LlamaIndex, AutoGen adapters Experimental
Starter policy packs and OPA backend path Experimental

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

capfence-0.9.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

capfence-0.9.0-py3-none-any.whl (102.8 kB view details)

Uploaded Python 3

File details

Details for the file capfence-0.9.0.tar.gz.

File metadata

  • Download URL: capfence-0.9.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for capfence-0.9.0.tar.gz
Algorithm Hash digest
SHA256 e71a1271fe1d274f60fe1deb9c26f6a2205f67c8075d04683b5e50361cdb0626
MD5 2b34d53304ebe351d1807d2eff7a048e
BLAKE2b-256 3e00d2774fa48e9b200cb7a219a9d3745f6ec6da09d3830a7e2d980feef67317

See more details on using hashes here.

Provenance

The following attestation bundles were made for capfence-0.9.0.tar.gz:

Publisher: release.yml on capfencelabs/capfence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file capfence-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: capfence-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 102.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for capfence-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f21fdde7d35341c229b28d9a1a7b78aa6a2b168b92fe3972bc2c9b81e43aa902
MD5 26bca857aba16ebbe61949cdc42671c1
BLAKE2b-256 aef71e5243137b148c9a7d2ce940a82c272aacb17d89860df2981864f6957e0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for capfence-0.9.0-py3-none-any.whl:

Publisher: release.yml on capfencelabs/capfence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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