人机交互MCP服务器

一个允许AI助手通过Discord向人类提问的MCP服务器,用于需要人类输入或判断的场景。

  • by KOBA789
  • Rust
  • 本地部署
  • 231 星标
  • 更新于
在 GitHub 查看 KOBA789/human-in-the-loop

使用说明

人在环MCP服务器

MCP(模型上下文协议)服务器,允许AI助手通过Discord向人类提问。

概述

当人工智能助手在工作中需要人工输入或判断时,可以使用此MCP服务器。例如:

  • 当让LLM创建文档时,人工智能设计结构,而人类提供特定内容
  • 当人工智能需要确认不确定的决策时
  • 当需要专业知识或个人信息时

需求

  • 锈蚀(1.70或更高)
  • Discord帐户和机器人
  • MCP兼容的AI客户端(Claude Desktop、Copilot Edits等)

设置

1.创建Discord Bot

  1. 首选 Discord开发者门户
  2. 创建新应用程序
  3. 在bot部分创建一个bot并获取令牌
  4. 设置所需权限:
    • 发送消息
    • 创建公共线程
    • 读取消息历史记录
  5. 在Bot部分启用特权网关意图:
    • 消息内容意图

2.安装

cargo install --git https://github.com/KOBA789/human-in-the-loop.git

与MCP客户端连接

Claude桌面配置

添加以下内容 claude_desktop_config.json:

{
  "mcpServers": {
    "human-in-the-loop": {
      "command": "human-in-the-loop",
      "args": [
        "--discord-channel-id", "channel-id",
        "--discord-user-id", "user-id"
      ],
      "env": {
        "DISCORD_TOKEN": "your-discord-bot-token"
      }
    }
  }
}

Claude代码配置

对于Claude Code(Claude.ai/Code),添加到您的MCP设置中:

{
  "mcpServers": {
    "human-in-the-loop": {
      "command": "human-in-the-loop",
      "args": [
        "--discord-channel-id", "channel-id",
        "--discord-user-id", "user-id"
      ]
    }
  }
}

在运行Claude Code之前,将Discord令牌设置为环境变量:

export DISCORD_TOKEN="your-discord-bot-token"
claude

注意:服务器会自动从 DISCORD_TOKEN 环境变量。你也可以通过 --discord-token 如果需要的话。

用法

人工智能助手可以使用 ask_human 工具:

Human: Please create a documentation outline. You can ask the human as you need.
Assistant: I'll create a documentation outline. Let me ask you some questions first.
[Uses ask_human tool]

AI在Discord中发布问题并提到指定的用户。当用户在Discord中回复时,响应将返回给AI。

运作原理

  1. AI助手呼叫 ask_human 工具
  2. MCP服务器在指定的Discord通道中创建线程(或使用现有线程)
  3. 发布问题并提及指定用户
  4. 等待用户的回复
  5. 将回复内容返回给AI助手

查找不一致ID

获取频道ID

  1. 在Discord中启用开发人员模式(设置→ 高级→ 开发者模式)
  2. 右键单击频道→ “复制ID”

获取用户ID

  1. 右键单击用户→ “复制ID”

路线图

  • 未来向MCP激发的迁移:一旦MCP的Elicitation实现变得更加广泛和标准化,我们计划将UI从Discord迁移到原生MCP Elicitation。这将直接在MCP兼容的客户端中提供更集成的体验。