The Sudo Command for AI Agents. Local governance, atomic locking, and stable fingerprinting for MCP tools.
Project description
Nexus Governance 🛡️
The sudo command for AI Agents.
Nexus is a high-performance, local governance layer for the Model Context Protocol (MCP). It intercepts tool calls, fingerprints them, and enforces human-in-the-loop (HITL) approval before any critical code executes.
Threat model (in plain English):
- Agents can propose actions.
- Humans approve risky actions.
- Nexus prevents unsafe concurrency + records decisions.
📋 Table of Contents
Why Nexus?
You wouldn't let a junior intern run DROP TABLE, deploy firmware, or rotate secrets without review. Why let an LLM?
- 🔒 Atomic Safety: Prevents race conditions. If three agents try to deploy to the same server simultaneously, Nexus serializes approvals per
(tool, target)(configurable), so competing deploys can't interleave. - 🔑 Secret-Agnostic Approvals: Nexus "scrubs" sensitive data (API keys, tokens) before hashing. If your API key rotates, the approval fingerprint remains valid.
- 🚀 Local-first: Runs in-process; no external service required (SQLite state store).
- 🖥️ Built-in TUI (Approval console): Includes a terminal-based dashboard to monitor and approve requests in real-time.
- Fingerprinting: Every tool call becomes a deterministic fingerprint (scrubbed + hashed) so approvals are reusable and safe.
- 🧾 Audit trail: Every request + decision is recorded with timestamps and actor identity (operator / process, where available).
Live Demo: Try it yourself
Experience the governance flow in 60 seconds.
1. Run the simulation
Included in examples/demo.py is a script that simulates two agents:
- The Intern: Has no permissions.
- The Admin: Has permissions, but calls a "Critical" tool.
uv run examples/demo.py
What you will see:
- ⛔ Intern: Immediately blocked (
ACCESS DENIED). - ✋ Admin: Blocked by Nexus policy. Returns a JSON object:
{
"nexus": {
"status": "PENDING",
"instruction": "retry_same_call"
}
}
2. The "Sudo" Moment
Open a new terminal and launch the governance dashboard:
nexus
You will see the pending request for deploy_firmware.
- Select the request.
- Press A to Approve.
3. Re-run the simulation
Go back to your first terminal and run the script again:
uv run examples/demo.py
What you will see:
- 🎉 Admin: The exact same call now succeeds!
[SYSTEM] ✅ Deployment verified and complete.
Installation
# Via pip
pip install nexus-governance
# Via uv (Recommended)
uv add nexus-governance
Quickstart
Here is how to protect your own MCP tools.
from mcp.server.fastmcp import FastMCP
from nexus.adapter import NexusAdapter, NexusEngine
# 1. Initialize Engine & MCP
engine = NexusEngine(db_path="nexus.db")
mcp = FastMCP("CriticalOps")
# 2. Bind the Adapter
nexus = NexusAdapter(mcp, engine)
# 3. Define a Protected Tool
@nexus.tool(danger="critical")
async def deploy_firmware(version: str, target: str):
# ✋ This code will NOT run until a human approves it.
print(f"Deploying {version} to {target}...")
return "Success"
if __name__ == "__main__":
mcp.run()
The Agent Experience
When an agent calls this tool, it receives a PENDING signal instead of a result. It is instructed to wait or retry, preventing hallucinated success. For critical tools, Nexus encourages idempotent operations or target-scoped locks.
Architecture
nexus.core: The kernel. Handles SQLite locking, state machine transitions, and fingerprint logic.nexus.adapter: The integration layer. Currently supportsmcp.server.fastmcp.nexus.cli: The Textual-based TUI for monitoring and approvals.
Nexus sits between the MCP server and tool handlers — tools are only exposed via the adapter, making bypass impossible without code changes.
Additional adapters (non-MCP runtimes, remote agents) can be added without changing the core engine.
How Fingerprinting Works
Nexus generates a deterministic hash for every tool call.
- Scrubbing: It detects arguments that look like secrets (e.g.,
sk-proj-...) and replaces them with<REDACTED>. - Stability:
deploy(key="A")anddeploy(key="B")generate the same fingerprint. You approve the action, not the credential.
License
MIT © Zishan Neno
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexus_governance-0.1.0.tar.gz.
File metadata
- Download URL: nexus_governance-0.1.0.tar.gz
- Upload date:
- Size: 79.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75057be6115a0a33726dd9a67be8d721aeda4ad32ec4b197167581ca8790af41
|
|
| MD5 |
b1fb0d79de4a51d563a018686a1fb951
|
|
| BLAKE2b-256 |
0a207121f3cd6e6a0cc6a7b07c43178cd7ef40aa3559ebe8f65b7912ae9af7ce
|
File details
Details for the file nexus_governance-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nexus_governance-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ffb2a0153cbdd818701f9a71d9400ece681e1327eca8200a5c281327dc8a7f1
|
|
| MD5 |
788c40f653991c6a6b084e79f56cf208
|
|
| BLAKE2b-256 |
14176e0744ecb380d72b77fcba132f77c03f2ab0fcbf1b340b33ea1dad4d6bd4
|