AI Firewall MCP

io.github.Akhilucky由 GitHub 账号 Akhilucky 发布v1.0.1更新于 Oct 24, 2026

Multi-agent LLM security layer detecting prompt injection and jailbreaks.

已验证STDIO仅桌面安全与监控AI 与机器学习

概览

AI 生成的概览

一个 MCP 服务器,在提示词到达 LLM 之前检测注入、越狱和策略违规。

可以做什么
对每条提示词运行三代理流水线:检索代理在 FAISS 向量库中对已知攻击模式做语义搜索,守卫代理对向量相似度、关键词匹配和启发式规则打分,策略代理返回 ALLOW、BLOCK 或 SANITIZE。提供五个工具:analyze_prompt、get_threat_breakdown、sanitize_prompt、get_firewall_status 和 benchmark_firewall。还附带 CLI 和可选的 REST API。
适用场景
当助手或代理流水线接收不可信的用户输入,并希望在送入 LLM 前检查提示词注入、越狱尝试或数据外泄与泄漏时使用。也可通过对抗性基准工具对自己的提示词做红队测试。
运行要求
以 stdio 方式在本地运行的进程。用 pip 或 pipx 安装 PyPI 包 ai-firewall-mcp,或运行 Docker 镜像。未声明账号、API 密钥或请求头。可选环境变量 FIREWALL_MODE、SIMILARITY_THRESHOLD 和 LOG_LEVEL 用于调整行为。REST API 模式需要安装 api 附加组件。
安装前请注意
该服务器会检查提示词文本,因此被分析的提示词会由其本地模型和向量库处理,请考虑内容是否敏感。它返回的 ALLOW、BLOCK 或 SANITIZE 决定可能修改或丢弃提示词内容,在生产环境依赖前应先测试阈值。清单未要求任何凭据。

安装

在 SourceWeft 中

  1. 打开 控制台中的 AI Firewall MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

<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

bash
pip install ai-firewall-mcpai-firewall-mcp

Docker

bash
docker pull akhilucky/ai-firewall-mcp:latestdocker run -i akhilucky/ai-firewall-mcp:latest

Claude Desktop

Add to claude_desktop_config.json:

pip install:

json
{  "mcpServers": {    "ai-firewall": {      "command": "pipx",      "args": ["run", "ai-firewall-mcp"]    }  }}

Docker:

json
{  "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-mcp if installed via pip

MCP Tools

ToolDescription
analyze_promptAnalyze a prompt for injection, jailbreaks, exfiltration, and leakage
get_threat_breakdownDetailed per-signal scoring breakdown from the last analysis
sanitize_promptClean a suspicious prompt while preserving legitimate content
get_firewall_statusHealth check: vector DB size, model status, uptime
benchmark_firewallRun the adversarial test suite and return detection statistics

Testing with MCP Inspector

bash
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
AgentRole
Retrieval AgentSemantic search against known attack patterns (FAISS + sentence-transformers)
Guard AgentMulti-signal classification: vector similarity, keyword match, heuristic scoring
Policy AgentFinal 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 VarDefaultDescription
FIREWALL_MODEstrictstrict / moderate / permissive
SIMILARITY_THRESHOLD0.50Vector match threshold (lower = stricter)
LOG_LEVELINFOLogging verbosity

CLI / API Usage

bash
# Interactive dashboardpython main.py
# Red-team adversarial testspython main.py --redteam
# REST API serverpython main.py --api
# Single prompt analysispython 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

bash
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.


Built for security. Designed for production.

来源:README.md,提交 4570507

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分