Carlos-Projects/mcp-attest
GitHub: Carlos-Projects/mcp-attest
MCP Attest 是一个 MCP 安全扩展,在客户端连接前验证服务器的身份、完整性和信任度,解决 AI 工具链中不可信服务器接入的风险问题。
Stars: 0 | Forks: 1
# MCP Attest 🔐
[](https://github.com/Carlos-Projects/mcp-attest/actions)
[](https://pypi.org/project/mcp-attest/)
[](https://python.org)
[](LICENSE)
[](https://github.com/Carlos-Projects/mcp-attest)
[](https://github.com/Carlos-Projects/mcp-attest/blob/main/.pre-commit-config.yaml)
[](https://github.com/Carlos-Projects/mcp-attest)
[](https://api.star-history.com/svg?repos=Carlos-Projects/mcp-attest&type=Date)
**验证、信任、连接。** MCP Attest 是一个 Model Context Protocol 的安全扩展,它会在允许客户端连接之前验证服务器的身份、完整性和权限。基于论文 [*Attested Tool-Server Admission*](https://arxiv.org/abs/2605.24248)(Alfredo Metere,2026年5月)。
## 它的功能 🎯
- **身份验证** — 通过 TLS 证书、加密签名或 DID 验证 MCP 服务器身份
- **完整性证明** — 生成并验证所暴露服务器工具的 SHA-256 清单
- **权限审计** — 评估请求权限与声明权限(最小权限原则)
- **能力指纹识别** — 创建唯一的服务器能力指纹以检测变更
- **信任评分计算** — 根据身份、完整性和权限计算信任评分(0–100)
- **撤销检查** — 验证服务器是否已从信任列表中被撤销
- **策略生成** — 根据信任评分生成兼容 MCPGuard 的访问策略
## 独特之处 🏆
| 能力 | 功能 | 重要性 |
|---|---|---|
| **多因素身份验证** | TLS 证书 + 加密签名 + DID | 纵深防御 — 消除单点信任 |
| **能力指纹识别** | 暴露工具的 SHA-256 哈希 | 检测工具漂移、篡改或供应链攻击 |
| **信任评分** | 基于 4 个维度的加权 0–100 分数 | 量化的风险决策,而非主观直觉 |
| **MCPGuard 集成** | 自动生成访问策略 | 为现有 MCP 部署提供即插即用的安全性 |
## 架构 🏗️
```
┌──────────────┐ ┌──────────────────────────────────────────────┐
│ Client │ │ MCP Attest CLI │
│ (MCP Host) │ │ │
│ │ │ ┌─────────┐ ┌──────────┐ ┌─────────────┐ │
│ ┌────────┐ │ │ │Identity │ │Integrity │ │Permissions │ │
│ │ Your │ │────┼─▶│Verify │──│Attest │──│Audit │ │
│ │ App │ │ │ │(TLS/DID │ │(Manifest │ │(Least │ │
│ └────────┘ │ │ │ /Crypto)│ │ /Fp) │ │ Privilege) │ │
│ │ │ │ └────┬────┘ └────┬─────┘ └──────┬──────┘ │
│ │ │ │ │ │ │ │
│ ▼ │ │ ▼────────────▼───────────────▼ │
│ ┌────────┐ │ │ │ │
│ │ MCP │ │ │ ┌───────▼───────┐ │
│ │ Server │ │ │ │ Trust Scorer │ │
│ └────────┘ │ │ │ (0–100 score) │ │
└──────────────┘ │ └───────┬───────┘ │
│ │ │
│ ┌───────▼───────┐ │
│ │ Policy │ │
│ │ Generator │──▶ MCPGuard │
│ └───────────────┘ │
└──────────────────────────────────────────────┘
```
## 快速开始 ⚡
```
# 从 PyPI 安装
pip install mcp-attest
# 或从源码安装
git clone https://github.com/Carlos-Projects/mcp-attest
cd mcp-attest
pip install -e ".[dev]"
# 验证 server 的身份、完整性和信任
mcp-attest verify --server https://mcp.example.com --manifest manifest.json
# 生成 capability 指纹
mcp-attest fingerprint --server https://mcp.example.com
# 计算信任分数
mcp-attest trust --server https://mcp.example.com
# 生成 MCPGuard 访问策略
mcp-attest policy --server https://mcp.example.com --min-score 75
```
### Python API 🐍
```
from mcp_attest import Attester
attester = Attester()
report = await attester.full_attestation(
server_url="https://mcp.example.com",
)
print(f"Trust score: {report.trust.score}/100")
print(f"Identity: {'✅' if report.identity.verified else '❌'}")
print(f"Integrity: {report.integrity.status.value}")
```
## 对比 📊
| 能力 | **MCP Attest** | 原生 MCP 客户端 | mcp-scan |
|---|---|---|---|
| TLS 身份验证 | ✅ 多种方式 | 基础 | ❌ |
| 加密签名 | ✅ RSA-2048 SHA-256 | ❌ | ❌ |
| DID 验证 | ✅ did:web + did:key | ❌ | ❌ |
| 能力指纹识别 | ✅ SHA-256 清单哈希 | ❌ | ❌ |
| 信任评分 | ✅ 加权(4 个维度) | ❌ | ❌ |
| 权限审计 | ✅ 最小权限评分 | ❌ | ❌ |
| 撤销检查 | ✅ 可配置列表 | ❌ | ❌ |
| MCPGuard 策略导出 | ✅ 自动生成 YAML | ❌ | ❌ |
| SARIF 报告 | ✅ | ❌ | ✅ |
## 生态系统 🔗
| 工具 | 集成 |
|---|---|
| [MCPGuard](https://github.com/Carlos-Projects/mcpguard) | 运行时策略执行中间件 |
| [MCPscop](https://github.com/Carlos-Projects/mcpscope) | 证明报告的仪表盘可视化 |
| [mcpwn](https://github.com/Carlos-Projects/mcpwn) | 针对证明基线的进攻性安全测试 |
| [mcp-taxonomy](https://github.com/Carlos-Projects/mcp-taxonomy) | MCP 安全的规范化分类法 |
## 开发 🛠️
```
pip install -e ".[dev]"
ruff check .
mypy src/mcp_attest/
pytest
```
## 学术参考 📚
- [arXiv:2605.24248](https://arxiv.org/abs/2605.24248) — Attested Tool-Server Admission
- [arXiv:2605.25376](https://arxiv.org/abs/2605.25376) — KYA: Trust Layer for Autonomous Systems
- [MCP 规范](https://modelcontextprotocol.io/)
- [NIST AI RMF 1.0](https://www.nist.gov/itl/ai-risk-management-framework)
- [MITRE ATLAS](https://atlas.mitre.org/)
## 安全 🔒
发现漏洞?请参见 [SECURITY.md](SECURITY.md)。
## 许可证 📄
MIT — 详情请参阅 [LICENSE](LICENSE)。
标签:MCP, Python, Streamlit, 人工智能, 完整性校验, 底层编程, 无后门, 权限审计, 用户模式Hook绕过, 访问控制, 逆向工具