一个强大的模型上下文协议(MCP)服务器,使像Claude这样的AI助手能够通过直观的GUI对话与人类互动。该服务器通过提供实时用户输入工具、选择、确认和反馈机制,弥合了自动化AI流程与人类决策之间的差距。

使用此MCP服务器最简单的方法是通过uvx:
# 直接安装并运行
uvx hitl-mcp-server
# 或使用下划线版本
uvx hitl_mcp_server
从PyPI安装:
pip install hitl-mcp-server
运行服务器:
hitl-mcp-server
# 或
hitl_mcp_server
克隆仓库:
git clone https://github.com/GongRzhe/Human-In-the-Loop-MCP-Server.git
cd Human-In-the-Loop-MCP-Server
开发模式安装:
pip install -e .
要将此服务器与Claude Desktop一起使用,请在您的claude_desktop_config.json中添加以下配置:
{
"mcpServers": {
"human-in-the-loop": {
"command": "uvx",
"args": ["hitl-mcp-server"]
}
}
}
{
"mcpServers": {
"human-in-the-loop": {
"command": "hitl-mcp-server",
"args": []
}
}
}
%APPDATA%\Claude\claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.json~/.config/Claude/claude_desktop_config.json注意:您可能需要在系统偏好设置 > 安全与隐私 > 辅助功能中允许Python控制您的计算机,以便GUI对话框正常工作。
更新配置后,请重启Claude Desktop以使更改生效。
get_user_input从用户获取单行文本、数字或其他数据。
参数:
title (str):对话窗口标题prompt (str):问题/提示文本default_value (str):预填值(可选)input_type (str):"text"、"integer"或"float"(默认:"text")示例用法:
result = await get_user_input(
title="项目设置",
prompt="请输入项目名称:",
default_value="my-project",
input_type="text"
)
get_user_choice向用户提供多个选项供选择。
参数:
title (str):对话窗口标题prompt (str):问题/提示文本choices (List[str]):可用选项allow_multiple (bool):是否允许多选(默认:false)示例用法:
result = await get_user_choice(
title="框架选择",
prompt="请选择您偏好的框架:",
choices=["React", "Vue", "Angular", "Svelte"],
allow_multiple=False
)
get_multiline_input收集较长的文本内容、代码或详细描述。
参数:
title (str):对话窗口标题prompt (str):问题/提示文本default_value (str):预填文本(可选)示例用法:
result = await get_multiline_input(
title="代码审查",
prompt="请提供您的详细反馈:",
default_value=""
)
show_confirmation_dialog在继续之前询问是/否确认。
参数:
title (str):对话窗口标题message (str):确认消息示例用法:
result = await show_confirmation_dialog(
title="删除确认",
message="您确定要删除这5个文件吗?此操作无法撤销。"
)
show_info_message显示信息、通知或状态更新。
参数:
title (str):对话窗口标题message (str):信息消息示例用法:
result = await show_info_message(
title="过程完成",
message="成功处理了1,247条记录,耗时2.3秒!"
)
health_check检查服务器状态和GUI可用性。
示例用法:
status = await health_check()
# 返回详细的平台和功能信息
所有工具返回结构化的JSON响应:
{
"success": true,
"user_input": "用户的响应文本",
"cancelled": false,
"platform": "windows",
"input_type": "text"
}
常见响应字段:
success (bool):操作是否成功完成cancelled (bool):用户是否取消了对话platform (str):操作系统平台error (str):如果操作失败,返回错误消息特定工具字段:
user_input,input_typeselected_choice,selected_choices,allow_multipleuser_input,character_count,line_countconfirmed,responseacknowledged# 获取目标目录
location = await get_user_input(
title="备份位置",
prompt="请输入备份目录路径:",
default_value="~/backups"
)
# 选择备份类型
backup_type = await get_user_choice(
title="备份选项",
prompt="选择备份类型:",
choices=["完全备份", "增量", "差异"]
)
# 确认后再继续
confirmed = await show_confirmation_dialog(
title="确认备份",
message=f"创建{backup_type['selected_choice']}备份到{location['user_input']}?"
)
if confirmed['confirmed']:
# 执行备份
await show_info_message("成功", "备份已完成!")
# 获取内容要求
requirements = await get_multiline_input(
title="内容要求",
prompt="详细描述您的内容要求:"
)
# 选择语气和风格
tone = await get_user_choice(
title="内容风格",
prompt="选择所需语气:",
choices=["专业", "随意", "友好", "技术"]
)
# 生成并展示结果
# ... 内容生成逻辑 ...
await show_info_message("内容就绪", "您的内容已成功生成!")
GUI未出现
python -c "import tkinter"health_check()工具以诊断问题权限错误(macOS)
导入错误
pip install hitl-mcp-serverClaude Desktop集成问题
pip install uvxuvx hitl-m-服务器对话超时
cancelled=true通过运行服务器时设置环境变量启用详细日志:
HITL_DEBUG=1 uvx hitl-mcp-server
Human-In-the-Loop-MCP-Server/
├── human_loop_server.py # 主服务器实现
├── pyproject.toml # 包配置
├── README.md # 文档
├── LICENSE # MIT许可证
├── .gitignore # Git忽略规则
└── demo.gif # 演示动画
git checkout -b feature-name本项目采用MIT许可证 - 详情请参阅LICENSE文件。
为AI社区制作 - 通过直观交互连接人类和AI