Human In The Loop

Human In The Loop

🚀 人工介入式MCP服务器

这是一个MCP(模型上下文协议)服务器,它允许AI助手通过Discord向人类提问,以获取人类的输入或判断,从而更好地完成工作。

🚀 快速开始

本MCP服务器适用于AI助手在工作过程中需要人类输入或判断的场景。例如:

  • 在让大语言模型(LLM)创建文档时,AI负责设计结构,人类提供具体内容。
  • 当AI对不确定的决策需要确认时。
  • 当需要专业知识或个人信息时。

✨ 主要特性

  • 支持AI助手在工作中向人类提问,获取必要的信息和判断。
  • 可与多种MCP兼容的AI客户端集成,如Claude Desktop、Copilot Edits等。
  • 通过Discord与人类进行交互,方便快捷。

📦 安装指南

环境要求

  • Rust(1.70或更高版本)
  • Discord账户和机器人
  • MCP兼容的AI客户端(Claude Desktop、Copilot Edits等)

安装步骤

1. 创建Discord机器人

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

2. 安装服务器

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

💻 使用示例

与MCP客户端连接

Claude Desktop配置

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 Code配置

对于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令牌。如果需要,也可以通过 --discord-token 参数传递。

基础用法

AI助手可以使用 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助手。

获取Discord ID

获取频道ID

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

获取用户ID

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

📚 详细文档

未来规划

  • 未来迁移到MCP Elicitation:一旦MCP的Elicitation实现更加广泛和标准化,我们计划将用户界面从Discord迁移到原生的MCP Elicitation。这将在MCP兼容的客户端内提供更集成的体验。
  • 0 关注
  • 0 收藏,9 浏览
  • system 提出于 2025-09-18 18:54

相似服务问题