AirgapGuard-MCP
README.md
# AirgapGuard-MCP: 100% Offline Secret & PII Scrubbing Sentinel MCP Server
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/Apache-2.0)
[-purple.svg)]()
[]()
> **Architect & Author:** Chethan Raj D S (`chethanraj.d.s@gmail.com`)
> **Credentials:** IIT Delhi Executive CTO Alumnus · B.E. Electrical & Electronics Engineering (85.60%)
> **Engineering Focus:** Zero-Trust Architecture · Cryptographic Vaults · Offline Systems · High-Throughput Developer Tooling
---
## 1. Executive Architectural Overview
**AirgapGuard-MCP** is an open-source, 100% offline **Model Context Protocol (MCP)** security sentinel engineered to prevent AI coding agents (**Claude Code**, **Cursor**, **Windsurf**, **GitHub Copilot**, **Antigravity**) from leaking production credentials, API keys, private keys, database connection strings, and PII into external LLM prompts.
### The Burning Problem It Solves
Developers and enterprise security teams often ban or restrict AI coding tools because:
1. **Accidental Exfiltration:** An agent reading `.env`, config files, or logs inadvertently transmits raw production AWS keys, Stripe secrets, or database passwords to external model providers.
2. **Broken Code from Naive Redaction:** Standard regex scrubbers replace secrets with generic `[REDACTED]`, causing generated code patches or scripts to break when executed locally.
3. **Hidden / High-Entropy Secrets:** Custom or unformatted API tokens and passwords escape standard regex checks.
**AirgapGuard-MCP uses Shannon entropy ($H \ge 4.3$) and deterministic, reversible in-memory mocking to sanitize text before it hits the AI agent, and cleanly restores real secrets locally when code is written back.**
```
┌─────────────────────────────────────────┐
│ AI Coding Agent (Claude Code/Cursor) │
└────────────────────┬────────────────────┘
│
JSON-RPC 2.0 over Stdio
│
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ AirgapGuard MCP Sentinel Engine │
├─────────────────────────────────┬───────────────────────────────────────────────┤
│ In-Memory Reversible Vault │ Multi-Tier Detection Core │
│ • Mapping Session Isolation │ • Pattern Matcher (AWS, OpenAI) │
│ • Synthetic Mock Injection │ • Shannon Entropy Scanner (H >= 4.3)│
│ • Local Round-Trip Patching │ • Database URI & Bearer Scrubbing │
│ • Zero-Disk Memory Purge │ • Workspace File Exposure Auditor │
└────────────────┬────────────────┴───────────────────────┬───────────────────────┘
│ │
▼ ▼
[ Sanitized AI Context ] [ Real Workspace Secrets ]
(<AIRGAP_CREDENTIAL_1>) (100% Local, Never Egresses)
```
---
## 2. Flagship Offline MCP Tools
### 1. `airgap_sanitize_text` (Reversible Secret Scrubbing)
* **What it does:** Scans text, code, or logs for AWS keys, OpenAI tokens, Bearer headers, private keys, database URIs, PII emails, and Shannon high-entropy tokens.
* **Deterministic Mocking:** Replaces them with reversible placeholders (`<AIRGAP_CREDENTIAL_1>`) and stores mapping strictly in volatile memory under an isolated session ID.
### 2. `airgap_desanitize_patch` (Local Round-Trip Restoration)
* **What it does:** Re-applies the original secrets into code, git patches, or shell commands generated by the AI agent using the session vault mapping. Ensures local execution works seamlessly without exposing credentials during generation.
### 3. `airgap_audit_workspace` (Proactive Workspace Exposure Scanner)
* **What it does:** Scans the workspace directory tree for accidentally exposed credential files (`.env`, `id_rsa`, `*.pem`, `*.key`, `service_account.json`). Outputs risk classification (`CLEAN`, `ELEVATED`, `CRITICAL`) and concrete mitigation steps.
### 4. `airgap_scan_entropy` (Shannon Entropy Token Analyzer)
* **What it does:** Calculates Shannon entropy bits per character for arbitrary strings. Flags strings exceeding $H \ge 4.3$ with length $\ge 16$ characters as probable raw cryptographic tokens or unformatted passwords.
### 5. `airgap_generate_canary_env` (Synthetic Offline Testing Mocks)
* **What it does:** Generates realistic, non-functional synthetic environment variables (`DATABASE_URL`, `OPENAI_API_KEY`, `JWT_SECRET`, `AWS_ACCESS_KEY_ID`) for offline local testing and mock deployments.
---
## 3. Installation & IDE Integration
### Option A: Cursor IDE (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"airgapguard": {
"command": "python",
"args": ["-m", "airgapguard.mcp.server"],
"cwd": "/path/to/target/project"
}
}
}
```
### Option B: Claude Code CLI
```bash
claude mcp add airgapguard -- python -m airgapguard.mcp.server
```
### Option C: Claude Desktop (`claude_desktop_config.json`)
```json
{
"mcpServers": {
"airgapguard": {
"command": "python",
"args": ["-m", "airgapguard.mcp.server"],
"cwd": "/absolute/path/to/airgapguard-mcp"
}
}
}
```
---
## 4. Standalone CLI Usage
AirgapGuard can also be used as a standalone terminal security tool:
```bash
# Sanitize a dirty configuration file
python -m airgapguard.cli sanitize .env
# Restore real secrets into an AI-generated patch
python -m airgapguard.cli desanitize "<sanitized_code>" --session <session_id>
# Audit current workspace for exposed keys
python -m airgapguard.cli audit .
# Calculate Shannon entropy on candidate token
python -m airgapguard.cli entropy "qZ8$vL2#mP9!xK4@wT7^bN1*"
# Generate safe canary test environment variables
python -m airgapguard.cli canary
```
---
## 5. Verification & Test Suite
The test suite runs 100% offline with zero external network access:
```bash
# Clone the repository
git clone https://github.com/Chethan-Raj-D-S/airgapguard-mcp.git
cd airgapguard-mcp
# Run full test suite
pytest tests/ -v
```
**Verification Results:**
```text
tests/test_auditor.py::test_audit_dirty_workspace PASSED [ 7%]
tests/test_auditor.py::test_audit_clean_workspace PASSED [ 15%]
tests/test_entropy.py::test_shannon_entropy_simple_text PASSED [ 23%]
tests/test_entropy.py::test_shannon_entropy_random_secret PASSED [ 30%]
tests/test_entropy.py::test_entropy_scanner_detects_tokens PASSED [ 38%]
tests/test_mcp_server.py::test_mcp_initialize PASSED [ 46%]
tests/test_mcp_server.py::test_mcp_tools_list PASSED [ 53%]
tests/test_mcp_server.py::test_mcp_call_sanitize_and_desanitize PASSED [ 61%]
tests/test_mcp_server.py::test_mcp_call_scan_entropy PASSED [ 69%]
tests/test_mcp_server.py::test_mcp_call_canary PASSED [ 76%]
tests/test_sanitizer.py::test_sanitize_credentials PASSED [ 84%]
tests/test_sanitizer.py::test_desanitize_round_trip PASSED [ 92%]
tests/test_sanitizer.py::test_clean_text_no_op PASSED [100%]
============================= 13 passed in 0.64s ==============================
```
---
## 6. Directory Structure
```
airgapguard-mcp/
├── pyproject.toml # Modern package spec & dependencies
├── README.md # Architectural documentation
├── SKILL.md # AI Agent instruction specification
├── LICENSE # Apache 2.0 open-source license
├── airgapguard/
│ ├── __init__.py # Package exports
│ ├── cli.py # Standalone CLI entrypoint
│ ├── core/
│ │ ├── __init__.py
│ │ ├── auditor.py # Workspace credential scanner
│ │ ├── entropy.py # Shannon entropy detection engine
│ │ ├── models.py # Pydantic schemas for detections & vaults
│ │ ├── patterns.py # Regex catalog for credentials & PII
│ │ └── sanitizer.py # Reversible in-memory sanitization engine
│ └── mcp/
│ ├── __init__.py
│ ├── protocol.py # MCP protocol schemas
│ └── server.py # JSON-RPC 2.0 stdio MCP server
└── tests/
├── conftest.py # Mock credentials & dirty workspace fixtures
├── test_auditor.py # Workspace scanner tests
├── test_entropy.py # Shannon entropy tests
├── test_mcp_server.py # JSON-RPC stdio protocol tests
└── test_sanitizer.py # Reversible sanitization tests
```
---
## 7. License
Licensed under the Apache License, Version 2.0.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues