@mako10k/mcp确认
一个在人工智能和用户之间实现确认协议的MCP服务器。它为LLM提供了工具,以便在需要澄清或验证时请求用户确认。
@mako10k/mcp确认
用于人工智能用户确认和澄清的模型上下文协议(MCP)服务器。该服务器为AI助手(LLM)提供工具,以便在用户需要澄清或验证时要求用户确认。
概述
此MCP服务器实现 模型上下文协议引用规范 以实现AI助手和用户之间的确认和澄清协议。
AI助手可以在以下情况下使用它:
- 执行前确认行动
- 澄清模棱两可的请求
- 验证理解是否正确
- 问是/否问题
- 收集用户满意度评级
特性
可用工具
- ask_是_否
- 询问是/否确认问题 - 当AI需要澄清或验证时使用
- confirm_action
- 执行前确认操作 - 在确认对话框中包括影响和详细信息
- 澄清内容
- 澄清模棱两可的请求 - 提供多种解释选项
- 验证_理解
- 验证AI的理解是否正确 - 在继续之前确认下一步
- 收集_评级
- 收集用户满意度评级 - 评估AI响应质量
- 启发式定制
- 自定义确认对话框 - 使用自定义JSON模式
- search_logs
- 搜索确认历史日志 - 按类型、成功状态、日期范围、响应时间筛选 - 大型数据集的分页结果
- 分析日志
- 确认历史的统计分析 - 成功率、响应时间、趋势 - 按类型、时间段等分组。
安装
# Install globally
npm install -g @mako10k/mcp-confirm
# Or use with npx
npx @mako10k/mcp-confirm使用GitHub代码空间进行开发
该项目支持使用GitHub Codespace进行开发:
- 在GitHub上打开此存储库
- 点击“代码”按钮
- 选择“代码空间”选项卡
- 点击“在main上创建代码空间”
- 开发环境将自动设置
有关详细信息,请参阅 Developpent.md.
配置
环境变量
您可以使用环境变量配置服务器:
MCP_CONFIRM_LOG_PATH:确认历史日志文件的路径(默认:.mcp-data/confirmation_history.log)MCP_CONFIRM_TIMEOUT_MS:确认的默认超时时间(毫秒)(默认值:180000=3分钟)
- 最低要求: 5000 (5秒) - 最大值: 1800000 (30分钟) - 无效值将返回默认值并发出警告
NODE_ENV:设置为development启用调试日志记录
超时配置示例
# Use 5-minute timeout
export MCP_CONFIRM_TIMEOUT_MS=300000
# Use 1-minute timeout
export MCP_CONFIRM_TIMEOUT_MS=60000
# Use 10-second timeout (minimum enforced)
export MCP_CONFIRM_TIMEOUT_MS=10000超时行为
服务器根据确认类型使用智能超时设置:
- 关键行动 (删除、移除操作):120秒
- 警告措施:90秒
- 简单的是/否问题:30秒
- 评级请求:20秒(仅供参考)
- 其他确认:60秒(默认)
确认历史记录
所有确认交互都记录到一个文件中以供审计。日志包括:
- 请求的时间戳
- 确认类型
- 完整的请求和响应数据
- 响应时间(毫秒)
- 成功/失败状态
- 错误消息(如有)
日志目录(.mcp-data/)如果它不存在,将自动创建。
VS代码集成
添加到您的 .vscode/mcp.json:
{
"servers": {
"mcp-confirm": {
"type": "stdio",
"command": "npx",
"args": ["@mako10k/mcp-confirm"]
}
}
}Claude桌面配置
添加到您的Claude桌面 config.json:
视窗
地点: %APPDATA%\Claude\config.json
macOS
地点: ~/Library/Application Support/Claude/config.json
Linux
地点: ~/.config/claude/config.json
{
"mcp": {
"servers": {
"mcp-confirm": {
"command": "npx",
"args": ["@mako10k/mcp-confirm"],
"env": {
"MCP_CONFIRM_LOG_PATH": "~/.mcp-data/confirmation_history.log",
"MCP_CONFIRM_TIMEOUT_MS": "60000",
"NODE_ENV": "production"
}
}
}
}
}使用示例
基本确认
// Before AI executes an action
await confirm_action({
action: "Delete files",
impact: "Cannot be restored",
details: "10 files will be deleted"
});意图澄清
// When request is ambiguous
await clarify_intent({
request_summary: "Want to create a project",
ambiguity: "Type of project unclear",
options: ["Node.js project", "Python project", "React app"]
});了解验证
// Before complex tasks
await verify_understanding({
understanding: "Create web application with user authentication",
key_points: ["React + Node.js", "JWT authentication", "PostgreSQL database"],
next_steps: "Create project structure then implement auth system"
});技术规格
- 协议:模型上下文协议提取
- 语言:TypeScript
- 运行时:Node.js
- SDK版本:@modelcontextprotocol/sdk^1.0.0
运作原理
此服务器实现了真正的MCP激发协议:
- 发送
elicitation/create方法到客户端 - 使用JSON模式定义用户输入结构
- 用户响应如下
accept,decline,或cancel - 在…上
accept,按照架构接收结构化数据
这使得AI和用户之间能够进行可靠的通信。
发展
# Clone repository
git clone https://github.com/mako10k/mcp-confirm.git
cd mcp-confirm
# Install dependencies
npm install
# Build
npm run build
# Run locally
npm start
# Quality checks
npm run quality许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
仓库
- GitHub: https://github.com/mako10k/mcp-confirm
- npm: https://www.npmjs.com/package/@mako10k/mcp确认
