Skip to main content

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:

  1. Intern: Immediately blocked (ACCESS DENIED).
  2. 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.

  1. Select the request.
  2. 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 supports mcp.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.

  1. Scrubbing: It detects arguments that look like secrets (e.g., sk-proj-...) and replaces them with <REDACTED>.
  2. Stability: deploy(key="A") and deploy(key="B") generate the same fingerprint. You approve the action, not the credential.

License

MIT © Zishan Neno

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

nexus_governance-0.1.0.tar.gz (79.1 kB view details)

Uploaded Source

Built Distribution

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

nexus_governance-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

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

Hashes for nexus_governance-0.1.0.tar.gz
Algorithm Hash digest
SHA256 75057be6115a0a33726dd9a67be8d721aeda4ad32ec4b197167581ca8790af41
MD5 b1fb0d79de4a51d563a018686a1fb951
BLAKE2b-256 0a207121f3cd6e6a0cc6a7b07c43178cd7ef40aa3559ebe8f65b7912ae9af7ce

See more details on using hashes here.

File details

Details for the file nexus_governance-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nexus_governance-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ffb2a0153cbdd818701f9a71d9400ece681e1327eca8200a5c281327dc8a7f1
MD5 788c40f653991c6a6b084e79f56cf208
BLAKE2b-256 14176e0744ecb380d72b77fcba132f77c03f2ab0fcbf1b340b33ea1dad4d6bd4

See more details on using hashes here.

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