
Agent Immune
io.github.denial-web由 GitHub 账号 denial-web 发布v0.2.2更新于 Oct 24, 2026
AI agent security: prompt injection detection, semantic memory, output scanning, prompt hardening
概览
一个本地 MCP 服务器,为助手提供提示注入检测、输出扫描、威胁学习和提示加固等智能体安全能力。
- 可以做什么
- 评估用户输入中的注入、外泄和间接攻击,返回允许、复核、净化或阻止动作及分数,并按会话跟踪多轮升级。扫描模型输出中的凭据、个人数据、提示泄露和编码内容。把新的攻击文本写入语义记忆库,以便之后识别改写过的攻击。对消息列表做角色锁定、沙箱化和输出防护的加固。报告评估次数、拦截次数和延迟等指标。
- 适用场景
- 当助手需要处理不可信的用户输入或模型输出,并希望在静态规则之上再加一层运行时防护时适合使用,尤其是希望从事件中学习并识别改写或多语言攻击的场景。
- 运行要求
- 从 PyPI 安装的本地 Python 进程;需要 Python 3.9 以上(MCP 部分需 3.10 以上)。安装 mcp 附加组件后用 serve 命令以 stdio、sse 或 streamable-http 启动。语义记忆需 memory 附加组件和 sentence-transformers,快速检索需 hnswlib。未声明账号或 API 密钥。
安装
在 SourceWeft 中
- 打开 控制台中的 Agent Immune,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
agent-immune
[CI] [Python 3.9+] [Coverage 94%] [License Apache-2.0] [181 tests] [Glama]
Adaptive threat intelligence for AI agent security: semantic memory, multi-turn escalation, output scanning, rate limiting, and prompt hardening — designed to complement deterministic governance stacks (e.g. Microsoft Agent OS), not replace them.
The immune system that governance toolkits don't include: it learns from incidents and catches rephrased attacks that slip past static rules.
Try it now
Run python demos/demo_quick.py for the full interactive demo.
Install
Python 3.9+ required; 3.11+ recommended. The MCP stack targets Python 3.10+ (see the mcp package).
MCP server (local)
Run agent-immune as an MCP server so hosts (Claude Desktop, Cursor, VS Code, etc.) can call security tools without embedding the library:
Tools exposed: assess_input, assess_output, learn_threat, harden_prompt, get_metrics.
Example Claude Code (HTTP):
Available on
[MCP Registry] [MCP.so] [Glama] [PulseMCP]
Quick start
Custom security policy
Pre-built attack corpus
Bootstrap semantic memory instantly with 50 curated attacks across 11 languages:
This gives you immediate protection against common injection, exfiltration, and indirect attacks without any training data. Add your own incidents on top with immune.learn().
Async support
JSON persistence & threat sharing
Observability
Structured JSON events are emitted to the agent_immune.events logger — pipe to any log aggregator.
Rate limiting / circuit breaker
Prompt hardening
The memory advantage
Regex alone catches known patterns. After learning 8 attacks, semantic memory catches rephrased attacks that evade all regex rules — while benign queries stay untouched:
Run PYTHONPATH=src python demos/demo_full_lifecycle.py to reproduce this on your machine.
Why agent-immune?
Architecture
Benchmarks
Regex-only baseline
Zero false positives across all datasets. Multilingual patterns cover English, German, Spanish, French, Croatian, Russian, Chinese, Japanese, Korean, Arabic, and Hindi.
With adversarial memory
The core thesis: learning from a small incident log lifts recall on unseen attacks through semantic similarity.
F1 improves from 0.657 → 0.849 (+29%) with 92 learned attacks. 67.4% of never-seen attacks are caught purely through semantic similarity. Precision stays >= 99.1%.
Methodology: "flagged" =
action != ALLOW. Held-out recall excludes training slice. Seed = 42.
Demos
Documentation
- Getting started — install → assess → scan → learn in 5 minutes
- Architecture — full system internals
- Integration guide — CLI, adapters, memory, policy, async
- Threat model
- Comparison
- Benchmarks
- Roadmap
- MCP marketplaces — Smithery, MCP.so, Glama, registry, Cursor
- Changelog
Landscape
License
Apache-2.0. See LICENSE.
来源:README.md,提交 d220dd5
工具
0版本历史
1- v0.2.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分