Open-source firewall for AI agent tools

A firewall for AI agent tool calls.

Megent checks each Python tool you guard against your policy before it runs—allowing approved calls and blocking the rest.

Apache-2.0Python packageYAML policies
version: "1"default_action: deny tools:  send_email:    allow: true    pii_mask: [email, phone]

The execution boundary

Put a policy check between your agent and its tools.

Megent is an open-source Python firewall you run with your application. It checks the tool functions you guard; there is no hosted dashboard or web service. Keep the policy in your project and inspect the implementation on GitHub.

From policy to execution

Three steps. Your code stays yours.

Keep your agent and tools. Add a policy file and guard the functions that need a decision at runtime.

  1. 01

    Write the rule

    Start with a default action, then explicitly allow the tools your agent needs.

    default_action: deny
  2. 02

    Guard the tool

    Wrap the Python function that performs the action with Megent.

    @mg.guard
  3. 03

    Review decisions

    Use structured audit events to see which calls were allowed or blocked.

    allow · block

Policy controls

Small rules.
Clear decisions.

Keep the first policy readable. Add controls where the workflow needs them.

01

Allow or deny tools

Set a default action and name the tools that may run.

02

Mask configured fields

Apply pattern-based masking to fields such as email addresses and phone numbers.

03

Keep an audit trail

Emit structured events with the tool and policy decision.

04

Add identity and rate limits

Optional JWT identity and per-agent rate limits are available in the runtime.

Know the boundary

Tool-call policy is one layer of security.

Megent governs the calls you wrap. It does not inspect every prompt or model response, and it does not secure the tools themselves. Keep the rest of your application security controls in place.

Common questions

Clear answers before you install.

Read the project README
What does Megent check?

Megent evaluates calls to the Python tool functions you guard. It applies the configured policy before the wrapped function runs. Coverage depends on which functions your agent routes through Megent.

Does Megent replace my agent framework?

No. Megent is a Python runtime layer you add around the tools or execution functions you want to protect. Check your framework's call path and make sure the relevant tool boundary is wrapped.

Can Megent mask sensitive values?

The runtime supports configurable pattern-based masking for fields such as email addresses and phone numbers. Define the fields in your policy and review the behavior against your own data before using it in production.

Does Megent protect every part of an AI system?

No. Megent focuses on policy checks around guarded tool calls. Prompt injection, model output, secrets in prompts, and the tools themselves need their own security controls.

Where does Megent run?

Megent is an open-source Python package that runs with your application. The project is Apache-2.0 licensed. See the repository for current setup instructions and implementation details.

Start small

Put a policy at the tool boundary.

Install the Python package, read the quickstart, and guard one tool function first.

pip install megent

Open the quickstart