资格评估引擎

一个基于ZEN Engine决策引擎的规则评估系统,用于演示复杂业务规则的评估流程,适用于教育和开发参考。

  • by alpha-hack-program
  • Rust
  • 本地部署
  • 更新于
在 GitHub 查看 alpha-hack-program/eligibility-engine-mcp-rs

使用说明

合格引擎MCP服务器

示例模型上下文协议(MCP)服务器演示了基于虚构法规的休假辅助评估

一个用Rust开发的模型上下文协议(MCP)服务器示例,演示了如何使用ZEN引擎决策引擎评估复杂的业务规则。该项目可作为使用基于规则的决策系统构建MCP服务器的参考实现。

⚠️ 免责声明

本示例基于虚构的Lysmark共和国的虚构法规。有关本演示中使用的虚构法律框架、福利场景和资格规则的全部详细信息,请参阅 documents/ 文件夹。

这只是一个演示/示例项目。 这里实施的规定、金额和评估逻辑是虚构的,仅用于教育和演示目的。该软件:

  • 不应用于实际的法律或行政决策
  • 不代表真正的政府法规
  • 不隶属于任何官方政府实体
  • 作为MCP服务器实现的技术示例

有关休假援助的真实法律建议或官方信息,请咨询政府官方资源和合格的法律专业人士。

🎯 特性

  • 5个示例评估场景:演示复杂规则集(A-E)的实现
  • 决策引擎集成:演示如何使用ZEN引擎进行基于规则的评估
  • 多种传输协议:STDIO和流式HTTP实现的示例
  • 稳健的输入验证:演示JSON模式验证和详细的错误处理
  • 生产就绪集装箱化:部署的Docker/Podman设置示例
  • Claude桌面集成:MCP集成的MCPB封装示例
  • 专业版本管理:与货物放行自动版本同步
  • CI/CD管道:全面的GitHub操作工作流程
  • 专业知识库结构:有组织的脚本和干净的项目布局

📚 快速参考

任务 命令 描述
🏗️ 构建 make build-all 构建所有服务器
🧪 测试 make test 运行所有测试
🚀 发布 make release-patch 创建新的补丁版本
📦 包裹 make pack 创建Claude桌面包
🐳 容器 scripts/image.sh build 构建容器映像
🔄 同步 make sync-version 手动同步版本
ℹ️ 帮助 make help 显示所有命令

📋 援助场景示例(虚构)

场景 描述 每月金额示例
A. 一级亲属护理(疾病/事故) 725欧元
B 第三个或更多新生儿 500欧元
C 收养或寄养 500欧元
D 多胞胎、收养或寄养 500欧元
E 单亲家庭 500欧元

备注:这些场景和金额完全是虚构的,仅用于演示目的。

🚀 快速开始

先决条件

  • 锈蚀1.70+(安装Rust)
  • 货物(含铁锈)
  • jq 用于JSON处理(安装jq)
  • cargo-release 对于版本管理: cargo install cargo-release

安装

# Clone the repository
git clone https://github.com/alpha-hack-program/eligibility-engine-mcp-rs.git
cd eligibility-engine-mcp-rs

# Build all servers
make build-all

# Or build individually
make build-mcp      # MCP HTTP Server
make build-stdio    # STDIO Server for Claude

跑步

# MCP HTTP Server
make test-mcp

# Or directly
RUST_LOG=debug ./target/release/mcp_server

🔧 配置

环境变量

# Server configuration
RUST_LOG=info           # Logging level (debug, info, warn, error)

# Or use BIND_ADDRESS directly
BIND_ADDRESS=127.0.0.1:8000

示例用法

此输入表示对资格引擎的请求,以根据此查询确定某人是否有资格根据Lysmark法律获得无薪休假福利。

“我妻子刚刚生下我们的第三个孩子,我想知道我是否可以申请无薪休假补助。”

{
  `situation`: `birth`,
  `relationship`: `father`,
  `is_single_parent`: false,
  `total_children_after`: 3
}

申请人简介: 一位因孩子出生而请假的父亲 非单亲家庭(双亲家庭) 出生后将有两个孩子

案例分类: 确定为“病例B:第三个或更多新生儿” 如果满足要求,可能有资格获得每月725欧元的福利

示例响应:

{
  "output": {
    "description": "Third child or more with newborn",
    "monthly_benefit": 500,
    "additional_requirements": "The number of children must be 3 or more, the ages of at least 2 of the minors must be less than 6, if there is disability greater than 33% then the limit is 9 years",
    "case": "B",
    "potentially_eligible": true,
    "errores": [],
    "warnings": []
  },
  "input": {
    "relationship": "father",
    "situation": "birth",
    "is_single_parent": false,
    "total_children_after": 3.0
  },
  "relationship_valid": true
}

重要:这只是用于演示目的的示例数据。

🐳 容器化

构建并运行

这需要 podman 或 docker配置是通过以下方式进行管理的 .env 文件。

# Build container image
scripts/image.sh build

# Run locally
scripts/image.sh run

# Run from remote registry
scripts/image.sh push
scripts/image.sh run-remote

# Show container information
scripts/image.sh info

容器的环境变量

# Production configuration
podman run -p 8001:8001 \
  -e BIND_ADDRESS=0.0.0.0:8001 \
  -e RUST_LOG=info \
  quay.io/atarazana/eligibility-engine-mcp-server:latest

📦 Claude桌面集成

包装

# Create MCPB package for Claude Desktop
$ make pack
cargo build --release --bin stdio_server
   Compiling eligibility-engine-mcp-server v1.0.8 (/Users/.../eligibility-engine-mcp-rs)
    Finished `release` profile [optimized] target(s) in 18.23s
Packing MCP server for Claude Desktop...
chmod +x ./target/release/stdio_server
zip -rX eligibility-engine-mcp-server.mcpb -j mcpb/manifest.json ./target/release/stdio_server
updating: manifest.json (deflated 49%)
updating: stdio_server (deflated 63%)

克劳德配置示例

拖放 MCPB 文件进入 Settings->Extensions 下降区域。

备注:这展示了MCP集成模式,不适用于实际数据的生产使用。

🧪 测试

# Run all tests
make test

🛠️ 发展

可用命令

🏗️ 构建命令

make build-all              # Build all servers
make build-mcp              # Build MCP server (streamable-http)
make build-stdio            # Build stdio server
make pack                   # Pack MCP server for Claude Desktop

🚀 放行命令(货物放行)

make release-patch          # Create patch release (1.0.6 → 1.0.7)
make release-minor          # Create minor release (1.0.6 → 1.1.0)
make release-major          # Create major release (1.0.6 → 2.0.0)
make release-dry-run        # Show what release-patch would do
make sync-version           # Manually sync version to all files

🧪 测试命令

make test                   # Run all tests
make test-mcp               # Test MCP server locally

🔧 开发命令

make clean                  # Clean build artifacts
make help                   # Show all available commands

项目结构

├── src/                                    # Source code
│   ├── common/
│   │   ├── eligibility_engine.rs         # MCP logic and decision engine
│   │   └── mod.rs
│   ├── mcp_server.rs                      # MCP HTTP Server
│   └── stdio_server.rs                    # STDIO Server
├── scripts/                               # Utility scripts
│   ├── sync-manifest-version.sh           # Version sync for cargo-release
│   └── image.sh                          # Container management script
├── mcpb/
│   └── manifest.json                      # Claude Desktop manifest
├── .github/workflows/                     # CI/CD pipelines
│   └── ci.yml                            # GitHub Actions workflow
├── docs/                                  # Documentation
├── .env                                   # Environment variables
├── Containerfile                          # Container definition
├── Cargo.toml                            # Rust package manifest
└── Makefile                              # Build commands

调试和监控

首先运行Streamable HTTP服务器:

$ make test-mcp
cargo build --release --bin mcp_server
   Compiling eligibility-engine-mcp-server v1.0.6 (/Users/cvicensa/Projects/rust/claude/eligibility-engine-mcp-rs)
    Finished `release` profile [optimized] target(s) in 18.26s
🧪 Testing Streamable HTTP server...

RUST_LOG=debug ./target/release/mcp_server
2025-09-22T16:53:01.931985Z  INFO mcp_server: Starting Streamable HTTP Eligibility Engine MCP server on 127.0.0.1:8000

其次,运行MCP检查器:

注: 必须安装NodeJS 19+

$ make inspector
npx @modelcontextprotocol/inspector
Starting MCP inspector...
⚙️ Proxy server listening on 127.0.0.1:6277
🔑 Session token: 6f0fdc22e2a9775a95d60c976b37b873bffec1816002fc702ca8ec7186a7c338
Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth

🔗 Open inspector with token pre-filled:
   http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=6f0fdc22e2a9775a95d60c976b37b873bffec1816002fc702ca8ec7186a7c338

🔍 MCP Inspector is up and running at http://127.0.0.1:6274 🚀

打开浏览器,指向包含令牌的URL。

故障排除:

MCP错误-32602:参数反序列化失败:缺少字段 is_single_parent

只需点击复选框 is_single_parent 然后再试一次。

📚 api参考

主要终点

发布 /message -规则评估的示例端点

示例输入参数

字段 类型 必填 描述
relationship string ✅ 家庭关系(父亲、母亲、儿子、女儿、配偶、伴侣、丈夫、妻子、女人、男人)
situation string ✅ 护理原因(出生、收养、寄养、疾病、事故等)
is_single_parent boolean ✅ 这是单亲家庭吗?
total_children_after 编号 ❌ 子女人数(可选,案例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最低标准

🤝 贡献

开发流程

  1. 分叉项目
  2. 创建特征分支: git checkout -b feature/new-feature
  3. 进行更改和测试: make test
  4. 提交更改: git commit -am 'Add new feature'
  5. 推送到分支: git push origin feature/new-feature
  6. 创建拉取请求

专业发布流程

  1. 发展:进行更改,测试 make test
  2. 版本颠簸:使用 make release-patch/minor/major
  3. 构建:使用 make pack 用于Claude Desktop集成
  4. 容器:使用 scripts/image.sh build 集装箱化

指南

  • 代码质量:关注 cargo fmt 并通过 cargo clippy
  • 测试:添加新功能的测试
  • 版本管理:让货物放行处理版本控制
  • CI/CD:确保所有GitHub操作都通过
  • 文档:根据需要更新README.md
  • 专业结构:保留脚本 scripts/ 目录

⚙️ 版本管理

此项目使用 货物放行 用于跨所有配置文件自动同步的专业版本管理。

🔄 版本同步系统

  • 单一真相来源: Cargo.toml 版本控制一切
  • 自动同步:更新 mcpb/manifest.json 和 .env 自动地
  • Git集成:自动创建提交和标记

📦 发布工作流

# 1. Make your changes and commit them
git add -A && git commit -m "feat: your changes"

# 2. Create a release (choose appropriate version bump)
make release-patch     # Bug fixes: 1.0.6 → 1.0.7
make release-minor     # New features: 1.0.6 → 1.1.0  
make release-major     # Breaking changes: 1.0.6 → 2.0.0

# 3. Build and package
make pack
scripts/image.sh build
scripts/image.sh push

# 4. Push to repository
git push && git push --tags

🔍 预览更改

# See what would happen without making changes
make release-dry-run

🛠️ 手动版本同步(开发)

# Sync version from Cargo.toml to other files manually
make sync-version

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 了解详情。

🚀 生产部署

环境配置

该项目使用 .env 环境管理:

# Version (automatically managed by cargo-release)
VERSION=1.0.6

# Container Configuration  
APP_NAME="eligibility-engine-mcp-rs"
BASE_IMAGE="registry.access.redhat.com/ubi9/ubi-minimal"
PORT=8001

# Registry Configuration
REGISTRY=quay.io/atarazana

CI/CD管道

该项目包括一个全面的GitHub Actions工作流程:

  • ✅ 自动化测试:单元测试和集成测试
  • ✅ 版本同步验证:测试货物释放功能
  • ✅ 集装箱建筑:测试集装箱化过程
  • ✅ 工件管理:构建和上传发布工件
  • ✅ 与跨平台支持:在Ubuntu上使用多容器运行时进行测试

🙋 支持

🏷️ 标签

mcp model-context-protocol rust eligibility-engine unpaid-leave zen-engine claude decision-engine cargo-release professional-rust containerization ci-cd


与开发❤️ 通过 阿尔法黑客集团