trackmcp
Back to directory
xiaoshi7915

mdtj-mcp-server

View on GitHub

一个用于矛盾调解业务受理智能表单收集MCP服务器

1 stars PythonOthers Updated Jun 30, 2025

Documentation

智能表单收集MCP服务器

🚀 项目概述

智能表单收集MCP服务器是一个专门为矛盾调解业务设计的智能表单收集系统,支持通过MCP协议与Cursor、Dify、毕昇等大模型平台集成。

✨ 核心特性

  • 🐍 Python 3.12 + DeepSeek大模型
  • 🗄️ MySQL数据库支持
  • 🔌 标准MCP协议实现
  • 🌊 流式输出支持
  • 🧠 智能信息提取
  • 📊 Markdown表格展示
  • 🔄 实时验证和进度跟踪
  • 🐳 Docker容器化部署

📋 收集字段

个人基本信息

  • 申请人姓名 (必填)
  • 联系电话 (必填,11位手机号)
  • 联系地址 (必填,详细地址)

事件信息

  • 事件发生时间 (必填)
  • 事件发生地点 (必填)
  • 事件详情描述 (必填,详细描述)
  • 涉及人数 (必填,数字)

🛠️ 技术架构

code
┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│ Cursor/Dify/毕昇 │    │   MCP服务器      │    │   DeepSeek      │
│   大模型平台     │◄──►│   (Python 3.12) │◄──►│   大模型        │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                              │
                              ▼
                       ┌──────────────────┐
                       │   MySQL数据库    │
                       │   表单数据存储    │
                       └──────────────────┘

🚀 快速开始

1. 环境要求

  • Docker & Docker Compose (推荐)
  • 或 Python 3.12 + MySQL
  • DeepSeek API密钥

2. 环境变量配置

创建环境变量文件

bash
# 复制示例配置文件
cp env.example .env

# 编辑配置文件
vim .env

必需配置项

bash
# 数据库配置 (必填)
DATABASE_URL=mysql+aiomysql://username:password@host:port/database

# DeepSeek API配置 (必填)
DEEPSEEK_API_KEY=your_deepseek_api_key_here

可选配置项

bash
# LLM配置
LLM_PROVIDER=deepseek
LLM_MODEL=deepseek-chat
LLM_STREAM=true

# 系统配置
LOG_LEVEL=INFO
SESSION_TIMEOUT=3600

3. 部署方式

方式一:Docker Compose启动(推荐)

bash
# 克隆项目
git clone 
cd mdtj_mcp_server

# 启动服务
docker-compose up -d

# 查看日志
docker-compose logs -f

# 检查状态
curl http://localhost:7000/health

方式二:Docker单容器启动

bash
# 构建镜像
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启动

bash
# 激活虚拟环境
source py312/bin/activate

# 加载环境变量
source .env

# 启动HTTP服务器
python http_server.py

# 或启动标准MCP服务器
python mcp_server_final.py

方式四:使用管理脚本

bash
# 启动所有服务
./start_server.sh start

# 检查服务状态
./start_server.sh status

# 查看服务信息
./start_server.sh info

# 停止服务
./start_server.sh stop

3. 验证部署

服务器启动成功后,访问以下端点验证:

bash
# 健康检查
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集成

1. 配置MCP服务器

在Cursor的设置中添加MCP配置:

json
{
     "mcpServers": {
       "mdtj_mcp_server": {
         "command": "python",
         "args": ["/opt/mdtj_mcp_server/mcp_server_final.py"],
         "cwd": "/opt/mdtj_mcp_server"
       }
     }
   }

2. 使用工具

在Cursor中直接调用MCP工具:

code
@mdtj_mcp_server start_form_collection template_name="mediation"

Dify平台集成

1. HTTP API方式(推荐)

json
{
     "name": "智能表单收集器",
     "type": "api",
     "api": {
       "url": "http://localhost:7000/mcp",
       "method": "POST",
       "headers": {
         "Content-Type": "application/json"
       }
     }
   }

2. 自定义工具配置

    3. 智能体提示词

    markdown
    你是一个专业的矛盾调解业务受理助手,负责帮助用户完成表单信息收集。
    
       ## 工作流程
       1. 使用 start_form_collection 开始收集
       2. 使用 collect_field_info 收集用户信息
       3. 使用 get_collection_status 查看进度
       4. 使用 validate_form_data 验证数据
       5. 使用 submit_form 提交表单
    
       ## 交互原则
       - 保持专业友好的语调
       - 鼓励用户一次性提供多个信息
       - 使用表格清晰展示收集状态
       - 及时验证和确认用户信息

    毕昇平台集成

    1. API集成方式

    yaml
    api_tools:
         - name: "智能表单收集"
           endpoint: "http://localhost:7000/mcp"
           method: "POST"
           format: "json-rpc"

    2. 插件开发方式

      📝 使用示例

      完整对话流程

      1. 开始收集

      code
      用户: 我要申请矛盾调解
      助手: [调用 start_form_collection]
            欢迎使用矛盾调解业务受理系统!我需要收集以下信息...

      2. 信息收集

      code
      用户: 我叫张三,电话13812345678,住在北京市朝阳区建国路1号院。
            昨天下午3点在小区门口和邻居发生了争执,涉及2个人。
      助手: [调用 collect_field_info]
            感谢您提供的信息!我已经记录了您的基本信息和事件概况...

      3. 状态查询

      code
      助手: [调用 get_collection_status]
            当前收集进度:85.7%
            | 字段 | 状态 | 值 |
            |------|------|------|
            | 申请人姓名 | ✅ 已收集 | 张三 |
            | 联系电话 | ✅ 已收集 | 13812345678 |
            ...

      4. 表单提交

      code
      助手: [调用 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`

      健康检查

      bash
      # 检查服务状态
      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监控

      bash
      # 查看容器状态
      docker ps
      
      # 查看容器日志
      docker logs mdtj_mcp_server
      
      # 查看资源使用
      docker stats mdtj_mcp_server

      🛠️ 开发和维护

      本地开发

      bash
      # 安装依赖
      pip install -r requirements.txt
      
      # 运行测试
      pytest
      
      # 代码格式化
      black .
      isort .

      构建和发布

      bash
      # 构建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许可证。

      Frequently asked questions

      What is mdtj-mcp-server?

      mdtj-mcp-server is 一个用于矛盾调解业务受理智能表单收集MCP服务器

      How do I install mdtj-mcp-server?

      Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

      Is mdtj-mcp-server open source?

      Yes — it is hosted on GitHub at https://github.com/xiaoshi7915/mdtj-mcp-server and has 1 stars.

      Related MCP tools

      Run your own MCP server? See who uses it and what to fix.

      Measure it with TrackMCP