AI Security · Full Stack · SaaS

Agent Monitor — Local Security Boundary for AI Agents & MCP

Local-first activity monitor, deterministic policy gate, and universal security boundary for autonomous AI agents and Model Context Protocol (MCP) clients.

Agent Monitor — Local Security Boundary for AI Agents & MCP — Overview

Challenge

Autonomous AI agents and MCP tool integrations operate with broad system privileges, posing severe risks including unauthorized file system manipulation, prompt-injection privilege escalation, and unmonitored external network exfiltration.

Solution

Designed an in-line deterministic policy engine and real-time activity monitor that intercepts every tool call schema, verifies authorization boundaries, facilitates instant human-in-the-loop approvals, and records tamper-evident, SHA-256 hash-chained audit logs.

Outcome

Delivered a zero-latency, local-first safety layer providing absolute visibility and deterministic policy enforcement across MCP clients and agentic AI runtime environments.

Architecture

Hover or tap a component to see what it does.

AI agent / MCP client: Any agent that calls tools. It talks to Agent Monitor instead of the tool directly — no code changes needed.

Key decisions

Rules instead of an LLM judge?

A security gate must give the same answer every time and can't be prompt-injected. Rules are fast, testable and explainable.

SQLite instead of Postgres?

It's local-first: zero setup, one file. WAL mode lets the dashboard read while the gate writes.

SSE instead of WebSockets?

The dashboard only needs a one-way event stream. SSE is plain HTTP and reconnects on its own.

Why re-check after approval?

Between asking and approving, the policy, kill switch or action could change. Stale or tampered approvals are rejected.

Results

  • Every tool call passes a 14-stage check before it runs
  • Drop-in for any MCP client — no app changes
  • Audit log verifiable with one command
  • 200+ automated tests, incl. adversarial bypasses
Read the detailed study

Overview

Agent Monitor is a zero-trust, local-first security platform for autonomous AI agents and Model Context Protocol (MCP) clients. It sits between the agent and its tools as a transparent policy gate: every tool call is intercepted, evaluated by deterministic rules, and either allowed, blocked, or paused for a human — before anything executes.

It lets developers give agents real capabilities (file writes, shell commands, network access) while keeping full visibility, rate limits, secret redaction and a tamper-evident record of everything the agent did.

The problem

Coding agents and MCP servers run with the same privileges as the developer. A single prompt injection hidden in a README or web page can make an agent read .env files, push code, or send data to an external server. Most agent runtimes log after the fact; they don't stop the action.

MCP adds a second risk: tools are discovered at runtime, so a server can change a tool's schema or behaviour after it has been trusted (a 'rug-pull').

How a tool call flows

1. Payload bounds — oversized frames (10MB) and arguments (1MB) are rejected. 2. Kill switch — an authoritative flag in SQLite that halts everything instantly. 3. Source quarantine — calls from a quarantined MCP server are blocked, and quarantine survives restarts. 4. Rate limiting — a sliding window stops command floods.

5. Normalization — raw MCP calls, shell commands and resource URIs are mapped to typed canonical actions, with RFC 8089 file-URI handling. 6. Workspace guardrails — path traversal, symlink escapes, null bytes, multi-layer URL encoding, Unicode tricks and Windows/UNC escapes are all contained. 7. Risk assessment — a 0–100 score from CWE-mapped rules, plus a check that the tool's schema fingerprint hasn't changed.

8. Policy evaluation — versioned policies with additive specificity; when rules conflict, DENY beats ASK beats ALLOW. 9. Human approval for ASK, from the terminal or web dashboard. 10. Post-approval revalidation — the approved action's context hash, expiry, active policy version, kill switch and quarantine are all checked again.

11. Execution with a bounded timeout. 12. Result inspection — API keys, AWS credentials, JWTs and private keys are replaced with [REDACTED:<type>], and responses over 500KB are truncated. 13. Persistence to SQLite with SHA-256 hash chaining. 14. Automatic incident creation for critical violations, and live dispatch to connected clients.

Design decisions in depth

Deterministic, not probabilistic. Using an LLM to judge whether an LLM's action is safe just moves the prompt-injection problem one level up. The policy engine is synchronous, rule-based code with no model calls, so the same input always produces the same decision — and every decision comes with an explainable risk breakdown.

Local-first storage. Security tooling that requires a cloud account or a database server doesn't get installed. SQLite in WAL mode gives a single-file store with concurrent reads, a 5s busy timeout, and transactional migrations. Approvals are resolved with a conditional UPDATE (… WHERE status = 'pending'), so only one resolver can ever win — no race conditions between terminal and web.

Tamper-evident audit. Each event stores the hash of the previous event. JSON is canonicalized (sorted keys) before hashing so the same event always hashes the same way. 'agent-monitor audit verify' walks the chain and reports any break.

Two entry points, one invariant. The MCP gateway protects third-party agents without touching their code; the in-process interceptor protects agents built on Agent Monitor's own runtime. Both run the same 14-stage pipeline from a dependency-free core package.

Codebase structure

A TypeScript monorepo with six packages: core (pure domain logic — normalizer, risk and policy engines, sequence engine, fingerprinting, hash chaining, secret redaction; zero external dependencies), server (SQLite persistence, migrations, kill switch, incidents, event bus and SSE), agent (guardrails, safe tools, interceptor, approval manager and a reference DeepSeek coding agent), gateway (the MCP stdio proxy), cli, and web (the Next.js dashboard).

Key Features & Capabilities

Feature 01

Deterministic Tool Execution Policy Gating

Feature 02

Zero-Trust Local-First Microsecond Telemetry

Feature 03

Human-in-the-Loop Approval Interceptors

Feature 04

Model Context Protocol (MCP) Client Compatibility

Feature 05

Immutable Audit Trails & Security Violation Detection

Explore More Projects & Systems

All Projects →

01 / Marketplace

Briz Market — Local Shopping Marketplace for Nepal

Built the web version of Briz (brizmarket.com), a local marketplace already live as an iOS and Android app, where shoppers in Nepal find products and stores nearby and get offers from local sellers. Phase 1 of the web app launched on 9 October 2026; it will grow into the full product in phases.

02 / Full Stack

Tracky — Multi-Tenant Issue Management System

Architected a multi-tenant issue and bug management platform with eight role-based dashboards, JWT auth with rotating refresh tokens, real-time WebSocket notifications, and a partner API for external integrations.

03 / AI

Lumen — AI Marketing OS & Agent Suite

Built an integrated AI marketing platform combining a dynamic context chat agent (`aiagent`) with a full-featured Marketing Operating System SaaS (`marketingtool`) featuring multi-LLM routing, generative UI, Cloudinary asset pipelines, landing page builders, and automated lead capture.