QWED-MCP 🔌
Deterministic Verification for Claude Desktop & VS Code
[](https://pypi.org/project/qwed-mcp/)
[](https://hub.docker.com/r/qwedai/qwed-verification)
[](https://hub.docker.com/r/qwedai/qwed-verification/tags)
[](https://www.cloudflare.com/)
[](https://snyk.io/test/github/QWED-AI/qwed-mcp)
[](https://docs.qwedai.com)
[](https://www.netlify.com)
[](https://opensource.org/licenses/Apache-2.0)
[](https://modelcontextprotocol.io)
[](https://github.com/QWED-AI/qwed-mcp)
[](https://github.com/QWED-AI/qwed-verification#%EF%B8%8F-what-does-verified-by-qwed-mean)
**QWED Verification 的 MCP Server** — 为 Claude Desktop、VS Code 以及任何兼容 MCP 的 AI 助手带来确定性验证。
## ⚡ 快速安装
```
pip install qwed-mcp
```
## 🚀 在 Claude Desktop 中配置
### 第 1 步:查找你的配置文件
| 操作系统 | 路径 |
|----|------|
| **Windows** | `%APPDATA%\Claude\claude_desktop_config.json` |
| **macOS** | `~/Library/Application Support/Claude/claude_desktop_config.json` |
| **Linux** | `~/.config/Claude/claude_desktop_config.json` |
### 第 2 步:添加 QWED-MCP
**macOS/Linux:**
```
{
"mcpServers": {
"qwed-verification": {
"command": "qwed-mcp"
}
}
}
```
**Windows(使用 python -m):**
```
{
"mcpServers": {
"qwed-verification": {
"command": "python",
"args": ["-m", "qwed_mcp.server"]
}
}
}
```
### 第 3 步:重启 Claude Desktop
完全退出(系统托盘 → 退出)并重新打开。
### 第 4 步:测试吧!
询问 Claude:
## ⚠️ 迁移提示:弃用 `verify_*` 工具
为了解决“上下文臃肿”问题并符合新的 MCP 标准 (RFC-9728),所有 1:1 的功能工具(例如 `verify_math`、`verify_sql`、`verify_code`)自 `v0.2.1` 版本起**已被移除**。
它们已被一个功能强大的单一工具所取代:
**👉 `execute_python_code`**
**之前:**
**之后:**
如果你看到 `"Unknown tool"` 错误,说明 Claude 正在尝试使用旧版工具。只需告诉 Claude:*“`verify_*` 工具已被移除。请使用 `execute_python_code` 原生编写并运行 Python 验证脚本。”*
## 🔧 可用工具
| 工具 | 描述 | 用例 |
|------|-------------|----------|
| `execute_python_code` | **子进程执行** | 所有 QWED 功能的单一入口点。在具有受限环境变量的子进程中执行动态生成的 Python 代码。注意:以服务器权限运行;请确保输入是受信任的。 |
## 💡 Claude 示例提示词
### 财务计算
```
A bank says: "Invest $10,000 at 7.5% compounded quarterly for 5 years = $14,356.29"
Please write a short Python script using the standard compound interest formula to verify this, and run it with execute_python_code.
```
### 贷款 EMI 验证
```
Verify: ₹10,00,000 loan at 9% for 5 years = EMI of ₹20,758
Write a python script importing necessary tools to verify this EMI calculation, and execute it using execute_python_code.
```
### 复杂的推理工作流(Python 的力量)
```
Read the user terms in the attached document.
1. Use execute_python_code to extract and verify the legal clauses using qwed_legal.
2. In the same script, verify if the referenced financial penalties align with the allowed boundaries.
```
## 🏗️ 工作原理
```
┌───────────────────────────────────────────┐
│ Claude Desktop / VS Code │
│ (MCP Client) │
└─────────────────┬─────────────────────────┘
│ MCP Protocol (JSON-RPC)
▼
┌───────────────────────────────────────────┐
│ QWED-MCP Server │
├───────────────────────────────────────────┤
│ execute_python_code() │
│ └─► Subprocess Execution (Restricted Env)│
│ └─► Native QWED library execution │
└───────────────────────────────────────────┘
```
## 🎯 为什么选择 QWED-MCP?
| 没有 QWED-MCP | 有 QWED-MCP |
|------------------|---------------|
| LLM 计算 → 95% 正确率 | 执行调用 `qwed_finance` 的 Python 脚本 → **100% 正确** |
| LLM 编写 SQL → 可能会被注入 | 脚本使用 `qwed_new` 分析器 → **检测到注入** |
| LLM 推理 → 可能出错 | 通过 SDK 执行 Z3 求解器 → **经过形式化验证** |
| LLM 编写代码 → 可能不安全 | 执行了 AST 检查脚本 → **进行了安全检查** |
## 💡 QWED-MCP 是什么(以及不是什么)
### ✅ QWED-MCP 是:
- **MCP Server** — 为 Claude Desktop 和 VS Code 添加验证工具
- **确定性的** — 使用 SymPy(数学)、Z3(逻辑)、AST(代码)进行精确验证
- **开源的** — 兼容任何支持 MCP 的 AI 助手
- **安全层** — 实时捕获 LLM 幻觉
### ❌ QWED-MCP 不是:
- ~~Claude 的替代品~~ — 它是通过验证工具来增强 Claude
- ~~聊天机器人~~ — 它是 Claude 调用的后端服务器
- ~~联网的~~ — 所有验证均在本地进行
- ~~经过微调的模型~~ — 使用符号引擎,而非机器学习 (ML)
## 🆚 我们与其他 MCP Server 有何不同
| 方面 | 其他 MCP Server | QWED-MCP |
|--------|-------------------|----------|
| **目的** | 连接到 API、数据库、文件 | 验证 LLM 输出 |
| **方法** | 获取外部数据 | 计算确定性证明 |
| **引擎** | API 包装器 | SymPy、Z3、AST 分析器 |
| **准确性** | 取决于数据源 | 100% 经数学证明 |
| **离线** | 通常需要互联网 | 完全本地,无需 API |
### 在 Claude Desktop 中
```
┌───────────────────┐ ┌───────────────────────┐ ┌───────────────────┐
│ Claude │ │ QWED-MCP │ │ Verified Answer │
│ "What's d/dx x³?" │ ──► │ execute_python_code() │ ──► │ "3x²" ✓ │
│ "Write script to │ │ Runs SymPy natively │ │ (STDOUT Captured) │
│ check." │ └───────────────────────┘ └───────────────────┘
└───────────────────┘
```
## 🔒 安全与隐私
| 关注点 | QWED-MCP 方案 |
|---------|-------------------|
| **数据传输** | ❌ 无外部 API 调用 |
| **存储** | ❌ 不记录或存储任何内容 |
| **依赖项** | ✅ 本地引擎(SymPy、Z3) |
| **代码分析** | ✅ 你的代码永远不会离开你的机器 |
**非常适合:**
- 具有严格安全策略的企业
- 物理隔离的开发环境
- 敏感的代码审查工作流
## ❓ 常见问题解答
QWED-MCP 是免费的吗?
是的!在 Apache 2.0 下开源。可将其用于商业用途、修改或分发。
它能在 VS Code Copilot 中使用吗?
QWED-MCP 兼容任何支持 MCP 的客户端。带有 Claude 扩展的 VS Code 支持 MCP,所以可以的!
我需要 API key 吗?
不需要。QWED-MCP 完全在本地运行。无需 API key,无需调用云端。
这个和 QWED-Core 有什么区别?
QWED-Core 是 Python 库。QWED-MCP 将其封装为 MCP 服务器,以便 Claude 可以将其作为工具使用。
我可以添加自己的验证工具吗?
可以!该服务器是可扩展的。Fork 它并添加你自定义的 `@mcp.tool()` 函数。
## 🗺️ 路线图
### ✅ 已发布 (v0.2.1)
- [x] 解决上下文臃肿问题(兼容 RFC-9728)
- [x] 统一的 `execute_python_code` 环境
- [x] 安全的进程隔离(环境受限)和健壮的超时机制
- [x] Claude Desktop 集成
- [x] 支持 Windows/macOS/Linux
### 🚧 进行中
- [ ] `verify_json` — JSON Schema 验证工具
- [ ] `verify_finance` — NPV/IRR/摊销工具
- [ ] Cursor IDE 集成指南
### 🔮 计划中
- [ ] `verify_legal` — 截止日期和责任验证
- [ ] `verify_statistics` — 假设检验验证
- [ ] 用于 Web UI 的 SSE (Server-Sent Events) 传输
- [ ] TypeScript 实现
## 📁 示例
请查看 [`examples/`](./examples) 文件夹以获取:
- Python 客户端用法
- 示例验证脚本
- 集成示例
## 🛠️ 开发
```
# 克隆
git clone https://github.com/QWED-AI/qwed-mcp.git
cd qwed-mcp
# 安装 dev dependencies
pip install -e ".[dev]"
# 运行 tests
pytest tests/ -v
# 格式化代码
black src/
```
## 📖 文档
| 资源 | 链接 |
|----------|------|
| 完整文档 | [docs.qwedai.com/mcp](https://docs.qwedai.com/docs/mcp/overview) |
| 工具参考 | [docs.qwedai.com/mcp/tools](https://docs.qwedai.com/docs/mcp/tools) |
| 示例 | [docs.qwedai.com/mcp/examples](https://docs.qwedai.com/docs/mcp/examples) |
| 故障排除 | [docs.qwedai.com/mcp/troubleshooting](https://docs.qwedai.com/docs/mcp/troubleshooting) |
| MCP 协议 | [modelcontextprotocol.io](https://modelcontextprotocol.io) |
## 🔗 相关项目
- **QWED Core** — [github.com/QWED-AI/qwed-verification](https://github.com/QWED-AI/qwed-verification)
- **QWED-UCP** — [github.com/QWED-AI/qwed-ucp](https://github.com/QWED-AI/qwed-ucp)
- **QWED Open Responses** — [github.com/QWED-AI/qwed-open-responses](https://github.com/QWED-AI/qwed-open-responses)
## 📄 许可证
Apache 2.0 — 请参阅 [LICENSE](LICENSE)
由 QWED AI 构建
通过形式化验证让 AI 输出值得信赖