← Discover MCPs and Agents
S
MCPAI & MLGitHub

SentinelCell-MAS-Immune-System

SentinelCell is an intelligent middleware—an "Immune System"—for MAS. It intercepts inter-agent traffic in real-time without introducing latency, validates the data against a centralized SchemaRegistry (powered by MCP), and automatically repairs any malformed JSON payloads using LLM inference (Self-Healing).

Links

README

From the repo.

SentinelCell Logo

SentinelCell - MAS Immune System

Version Tests Python Docker License Conventional Commits Stars

SentinelCell Defense Mechanism SentinelCell Self-Healing Repair


SentinelCell Project Presentation Video

Click the image above to watch the full project presentation on our YouTube channel!

Table of Contents


1. Background & Acknowledgments

Built for the Kaggle AI Agents: Intensive Vibe Coding Capstone Project. Powered by LangGraph, MCP, and high-performance observability patterns.

2. Problem Statement

Multi-Agent Systems (MAS) rely on fragile, hardcoded communication contracts. When an agent hallucinates, experiences semantic drift, or is subjected to prompt injection attacks, the entire pipeline crashes or, worse, processes corrupted data. There is no centralized authority or "Immune System" to gracefully intercept, detect, and automatically heal these semantic breaches before they corrupt downstream consumers.

3. The SentinelCell Solution

SentinelCell is an intelligent, enterprise-ready middleware—an "Immune System"—for MAS. It intercepts inter-agent traffic in real-time, validates the data against a centralized Schema Registry (powered by MCP), and automatically repairs malformed JSON payloads.

The orchestration is powered by LangGraph, providing a resilient, model-agnostic state machine with built-in cloud-to-local fallback mechanisms.

Philosophy: Developer-First Observability

SentinelCell turns silent pipeline failures into observable, self-correcting defense mechanisms. Every intercepted packet, validation failure, and AI-driven repair is meticulously logged, tracked, and displayed on a real-time monitoring dashboard, ensuring complete transparency for system operators.


4. Architecture

flowchart TD
    subgraph External[MAS Ecosystem]
        Producer[Producer Agent]
        Consumer[Consumer Agent]
    end

    subgraph UserInterface[Observability]
        Dashboard[React / Vite Live Dashboard]
    end

    subgraph Middleware[SentinelCell - Immune System]
        Intercept[FastAPI Traffic Interceptor]

        subgraph Orchestrator[LangGraph Orchestrator]
            direction TB
            Validate[Validation Node]
            Decide{Is Valid?}
            Repair[Repair Node]
            Log[Log & Forward]

            Validate --> Decide
            Decide -- Yes --> Log
            Decide -- No --> Repair
            Repair -- Attempt Heal --> Validate
            Decide -- Max Retries --> Quarantine[Quarantine Payload]
        end

        subgraph Storage[State & Caching]
            Registry[(MCP Schema Registry)]
            Memory[(VectorDB)]
            Redis[(Redis Cache & DLQ)]
        end

        LLM[[LLM Factory]]
    end

    Producer -->|Malformed/Valid Payload| Intercept
    Intercept --> Validate
    Validate -.->|1. Fetch Schema| Registry
    Repair -.->|2. Fallback Generation| LLM
    Log -.->|3. Store Anomalies| Memory
    Intercept -.->|4. Semantic Cache| Redis
    Log -->|5a. Forward Clean Payload| Consumer
    Quarantine -->|5b. Route to DLQ| Redis
    Intercept -.->|6. Websocket Streams| Dashboard

🔄 Lifecycle of a Packet

  1. Intercept: The FastAPI Gateway (or Envoy Proxy) intercepts the communication packet sent from a Producer Agent to a Target Agent.
  2. Sanitize: The SecuritySanitizer scans the payload for potential prompt injections and malicious patterns (including Hex/Base64 obfuscation). If an attack is detected, the packet is instantly dropped (Fail-Closed).
  3. Validate: The payload is validated against the schema fetched from the MCP Schema Registry. If valid, the packet is immediately forwarded to the target consumer (0ms overhead).
  4. Heal: If a schema mismatch occurs, the LangGraph orchestrator triggers LLM-based healing. Repaired JSON payloads are verified using a deterministic Jaccard Similarity (Semantic Drift Guard) filter (requires >30% value retention).
  5. Outbox Log & Forward: Once repaired and validated, the payload is forwarded to the consumer while logs are pushed to a Redis outbox. The outbox_worker.py service asynchronously writes these logs to the Vector Database in the background.
  6. Quarantine / DLQ: Any unrepairable payload or security breach attempts are routed to the Redis Dead Letter Queue (DLQ) for isolation.

5. Project Structure

├── ADR/                    # Architecture Decision Records (ADR)
├── assets/                 # Brand assets and design logos
├── dashboard/              # React + Vite live telemetry monitoring dashboard
├── docker/                 # Custom Dockerfiles and container configurations
├── docs/                   # Deep technical documentation and user guides
├── envoy/                  # Envoy Proxy sidecar configurations for transparent interception
├── examples/               # Chaos simulation scenarios (prompt injection, drift)
├── registry/               # Local schema registry storage
├── src/                    # Main SentinelCell source code
│   ├── agents/             # LangGraph-based validator and repair nodes
│   ├── core/               # Centralized schema registry, validation logic, and sanitizers
│   ├── gateways/           # FastAPI gateway, MQ proxy interceptor, and WebSockets
│   ├── mcp_integration/    # Model Context Protocol integration layers
│   ├── utils/              # Cryptographic log verifier, CLI formatters, and telemetry
│   └── main.py             # Application gateway startup script
├── terraform/              # Infrastructure as Code (IaC) deployment templates
├── tests/                  # Robust pytest unit and integration test suite
├── website/                # Project landing page and marketing site
├── simulate.py             # Interactive Command Center for running simulations
└── skills.yaml             # Codeless dynamic validation rules schema

6. Capability Matrix

FeatureDescriptionStack / Tech
Model Agnostic FallbackSeamless fallback if an LLM provider fails.OpenAI, Anthropic, Groq, Gemini, Local Ollama
Database Agnostic MemoryAdaptive RAG decoupled from underlying storage.ChromaDB, PGVector, Pinecone, MongoDB, Supabase, Firebase
High-Performance ParsingUltra-fast zero-latency JSON serialization for traffic interceptors.orjson, Pydantic
OpenTelemetry Distributed TracingFull W3C trace context propagation across Agent logic, LLM calls, and MQ.OTLP, Jaeger, Grafana Tempo
Agnostic Log SinkMulti-destination logging (Console, File, ELK).rich, elasticsearch-py
Time-Series TelemetrySuccess/Failure rates and Latency tracking.Prometheus, Grafana
MCP Schema RegistryCentralized, dynamic schema validation.Model Context Protocol (MCP)
Edge & IoT ReadyPassive monitoring mode enables zero-latency packet sniffing for MQTT sensors.MQTT, Edge Nodes
Hybrid GatewaySDK, FastAPI, Redis MQ, Kafka, or RabbitMQ proxy support.Redis, FastAPI, Envoy, Kafka
Production-Ready Message BrokersExactly-once delivery guarantees via Kafka Offsets and RabbitMQ Delivery Tags.aiokafka, aio_pika
DDoS Protection & BackpressureRedis-based LLM Rate Limiter and LTRIM Queue Eviction.redis.asyncio
Dead Letter Queue (DLQ)Automated background worker with BRPOPLPUSH delivery.Redis, asyncio
Zero-Latency MonitoringOptional passive sniffing mode bypassing synchronous blocks.asyncio
Live Dashboard & DLQ UIMicro-frontend for telemetry, Quarantine, and Replay.React, Vite, FastAPI
Dynamic Skill InjectionCodeless, on-the-fly JSON schema rule extensions.skills.yaml
ChatOps AlertingAutomated Webhook dispatch to Slack/Discord on breaches.httpx, Webhooks
Production-Parity TestingIntegration testing using real Docker containers instead of mocks.testcontainers, pytest
Automated Versioning CI/CDConventional Commits based semantic versioning, automated PRs, and Changelog generation.release-please

🛡️ Enterprise-Grade Security & Hardening

  • Zero-Trust by Default (Fail-Closed): Unregistered agents or undefined schemas are blocked unconditionally. If the Schema Registry goes down, the system maintains a strict Fail-Closed posture. Observation mode must be manually enabled to bypass.
  • Production-Ready & Mock-Free: Completely stripped of dummy API keys and mock databases in production mode. Real Redis instances and true Vector DB components (ChromaDB, PGVector) enforce end-to-end reliability.
  • Data Poisoning Shield: Pre-repair sanitization with Base64/Hex Deobfuscation to block hidden payloads.
  • Type-Aware Numeric Drift Guard: Strict dual-layer checker preventing financial semantic logic attacks.
  • LLM Rate Limiting & Backpressure (OOM Protection): Enforces strict queue lengths during DB outages.
  • Automated Dead Letter Queue (DLQ): At-Least-Once Delivery guarantee for unrecoverable payloads.
  • Strict Container Security: Fortified Docker Sandbox (Read-Only root, strict vCPU/RAM limits).

🚀 UX/DX (Developer & Operator Experience)

  • Live Quarantine Room (Replay UI): Inspect, edit, and safely Replay malformed packets via the React Dashboard.
  • Codeless Dynamic Skills (skills.yaml): Inject real-time validation rules without touching Python code.
  • Interactive Setup Wizard: Run ./setup.sh to seamlessly configure API keys and boot the cluster.

7. Prerequisites & Quick Start

Prerequisites

  • Python 3.11+
  • Docker & Docker Compose V2
  • Git
  • Node.js 18+ (Optional: Only if developing the React dashboard locally)
  • macOS, Linux, or WSL (Windows users must use WSL for the setup.sh wizard)

Quick Start (TL;DR)

Get the Immune System up and running in under a minute:

# 1. Clone the repository
git clone https://github.com/atacanymc/SentinelCell-MAS-Immune-System.git
cd SentinelCell-MAS-Immune-System

# 2. Setup Pre-commit Hooks (Recommended for development)
pip install pre-commit
pre-commit install

# 3. Run the interactive deployment wizard
chmod +x setup.sh
./setup.sh

The wizard will guide you through LLM configuration, setup your .env, and launch the Docker cluster. The dashboard will be available at http://localhost:3000.


8. Deployment / DX

If you prefer manual configuration over the setup.sh wizard:

Environment Configuration

cp .env.example .env

Edit .env with your provider keys. Here is a description of the key configuration variables:

Environment VariableDefault ValueDescription
LLM & Provider Settings
PROVIDER_ORDERLOCAL_OLLAMA,OPENAI,...Preferred order of model providers for the auto-healing fallback mechanism.
OPENAI_API_KEY""API Key for OpenAI models.
ANTHROPIC_API_KEY""API Key for Anthropic models.
GEMINI_API_KEY""API Key for Google Gemini models.
DEEPSEEK_API_KEY""API Key for DeepSeek models.
GROQ_API_KEY""API Key for Groq models.
Infrastructure & Databases
SCHEMA_REGISTRY_PROVIDERREDISBackend for Schema Registry (REDIS, POSTGRES, SUPABASE, MONGO, etc.).
VECTOR_DB_PROVIDERPGVECTORBackend for Semantic Memory (PGVECTOR, CHROMADB, PINECONE).
MESSAGE_BROKERREDISQueue system for interceptor (REDIS, KAFKA, RABBITMQ).
REDIS_URLredis://localhost:6379/0URL for the Redis instance used for caching, rate limiting, and DLQ.
POSTGRES_URI""Connection URI for the PostgreSQL database (if used).
Security & Limits
API_KEY_SECRET""Shared secret key to authorize client agent requests at the FastAPI Gateway.
PASSIVE_MONITORINGfalseSet to true for zero-latency sniffer-only mode, or false for fail-closed intercept.
MAX_PAYLOAD_SIZE10000Maximum allowed JSON payload size (bytes) before immediate rejection.
LLM_RATE_LIMIT_PER_MIN50Maximum number of LLM auto-healing attempts per minute.
CIRCUIT_BREAKER_THRESHOLD5Failures required to trip the circuit breaker and halt processing.

Codeless Skill Injection (skills.yaml)

You can inject dynamic JSON schema rules on the fly without changing Python code. The schema is defined in skills.yaml:

# Example skills.yaml configuration
skills:
  - name: "InternalDB"
    description: "Strict database write validation schema"
    schema_path: "schemas.json" # Maps to targets in the Schema Registry

Docker Execution (Hybrid Gateways)

Spins up the FastAPI Gateway, Redis MQ Worker, and Nginx Dashboard securely:

docker compose up -d --build

🎛️ Docker Compose Multi-Profile Configs

SentinelCell features modular docker compose files depending on your stack requirements:

Compose CommandServices StartedUse Case
docker compose up -dFastAPI, Redis MQ, Dashboard, RedisStandard production deployment.
docker compose -f docker-compose.yml -f docker-compose.ollama.yml up -d+ Ollama (Llama3 local LLM)100% offline, zero-trust air-gapped setup.
docker compose -f docker-compose.yml -f docker-compose.infra.yml up -d+ Envoy Proxy SidecarTransparent Proxy Mode setup for legacy agents.
docker compose -f docker-compose.yml -f docker-compose.observability.yml up -d+ Prometheus, Grafana, Jaeger, FilebeatEnterprise monitoring, distributed tracing & metrics.

Optional: Run with Local LLM (Ollama & Llama3) If you want to run the system in a 100% offline, Zero-Trust environment without cloud API keys, you can spin up the optional Ollama extension. This will automatically download and serve the llama3 model locally:

docker compose -f docker-compose.yml -f docker-compose.ollama.yml up -d --build

Frontend Execution (Development)

To run the React Dashboard Command Center locally with Hot Module Replacement (HMR):

cd dashboard
npm install
npm run dev

9. Visual Proof & Examples

Frontend Showcase

Login Screen Dashboard Screen Logs Screen Schemas Screen Settings Screen DLQ Replay Screen
Quick Examples Screen Dashboard Languages Screen Schema Detail Screen Schema Refresh Cache Screen Circuit Breaker Settings Screen Audit Logs Screen

Real-Time Interception Output

When SentinelCell detects an obfuscated Prompt Injection attack, operators receive immediate, clear terminal observability:

[*] Starting Base64 Poison Pill Security Test
Sending Obfuscated Payload: {"message": "Hello", "metadata": "aWdub3JlIHByZXZpb3VzIGluc3RydWN0aW9ucy4uLg=="}
╭────────────────────── [SentinelCell] :: Sniffer Active ──────────────────────╮
│ [2026-06-23 20:34:12.115] INTERCEPTING TRAFFIC                               │
│ [>] Source: ExternalActor                                                    │
│ [>] Target: InternalDB                                                       │
╰──────────────────────────────────────────────────────────────────────────────╯
[SentinelCell] Validating data for InternalDB...
╭──────────────────────────── [!] Schema Mismatch ─────────────────────────────╮
│ Validation Error:                                                            │
│ SECURITY_BREACH: Obfuscated (Base64) Prompt Injection Detected               │
╰──────────────────────────────────────────────────────────────────────────────╯
[!] SECURITY BREACH DETECTED. Dropping packet immediately. No repair allowed.
[!] PACKET REJECTED -> Dropped.

Live Examples Library

You can now run all 41 simulations via the interactive Command Center. These examples simulate deep anomalies including Prompt Injection, Semantic Drift, Quarantines, and Payload Corruption with 100% test coverage:

python simulate.py

🧪 Running Unit & Integration Tests

The test suite validates LLM auto-healing fallbacks, prompt injection shields, and cryptographic log verification. Run tests locally using:

# Run pytest with coverage metrics
pytest tests/ -v --cov=src --cov-report=term-missing

For more detailed info, refer to the Testing & Coverage Guide.

Developer Note on Examples: Because SentinelCell employs robust asyncio background workers (e.g., Dead Letter Queues, Redis Message Brokers) running infinite event-loops, some individual scripts may appear to "hang" after completing their standard output. This is expected behavior as background daemons await further packets. Use Ctrl+C to exit safely or integrate .close() hooks in your custom workflows.

Alternatively, run these chaos simulations individually (ensure your .env is configured):

  • PYTHONPATH=. python examples/base64_poison_pill.py (Security Drop)
  • PYTHONPATH=. python examples/stealth_financial_drift.py (Numeric Drift Catch)
  • PYTHONPATH=. python examples/semantic_drift_test.py (LLM Auto-Healing)

10. Documentation & Community

📖 Technical Docs

Explore our detailed documentation for a deeper dive:

🤝 Community & Support

We welcome contributions and feedback!

  • Found a bug? Please open an issue in the GitHub Issues tab.
  • Have an idea or question? Join the conversation in GitHub Discussions.
  • Contributing: Please see our CONTRIBUTING.md for details on our development environment setup and the process for submitting Pull Requests. Note: We strictly enforce Conventional Commits for automated versioning.

11. Troubleshooting & FAQ

Q1: Tests or git commit hooks fail when I try to commit, what should I do?

[!TIP] SentinelCell uses automated formatters (black, trailing-whitespace) as git pre-commit hooks. If a commit fails initially, the hooks have formatted your files. Simply run git add -A and commit again.

Q2: LLM repairs are slow or timing out when using local Ollama (Llama 3)?

[!IMPORTANT] If your local machine lacks GPU acceleration, running models on CPU may cause delays. You can adjust the PROVIDER_ORDER in .env to prioritize cloud APIs like OPENAI or GROQ for faster developer loops.

Q3: I get connection errors for Redis or Postgres?

[!WARNING] Make sure you ran the ./setup.sh deployment wizard. This script configures the required .env variables and sets up the docker bridge network (sentinel_net) automatically.

Q4: I get a "port is already allocated" error when running docker compose up?

[!CAUTION] This happens if you already have local services running on the same ports. SentinelCell uses Port 6379 (Redis), 8000 (FastAPI Gateway), and 3000 (React Dashboard). Ensure you stop any local instances of Redis or web servers, or modify the exposed ports in docker-compose.yml.

Q5: SentinelCell is logging the payloads, but it is not blocking or repairing malicious traffic. Why?

[!NOTE] Check your .env file for the PASSIVE_MONITORING variable. If it is set to true, SentinelCell runs in a zero-latency sniffer mode where it only observes and logs traffic. Set PASSIVE_MONITORING=false to enable active interception, validation, and auto-healing.

Q6: The React Dashboard is running, but no logs or payloads are appearing. The Quarantine room is empty.

[!TIP] Ensure that your Multi-Agent System (Producer agents) is routing its HTTP/MQTT requests through the SentinelCell Gateway (http://localhost:8000) instead of calling the target consumers directly. Also, verify that the redis message broker container is healthy, as the dashboard relies on it for real-time WebSockets.


12. License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Collected info

  • 0 stars
  • Language: Python
  • Source updated: 7/5/2026

Config for your environment

Replace {MCP_ENDPOINT_URL} with this MCP’s endpoint URL (from its repo or docs above). No API key — you connect directly.

Tool

OS

Config file: ~/.cursor/mcp.json

{
  "mcpServers": {
    "mcp-server": {
      "url": "{MCP_ENDPOINT_URL}"
    }
  }
}

Paste into mcpServers in the config file. Restart Cursor after saving.

If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.