mdtj-mcp-server
3.3
If you are the rightful owner of mdtj-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Intelligent Form Collection MCP Server is designed for conflict mediation business, integrating with major model platforms using the MCP protocol.
智能表单收集MCP服务器
🚀 项目概述
智能表单收集MCP服务器是一个专门为矛盾调解业务设计的智能表单收集系统,支持通过MCP协议与Cursor、Dify、毕昇等大模型平台集成。
✨ 核心特性
- 🐍 Python 3.12 + DeepSeek大模型
- 🗄️ MySQL数据库支持
- 🔌 标准MCP协议实现
- 🌊 流式输出支持
- 🧠 智能信息提取
- 📊 Markdown表格展示
- 🔄 实时验证和进度跟踪
- 🐳 Docker容器化部署
📋 收集字段
个人基本信息
- 申请人姓名 (必填)
- 联系电话 (必填,11位手机号)
- 联系地址 (必填,详细地址)
事件信息
- 事件发生时间 (必填)
- 事件发生地点 (必填)
- 事件详情描述 (必填,详细描述)
- 涉及人数 (必填,数字)
🛠️ 技术架构
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Cursor/Dify/毕昇 │ │ MCP服务器 │ │ DeepSeek │
│ 大模型平台 │◄──►│ (Python 3.12) │◄──►│ 大模型 │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ MySQL数据库 │
│ 表单数据存储 │
└──────────────────┘
🚀 快速开始
1. 环境要求
- Docker & Docker Compose (推荐)
- 或 Python 3.12 + MySQL
- DeepSeek API密钥
2. 环境变量配置
创建环境变量文件
# 复制示例配置文件
cp env.example .env
# 编辑配置文件
vim .env
必需配置项
# 数据库配置 (必填)
DATABASE_URL=mysql+aiomysql://username:password@host:port/database
# DeepSeek API配置 (必填)
DEEPSEEK_API_KEY=your_deepseek_api_key_here
可选配置项
# LLM配置
LLM_PROVIDER=deepseek
LLM_MODEL=deepseek-chat
LLM_STREAM=true
# 系统配置
LOG_LEVEL=INFO
SESSION_TIMEOUT=3600
3. 部署方式
方式一:Docker Compose启动(推荐)
# 克隆项目
git clone <repository-url>
cd mdtj_mcp_server
# 启动服务
docker-compose up -d
# 查看日志
docker-compose logs -f
# 检查状态
curl http://localhost:7000/health
方式二:Docker单容器启动
# 构建镜像
docker build -t mdtj_mcp_server:latest .
# 运行容器
docker run -d -p 7000:7000 --name mdtj_mcp_server \
--env-file .env \
mdtj_mcp_server:latest
# 检查状态
docker logs mdtj_mcp_server
curl http://localhost:7000/health
方式三:本地Python启动
# 激活虚拟环境
source py312/bin/activate
# 加载环境变量
source .env
# 启动HTTP服务器
python http_server.py
# 或启动标准MCP服务器
python mcp_server_final.py
方式四:使用管理脚本
# 启动所有服务
./start_server.sh start
# 检查服务状态
./start_server.sh status
# 查看服务信息
./start_server.sh info
# 停止服务
./start_server.sh stop
3. 验证部署
服务器启动成功后,访问以下端点验证:
# 健康检查
curl http://localhost:7000/health
# 工具列表
curl -X POST http://localhost:7000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}'
# SSE端点
curl http://localhost:7000/sse
🔧 MCP工具列表
工具名称 | 功能描述 | 参数 |
---|---|---|
start_form_collection | 开始新的表单收集会话 | template_name , stream |
collect_field_info | 收集用户输入的字段信息 | session_id , user_input , stream |
get_collection_status | 获取当前收集状态 | session_id |
validate_form_data | 验证表单数据完整性 | session_id |
submit_form | 提交完整表单 | session_id |
get_session_statistics | 获取系统统计信息 | 无 |
🎯 平台集成
Cursor集成
-
配置MCP服务器
在Cursor的设置中添加MCP配置:
{ "mcpServers": { "mdtj_mcp_server": { "command": "python", "args": ["/opt/mdtj_mcp_server/mcp_server_final.py"], "cwd": "/opt/mdtj_mcp_server" } } }
-
使用工具
在Cursor中直接调用MCP工具:
@mdtj_mcp_server start_form_collection template_name="mediation"
Dify平台集成
-
HTTP API方式(推荐)
{ "name": "智能表单收集器", "type": "api", "api": { "url": "http://localhost:7000/mcp", "method": "POST", "headers": { "Content-Type": "application/json" } } }
-
自定义工具配置
- 工具名称:智能表单收集器
- API端点:
http://localhost:7000/mcp
- 请求格式:JSON-RPC 2.0
-
智能体提示词
你是一个专业的矛盾调解业务受理助手,负责帮助用户完成表单信息收集。 ## 工作流程 1. 使用 start_form_collection 开始收集 2. 使用 collect_field_info 收集用户信息 3. 使用 get_collection_status 查看进度 4. 使用 validate_form_data 验证数据 5. 使用 submit_form 提交表单 ## 交互原则 - 保持专业友好的语调 - 鼓励用户一次性提供多个信息 - 使用表格清晰展示收集状态 - 及时验证和确认用户信息
毕昇平台集成
-
API集成方式
api_tools: - name: "智能表单收集" endpoint: "http://localhost:7000/mcp" method: "POST" format: "json-rpc"
-
插件开发方式
- 基于HTTP API开发自定义插件
- 支持流式输出和实时更新
- 集成到毕昇工作流中
📝 使用示例
完整对话流程
1. 开始收集
用户: 我要申请矛盾调解
助手: [调用 start_form_collection]
欢迎使用矛盾调解业务受理系统!我需要收集以下信息...
2. 信息收集
用户: 我叫张三,电话13812345678,住在北京市朝阳区建国路1号院。
昨天下午3点在小区门口和邻居发生了争执,涉及2个人。
助手: [调用 collect_field_info]
感谢您提供的信息!我已经记录了您的基本信息和事件概况...
3. 状态查询
助手: [调用 get_collection_status]
当前收集进度:85.7%
| 字段 | 状态 | 值 |
|------|------|------|
| 申请人姓名 | ✅ 已收集 | 张三 |
| 联系电话 | ✅ 已收集 | 13812345678 |
...
4. 表单提交
助手: [调用 submit_form]
表单提交成功!您的申请编号是:MD20250615001
🔧 配置说明
环境变量
变量名 | 说明 | 默认值 |
---|---|---|
DATABASE_URL | MySQL数据库连接URL | 必填 |
DEEPSEEK_API_KEY | DeepSeek API密钥 | 必填 |
LLM_PROVIDER | LLM提供商 | deepseek |
LLM_MODEL | LLM模型名称 | deepseek-chat |
LLM_STREAM | 是否启用流式输出 | true |
LOG_LEVEL | 日志级别 | INFO |
数据库配置
系统使用MySQL数据库存储表单数据,包含以下表:
form_sessions
- 表单收集会话form_submissions
- 完整表单提交记录
服务端点
- HTTP服务器:
http://localhost:7000
- MCP端点:
http://localhost:7000/mcp
- SSE端点:
http://localhost:7000/sse
- 健康检查:
http://localhost:7000/health
- 工具列表:
http://localhost:7000/tools
📊 监控和日志
日志文件
- HTTP服务器日志:
logs/http_server.log
- MCP服务器日志:
logs/mcp_server.log
健康检查
# 检查服务状态
curl http://localhost:7000/health
# 检查工具可用性
curl -X POST http://localhost:7000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}'
Docker监控
# 查看容器状态
docker ps
# 查看容器日志
docker logs mdtj_mcp_server
# 查看资源使用
docker stats mdtj_mcp_server
🛠️ 开发和维护
本地开发
# 安装依赖
pip install -r requirements.txt
# 运行测试
pytest
# 代码格式化
black .
isort .
构建和发布
# 构建Docker镜像
docker build -t mdtj_mcp_server:v1.0.0 .
# 推送到镜像仓库
docker tag mdtj_mcp_server:v1.0.0 your-registry/mdtj_mcp_server:v1.0.0
docker push your-registry/mdtj_mcp_server:v1.0.0
📚 相关文档
- - 详细的平台配置指南
- - 完整的项目总结
- - 服务器管理工具
🤝 贡献
欢迎提交Issue和Pull Request来改进项目!
📄 许可证
本项目采用MIT许可证。