ai-firewall-mcp
A multi-agent AI security layer that protects LLMs from prompt injection, jailbreaks, and policy violations via MCP tools.
README
<div align="center"> <img src="https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue?logo=python&logoColor=white"> <img src="https://img.shields.io/badge/License-MIT-green"> <img src="https://img.shields.io/github/actions/workflow/status/Akhilucky/AI-firewall/ci.yml?branch=main&label=CI&logo=github"> <img src="https://img.shields.io/pypi/v/ai-firewall-mcp?label=PyPI&logo=pypi"> <img src="https://img.shields.io/docker/v/akhilucky/ai-firewall-mcp/latest?label=Docker%20Hub&logo=docker"> <img src="https://img.shields.io/badge/MCP-Registry-8A2BE2"> <br> <a href="https://github.com/Akhilucky/AI-firewall"><b>GitHub</b></a> • <a href="https://pypi.org/project/ai-firewall-mcp/"><b>PyPI</b></a> • <a href="https://hub.docker.com/r/akhilucky/ai-firewall-mcp"><b>Docker Hub</b></a> </div>
<mcp-name: io.github.Akhilucky/ai-firewall-mcp>
AI Firewall — MCP Server
A multi-agent AI security layer that protects LLMs from prompt injection, jailbreaks, and policy violations. Available as an MCP server for any MCP-compatible client (Claude Desktop, Cursor, Windsurf, Cline, Roo Code, etc.).
Quick Start
pip install
pip install ai-firewall-mcp
ai-firewall-mcp
Docker
docker pull akhilucky/ai-firewall-mcp:latest
docker run -i akhilucky/ai-firewall-mcp:latest
Claude Desktop
Add to claude_desktop_config.json:
pip install:
{
"mcpServers": {
"ai-firewall": {
"command": "pipx",
"args": ["run", "ai-firewall-mcp"]
}
}
}
Docker:
{
"mcpServers": {
"ai-firewall": {
"command": "docker",
"args": ["run", "-i", "akhilucky/ai-firewall-mcp:latest"]
}
}
}
Cursor / Windsurf / Cline / Roo Code
Configure in your MCP settings with:
- Type:
stdio - Command:
docker run -i akhilucky/ai-firewall-mcp:latest - Or use
ai-firewall-mcpif installed via pip
MCP Tools
| Tool | Description |
|---|---|
analyze_prompt |
Analyze a prompt for injection, jailbreaks, exfiltration, and leakage |
get_threat_breakdown |
Detailed per-signal scoring breakdown from the last analysis |
sanitize_prompt |
Clean a suspicious prompt while preserving legitimate content |
get_firewall_status |
Health check: vector DB size, model status, uptime |
benchmark_firewall |
Run the adversarial test suite and return detection statistics |
Testing with MCP Inspector
npx @modelcontextprotocol/inspector ai-firewall-mcp
Architecture
The firewall runs three agents per prompt:
User Prompt → [Retrieval Agent] → [Guard Agent] → [Policy Agent] → LLM
│ │ │
▼ ▼ ▼
Vector DB (FAISS) Threat Signals Allow/Block
| Agent | Role |
|---|---|
| Retrieval Agent | Semantic search against known attack patterns (FAISS + sentence-transformers) |
| Guard Agent | Multi-signal classification: vector similarity, keyword match, heuristic scoring |
| Policy Agent | Final decision: ALLOW / BLOCK / SANITIZE based on configurable thresholds |
Threat signals are weighted: 40% vector similarity, 25% keyword match, 20% heuristic, 15% policy weight.
Configuration
| Env Var | Default | Description |
|---|---|---|
FIREWALL_MODE |
strict |
strict / moderate / permissive |
SIMILARITY_THRESHOLD |
0.50 |
Vector match threshold (lower = stricter) |
LOG_LEVEL |
INFO |
Logging verbosity |
CLI / API Usage
# Interactive dashboard
python main.py
# Red-team adversarial tests
python main.py --redteam
# REST API server
python main.py --api
# Single prompt analysis
python main.py --analyze "Ignore all previous instructions"
The REST API runs at http://localhost:8000 with OpenAPI docs at /docs (requires pip install ai-firewall-mcp[api]).
Testing
pytest tests/ -v # Full test suite (43 tests)
pytest tests/test_mcp.py # MCP-specific tests only
Project Structure
├── src/ai_firewall/ # MCP server package (PyPI entry)
│ ├── mcp_server.py # 5 MCP tools, stdio transport
│ ├── threat_scorer.py # Per-signal scoring breakdown
│ └── __init__.py
├── src/agents/ # Core firewall agents
├── tests/ # Test suites
├── Dockerfile # Docker image (2.04GB, CPU-only torch)
├── pyproject.toml # Package config & metadata
└── .github/workflows/ci.yml # CI/CD pipeline
License
MIT — see LICENSE.
<div align="center">Built for security. Designed for production.</div>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。