优雅引擎MCP服务器
示例模型上下文协议(MCP)服务器演示了基于虚构法规的休假辅助评估
  
一个用Rust开发的模型上下文协议(MCP)服务器示例,演示了如何使用ZEN引擎决策引擎评估复杂的业务规则。该项目可作为使用基于规则的决策系统构建MCP服务器的参考实现。
⚠️ 免责声明
这只是一个演示/示例项目。 这里实施的规定、金额和评估逻辑是虚构的,仅用于教育和演示目的。该软件:
- 不应用于实际的法律或行政决策
- 不代表真正的政府法规
- 不隶属于任何官方政府实体
- 作为MCP服务器实现的技术示例
有关休假援助的真实法律建议或官方信息,请咨询政府官方资源和合格的法律专业人士。
🎯 特性
- 5个示例评估场景:演示复杂规则集(A-E)的实现
- 决策引擎集成:演示如何使用ZEN引擎进行基于规则的评估
- 多种传输协议:STDIO、SSE和HTTP流式传输实现的示例
- 稳健的输入验证:演示JSON模式验证和详细的错误处理
- 生产就绪集装箱化:部署的Docker/Podman设置示例
- Claude桌面集成:MCP集成的DXT封装示例
📋 援助场景示例(虚构)
| 场景 | 描述 | 每月金额示例 |
|---|---|---|
| A. | 一级亲属护理(疾病/事故) | 725欧元 |
| B | 第三个或更多新生儿 | 500欧元 |
| C | 收养或寄养 | 500欧元 |
| D | 多胞胎、收养或寄养 | 500欧元 |
| E | 单亲家庭 | 500欧元 |
备注:这些场景和金额完全是虚构的,仅用于演示目的。
🚀 快速开始
先决条件
- 锈蚀1.70+(安装Rust)
- 货物(含铁锈)
安装
# Clone the repository
git clone https://github.com/alpha-hack-program/elegibility-engine-mcp-rs.git
cd elegibility-engine-mcp-rs
# Build all servers
make build-all
# Or build individually
make build-sse # SSE Server
make build-mcp # MCP HTTP Server
make build-stdio # STDIO Server for Claude跑步
# SSE Server (recommended for development)
make test-sse
# MCP HTTP Server
make test-mcp
# Or directly
RUST_LOG=debug ./target/release/sse_server🔧 配置
环境变量
# Server configuration
HOST=127.0.0.1 # Bind address (0.0.0.0 for containers)
PORT=8001 # Server port
RUST_LOG=info # Logging level (debug, info, warn, error)
# Or use BIND_ADDRESS directly
BIND_ADDRESS=127.0.0.1:8001示例用法
{
"input": {
"relationship": "mother",
"situation": "illness",
"single_parent_family": false,
"number_of_children": 2
}
}示例响应:
{
"output": {
"case": "A",
"description": "Care for first-degree relative (illness or accident)",
"monthly_benefit": 725,
"potentially_eligible": true,
"additional_requirements": "The person must have been hospitalized..."
}
}重要:这只是用于演示目的的示例数据。
🐳 容器化
构建并运行
这需要 podman 或 docker.适应 .env 满足您的需求。
# Build container image
./image.sh build
# Run locally
./image.sh run
# Run from remote registry
./image.sh push
./image.sh run-remote容器的环境变量
# Production configuration
docker run -p 8001:8001 \
-e HOST=0.0.0.0 \
-e PORT=8001 \
-e RUST_LOG=info \
quay.io/atarazana/elegibility-engine-mcp-server:latest📦 Claude桌面集成
包装
# Create DXT package for Claude Desktop
make pack克劳德配置示例
拖放 DXT 文件进入 Settings->Extensions 下降区域。
备注:这展示了MCP集成模式,不适用于实际数据的生产使用。
🧪 测试
# Run all tests
make test手动测试示例
运行服务器: make test-sse 或 ./image.sh run.
这需要NodeJS 19+。
在另一个终端。
make inspector然后将浏览器连接到MCP检查器给出的建议网址。一旦连接到 http://localhost:${PORT}/sse
PORT已设置.env
连接并列出工具,选择工具并使用此JSON。
{
"relationship": "son",
"situation": "birth",
"single_parent_family": true
}🛠️ 发展
可用命令
make help # Show help
make build-all # Build all servers
make clean # Clean artifacts
make fmt # Format code
make lint # Run clippy
make audit # Security audit
make dev # Development server with auto-reload项目结构
├── src/
│ ├── common/
│ │ ├── eligibility_engine.rs # MCP logic and decision engine
│ │ └── mod.rs
│ ├── sse_server.rs # SSE Server
│ ├── mcp_server.rs # MCP HTTP Server
│ └── stdio_server.rs # STDIO Server
├── dxt/
│ └── manifest.json # Claude Desktop manifest
├── Containerfile # Container definition
├── Makefile # Build commands
└── container.sh # Container management script调试和监控
# Debug proxy
make proxy # Start mitmproxy on port 8888
# MCP Inspector
make inspector # Start MCP Inspector
# Supergateway for SSE
make sgw-sse # STDIO -> SSE wrapping
# Supergateway for MCP
make sgw-mcp # STDIO -> MCP HTTP wrapping📚 api参考
主要终点
发布 /message -规则评估的示例端点
示例输入参数
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
relationship | string | ✅ | 家庭关系(父亲、母亲、儿子、女儿、配偶、伴侣、丈夫、妻子、女人、男人) |
situation | string | ✅ | 护理原因(出生、收养、寄养、疾病、事故等) |
single_parent_family | boolean | ✅ | 这是单亲家庭吗? |
number_of_children | 编号 | ❌ | 子女人数(可选,案例B需要) |
响应
| 字段 | 类型 | 描述 |
|---|---|---|
case | string | 适用场景字母(A-E) |
description | string | 场景描述 |
monthly_benefit | number | 每月金额(欧元) |
potentially_eligible | boolean | 是否满足基本要求? |
additional_requirements | string | 其他特定要求 |
errores | array | 验证错误列表 |
warnings | array | 警告和其他信息 |
🔒 安全
- 输入验证:严格的JSON模式
- 非root用户:容器以用户身份运行
1001 - 安全审计:
cargo audit在CI/CD中 - 最小图像:基于UBI 9最低标准
🤝 贡献
- 分叉项目
- 创建特征分支(
git checkout -b feature/new-feature) - 提交更改(
git commit -am 'Add new feature') - 推送到分支(
git push origin feature/new-feature) - 创建拉取请求
指南
- 遵循代码风格
cargo fmt - 通过linting
cargo clippy - 添加新功能的测试
- 根据需要更新文档
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 了解详情。
🙋 支持
- 问题:
- 文档: 维基工程
🏷️ 标签
mcp model-context-protocol rust eligibility-engine unpaid-leave zen-engine claude decision-engine
______________________________________________________________________
与开发❤️ 靠近 阿尔法黑客集团
