@sparkysolutions/agentsentinel
v0.1.0
Published
Universal zero-trust runtime security firewall and AST policy interceptor for AI agents, MCP servers, and autonomous tool execution.
Maintainers
Readme
🛡️ AgentSentinel
The Universal Zero-Trust Security Firewall & Runtime Guard for AI Agents & Model Context Protocol (MCP)
Languages: English | हिन्दी (Hindi) | Español (Spanish)
📈 QUANTITATIVE & HFT EDITION FOR ALGORITHMIC TRADING DESKS
Protect autonomous AI trading swarms from reflexive cascading liquidations, runaway execution loops, and catastrophic market slippage. Benchmarked at sub-millisecond (< 500µs) deterministic AST interception.
📄 Read Institutional Quant Whitepaper • 🌐 Global B2B Quant Playbook • ⚖️ SEC Rule 15c3-5 & MiFID II RTS 6 Compliant
[!TIP] 🚀 Deploying AI Agents or Quant Swarms in Production?
Protect your infrastructure against prompt injection, database purges, and runaway fund loss with zero-trust AST circuit breakers.
🔗 Book a 15-Minute Private Pilot / Demo • 💻 Run Live Interactive Exploit Demo:npm run demo• 💬 Direct Channel: [email protected]
⚡ Overview
As autonomous AI agents, coding assistants (Cursor, Devin, Claude Code), and Model Context Protocol (MCP) tools proliferate, agents gain direct execution access to terminal commands, relational databases, filesystems, and internal APIs.
AgentSentinel provides a lightweight, sub-2ms, zero-dependency runtime security firewall that intercepts every tool call before execution. It inspects abstract syntax trees (ASTs), regex signatures, and behavioral limits to enforce strict security boundaries:
- Terminal & Shell Defense: Blocks recursive wiping (
rm -rf /), raw disk formats (mkfs,dd), fork bombs, reverse shells, and base64-obfuscated execution. - SQL & Database Defense: Intercepts unconstrained queries (
DROP TABLE,TRUNCATE,DELETE/UPDATEwithoutWHERE), and stacked injection attacks. - Filesystem Confinement: Blocks path traversal (
../../), sensitive directory introspection (/etc/shadow,~/.ssh,SAM), and enforces root workspace jails. - Secret & PII Redaction: Client-side zero-telemetry scanning for AWS keys, GitHub PATs, private keys, Credit Card Luhn verification, SSN, and Aadhaar numbers.
- Framework Middleware: First-class plug-and-play middleware for MCP, Vercel AI SDK, LangChain, and standalone TypeScript/Node.js agents.
🚀 Quickstart Guide
1. Installation
Install via npm or your preferred package manager:
npm install @agentsentinel/coreInitialize an enterprise policy in your project repository:
npx agentsentinel init
# Created security policy configuration: ./agentsentinel.policy.json2. Standalone Runtime Evaluation
Intercept tool execution before dispatching to system primitives:
import { SentinelEngine, Verdict } from '@agentsentinel/core';
import { createDestructiveDeletionRule } from '@agentsentinel/core';
const engine = new SentinelEngine();
engine.registry.register(createDestructiveDeletionRule());
// Intercept tool call before running
const result = await engine.evaluate({
id: 'call_01',
toolName: 'bash:execute',
category: 'shell',
params: { command: 'rm -rf / --no-preserve-root' },
timestamp: Date.now()
});
if (result.verdict === Verdict.BLOCK) {
console.error('🚫 Blocked dangerous command:', result.violations[0].reason);
} else {
// Execute safely
}3. Model Context Protocol (MCP) Middleware
Wrap your MCP server handlers with zero-trust firewall policy:
import { createMcpInterceptor, SentinelEngine } from '@agentsentinel/core';
const engine = new SentinelEngine();
const mcpGuard = createMcpInterceptor(engine, {
denyTools: ['admin_wipe_cluster'],
errorMode: 'tool_result_error',
});
// Wrap existing MCP tool handler
const safeBashHandler = mcpGuard.wrapToolHandler('bash_exec', async (args) => {
return { stdout: await executeShell(args.command) };
});
// Prohibited calls return formatted MCP error results with isError: true
const response = await safeBashHandler({ command: ':(){ :|:& };:' });
// { isError: true, content: [{ type: 'text', text: '[AgentSentinel MCP Guard] ...' }] }4. Vercel AI SDK Integration
Protect an entire dictionary of Vercel AI SDK tools in a single line:
import { tool } from 'ai';
import { z } from 'zod';
import { protectVercelTools, SentinelEngine } from '@agentsentinel/core';
const engine = new SentinelEngine();
const rawTools = {
runCommand: tool({
description: 'Execute shell command',
parameters: z.object({ command: z.string() }),
execute: async ({ command }) => ({ output: `Ran: ${command}` }),
}),
queryDatabase: tool({
description: 'Query database',
parameters: z.object({ query: z.string() }),
execute: async ({ query }) => ({ rows: [] }),
}),
};
// Guard all tools with AgentSentinel
export const tools = protectVercelTools(rawTools, { engine });5. LangChain StructuredTool Integration
Guard LangChain tools against malicious tool parameters:
import { DynamicStructuredTool } from '@langchain/core/tools';
import { z } from 'zod';
import { wrapLangChainTool, SentinelEngine } from '@agentsentinel/core';
const engine = new SentinelEngine();
const calculatorTool = new DynamicStructuredTool({
name: 'db_tool',
description: 'Executes SQL on DB',
schema: z.object({ query: z.string() }),
func: async ({ query }) => 'query results...',
});
// Wrap tool with policy guard
export const guardedTool = wrapLangChainTool(calculatorTool, {
engine,
returnDirectOnError: true, // Returns violation explanation to agent rather than crashing chain
});6. Command-Line Interface (CLI)
AgentSentinel includes a zero-dependency CLI for auditing scripts, SQL files, and logs in CI/CD pipelines:
# Audit a shell script before execution (Exit code 0 on clean, 1 on blocked)
agentsentinel audit ./scripts/deploy.sh
# Audit a SQL migration file for unconstrained DROP or DELETE statements
agentsentinel audit ./migrations/v2_patch.sql
# Test an inline command with JSON output
agentsentinel check --cmd "rm -rf /" --format json
# Audit an AgentSentinel structured audit log
agentsentinel audit-log ./logs/agent_audit.jsonl📈 Quantitative & HFT Algorithmic Defense (Trading Swarms)
In the wake of multi-billion dollar algorithmic market cascades, quantitative hedge funds, HFT firms, and autonomous market makers deploy AgentSentinel Quantitative Edition as a deterministic, sub-millisecond AST circuit breaker between AI models (LLM / RL) and execution venues (DEX, CEX, FIX adapters).
5 Quantitative Execution Tripwires:
- Dynamic Slippage & Liquidity Shock Cutoff: Enforces mathematical boundaries on price impact, blocking market orders attempting to cross thin order books during liquidity-drain spikes.
- Runaway Loop & Velocity Limiter: Detects algorithmic loop deadlocks and partial-fill re-quote traps, throttling rogue subagents before triggering exchange-level rate-limit bans or margin liquidations.
- Web3 Fee & Rent Overflow Protection: Intercepts Soroban (
minResourceFee,rentPerKb) and EVM gas simulation payloads, preventing uint32 integer overflow crashes and wallet exhaustion. - Destructive Tool & Order Redaction: Halts unauthorized mass order cancellations, balance dumps, or credential exfiltration attempts.
- 100% Air-Gapped Zero-Telemetry Execution: Runs strictly inside your private VPC or bare-metal co-located racks. Zero bytes leave your infrastructure.
import { SentinelEngine, createSorobanFeeSurgeGuardRule, Verdict } from '@agentsentinel/core';
const quantGuard = new SentinelEngine();
quantGuard.registerRule(createSorobanFeeSurgeGuardRule({
maxAllowedFeeXlm: 10, // Hard-cap transaction fee ceiling
maxRentPerKbStroops: 50_000n, // Max allowable state rent
enableUint32OverflowProtection: true // Prevent uint32 simulation crashes
}));
// Intercept tool call before order reaches exchange socket
const audit = await quantGuard.evaluate(tradeOrderToolContext);
if (audit.verdict === Verdict.BLOCK) {
console.error('🚨 Order blocked by circuit breaker:', audit.violations[0].reason);
}For full technical specifications, architecture diagrams, and institutional licensing, consult:
📊 Performance Benchmarks
AgentSentinel is engineered for ultra-low latency with zero runtime dependencies:
| Metric | Target SLA | Benchmark Performance | |---|---|---| | Mean Latency | $< 2.0\text{ ms}$ | $0.125\text{ ms}$ ($125\ \mu\text{s}$) | | Median (p50) | $< 1.0\text{ ms}$ | $0.110\text{ ms}$ ($110\ \mu\text{s}$) | | 95th Percentile (p95) | $< 3.0\text{ ms}$ | $0.280\text{ ms}$ ($280\ \mu\text{s}$) | | Throughput | $> 2,000\text{ ops/sec}$ | $\sim 8,000\text{ ops/sec}$ | | Network Egress | Zero | $0\text{ bytes}$ (Air-Gapped Client-Side) |
Detailed benchmark methodology and percentiles are documented in BENCHMARKS.md. System architecture specifications are available in ARCHITECTURE.md. For violation diagnostics and false-positive calibration, consult TROUBLESHOOTING.md. Walkthrough examples are available for Claude Desktop MCP and Cursor AI.
💖 Sponsorship & Multi-Rail Backing
AgentSentinel is an independent open-source zero-trust security framework. You can financially sponsor ongoing security research, zero-telemetry defense rules, and Soroban tripwire tooling via multi-rail fiat or Web3 channels:
| Rail | Destination / Explorer Link | Payment Type |
|---|---|---|
| 🇮🇳 Instant Fiat (UPI / Cards) | Pay via Razorpay Portal | 1-Click UPI (GPay, PhonePe, Paytm), RuPay, Cards |
| ⭐ Stellar & Soroban (USDC / XLM) | GDDJH64X5VEXI7UWZMJA3YUG7ANYHKRRRFHLD2SF5OWEETNFBVYMRXZT | USDC, XLM, Soroban Grants & Developer Tips |
| 🌐 EVM (MegaETH / Base / Ethereum) | 0x40B7d9273092822341860F5610168861351e71eb | USDC, USDT, ETH on MegaETH / Base / Ethereum |
| ❤️ GitHub Sponsors | github.com/sponsors/sparkysolutions10-pixel | Official GitHub Sponsor Dashboard |
📚 Academic & Software Citation
If you use AgentSentinel in your academic research, quantitative trading infrastructure, or security audit pipelines, please cite the software using the following metadata:
@software{biswas_agentsentinel_2026,
author = {Mukesh Biswas},
title = {AgentSentinel: Universal Zero-Trust Runtime Security Firewall & AST Policy Interceptor for AI Agents & Model Context Protocol (MCP)},
month = oct,
year = 2026,
publisher = {GitHub},
version = {v0.1.0},
url = {https://github.com/sparkysolutions10-pixel/agentsentinel},
orcid = {0009-0008-2818-6579},
note = {Deterministic Sub-Millisecond AST Execution Firewall & Real-Time Circuit Breaker Architecture}
}ORCID Author Record: https://orcid.org/0009-0008-2818-6579
📄 License
Apache-2.0 © 2026 sparkysolutions10-pixel
