Getting started
Core concepts
Aegis is built on five ideas. If you understand them, every design decision in the library follows.
1. A capability spec is one task's permissions
A capability spec is a YAML document that lists exactly which (server, tool, argument, value) combinations one task may use. One spec covers one task. A spec isn't reused across runs, and it is never derived from agent logic or tool output. It is loaded once, before the agent starts.
2. The trust boundary sits before the first tool call
The user's request is trusted, and so is the operator's configuration, such as sandbox_root and the intercept rules. Everything the agent reads while it runs is untrusted: files, web pages, tool responses. Prompt injection arrives through that untrusted channel.
Aegis makes one guarantee here: nothing on the untrusted side of that boundary can change the policy.
3. The enforcement path contains no LLM
An LLM proposes a spec once, from the trusted request, before execution begins. From then on, every tool call is checked against a static spec by plain, deterministic Python. The LLM never sees tool output, and the spec never widens during the run.
This is the design decision everything else rests on. A model that classifies whether a tool call matches the user's intent has the same weakness it's meant to guard against: it reads the attacker's text. Deterministic code reads that text as data, not instructions.
Decisions take microseconds, give the same answer every time, and can be verified by reading the code. A denial you can't reproduce isn't evidence. This one is.
4. Closed world at every level
If the spec doesn't mention something, it isn't allowed. This applies at every level: servers, tools, argument names, argument values, and the type of each value. An unlisted argument isn't "allowed by default". It's unknown, so it's denied. A value type the engine can't reason about, such as a dict or a nested list, is refused rather than coerced.
The cost is verbosity: specs have to name every argument the agent will pass. The proposer handles that work for you.
5. Every decision leaves evidence
Each decision writes an audit record before the outcome goes back to the agent. Records carry a run_id to link them into a run, and a spec_hash (SHA-256 of the raw YAML) to tie each decision to the exact policy that made it. Waivers and weak-posture passes get their own rule ids, so you can find them with a search instead of mistaking them for clean passes.
What Aegis is not
- Not an identity system. It assumes authentication happens upstream and doesn't try to replace it.
- Not a prompt-injection detector. It doesn't classify text. It makes a successful injection unable to cause an out-of-scope action.
- Not a supply-chain control. It has no view of how an MCP server was built or what dependencies it pulls in.
- Not server discovery. It governs the agents it's wired into, and nothing else.
The security page maps all of this against the OWASP MCP Top 10, including the categories Aegis doesn't cover.
The public API
| Symbol | What it does |
|---|---|
wrap_toolset() | Puts Aegis in front of a Pydantic AI MCPToolset. Modifies the toolset in place and returns it. |
AegisConfig | Run configuration: sandbox_root, run_id, otlp_endpoint, approval_callback, response_inspection_mode, and the control-plane fields. |
propose_spec() | Turns a trusted plain-language request into a validated spec. Calls the Anthropic API once. |
load_spec() | Loads and validates a YAML spec from disk, and writes the spec_loaded record. Needs no API key. |
AegisApprovalRequired | Raised on an INTERCEPT when no approval callback is configured. The arguments are on .call_args. |
SpecValidationError | Raised at load time for a missing file, bad YAML, or a schema violation. |
Source of truth: README.md on GitHub. If this page and the repository disagree, the repository wins — and please open an issue.