用户提示MCP服务器
mcp名称:io.github。Jacob-J-Thomas/用户提示
A. 模型上下文协议(MCP) 服务器,使人工智能代理能够在任务中期通过弹出式终端窗口向用户提出澄清问题。用。NET 8和C#。
问题
长期运行的AI代理(如 克劳德代码IDE副产品或自定义代理工作流)经常遇到需要人工输入的情况——模糊的要求、意外的错误或可能有多种方式的设计决策。如果没有询问机制,代理要么猜测(通常是错误的),要么完全停止并等待用户注意到。
解决方案
此MCP服务器公开单个工具, user_prompt,AI代理可以在执行过程中的任何时候调用。当调用时,a 新终端窗口 在用户的计算机上打开,显示代理的问题。用户键入他们的答案,响应直接返回给代理,使其能够继续处理其他上下文。
特性
- 弹出终端提示 --问题出现在专用窗口中,与代理自己的I/O分开
- 多问题支持 --代理人可以在一次通话中提出多个问题;所有内容都以编号列表的形式显示在前面
- 结构化响应 --答案以清晰格式的问答对返回,代理可以解析
- 超时处理 --10分钟响应窗口,提供优雅的回退消息
- 车窗关闭检测 --如果用户关闭提示而不回答,代理将收到明确的通知
- 标准运输 --根据MCP规范通过stdin/stdout进行通信,与任何MCP客户端兼容
先决条件
- 视窗:PowerShell 5.1+(包含在Windows 10/11中)
- macOS/Linux *(未经测试)*: PowerShell核心(
pwsh) 必须安装
快速开始
挑选 一 以下三个安装选项中。每个选项都会引导您完成安装、客户端配置和端到端更新。
______________________________________________________________________
选项A:GitHub发布
独立可执行文件——否。需要NET SDK。
1.下载
从 最新版本:
| 平台 | 资产 |
|---|---|
| Windows(x64) | UserPromptMcpServer-win-x64.zip |
| macOS(英特尔) | UserPromptMcpServer-osx-x64.zip |
| macOS(苹果硅) | UserPromptMcpServer-osx-arm64.zip |
| Linux(x64) | UserPromptMcpServer-linux-x64.zip |
2.提取
解压缩到永久位置,例如:
- 视窗:
C:\Tools\UserPromptMcpServer\ - macOS/Linux:
~/tools/UserPromptMcpServer/
3.配置您的MCP客户端
克劳德代码(CLI):
claude mcp add user-prompt -- "C:\Tools\UserPromptMcpServer\UserPromptMcpServer.exe"其他客户 --将命令指向可执行文件(请参见 客户端配置参考 完整示例):
{
"command": "C:\\Tools\\UserPromptMcpServer\\UserPromptMcpServer.exe"
}正在更新: 下载新版本并替换同一文件夹中的文件。
______________________________________________________________________
选项B:。NET全局工具
需要 .NET 8.0 SDK 或稍后。该工具会自动添加到您的PATH中。
1.安装
dotnet tool install -g UserPrompt2.配置您的MCP客户端
克劳德代码(CLI):
claude mcp add user-prompt -- user-prompt其他客户 --命令名为 user-prompt (参见 客户端配置参考 完整示例):
{
"command": "user-prompt"
}正在更新:
dotnet tool update -g UserPrompt______________________________________________________________________
选项C:从源代码构建
需要 .NET 8.0 SDK 或稍后。
git clone https://github.com/Jacob-J-Thomas/user-context-retrieval-mcp-server.git
cd user-context-retrieval-mcp-server
dotnet publish UserPromptMcpServer -c Release -r win-x64 -o ./publish替换win-x64与您的平台 运行时标识符 (例如。osx-arm64,linux-x64).
然后按照以下方式配置客户端 选项A,指向内部的可执行文件 ./publish/.
______________________________________________________________________
客户端配置参考
此服务器使用 标准 传输——它不监听端口。MCP客户端启动服务器进程,并通过stdin/stdout与之通信。将下面的命令/路径替换为您选择的任何安装选项中的值。
克劳德桌面
将以下内容添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"user-prompt": {
"command": "/path/to/UserPromptMcpServer.exe"
}
}
}配置文件位置:
| 平台 | 路径 |
|---|---|
| 窗户 | %APPDATA%\Claude\claude_desktop_config.json |
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
光标
添加以下内容 .cursor/mcp.json (项目层面)或 ~/.cursor/mcp.json (全球):
{
"mcpServers": {
"user-prompt": {
"command": "/path/to/UserPromptMcpServer.exe"
}
}
}OpenAI Codex命令行界面
添加以下内容 ~/.codex/config.toml (全球)或 .codex/config.toml (项目层面):
[mcp_servers.user-prompt]
command = "/path/to/UserPromptMcpServer.exe"或者通过CLI:
codex mcp add user-prompt -- /path/to/UserPromptMcpServer.exe其他MCP客户端
任何支持stdio传输的MCP客户端都可以启动此服务器。将其指向可执行文件(或 user-prompt 命令名(如果使用)。NET全局工具)。
用法
配置后 user_prompt AI代理可以自动使用该工具。代理根据自己的判断决定何时调用它——不需要手动触发。
工具参考
工具名称: user_prompt
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
reason | string | 是 | 明确解释为什么代理需要用户输入。在终端窗口中突出显示。 |
questions | string[] | 是 | 具体问题列表。显示为编号列表;用户依次回答每个问题。 |
示例工具调用
{
"name": "user_prompt",
"arguments": {
"reason": "The project has no database configuration and I need to set one up.",
"questions": [
"Which database engine should I use (PostgreSQL, SQLite, SQL Server)?",
"Should I include Entity Framework Core as the ORM?"
]
}
}示例响应
User responded to 2 question(s):
1. Q: Which database engine should I use (PostgreSQL, SQLite, SQL Server)?
A: PostgreSQL
2. Q: Should I include Entity Framework Core as the ORM?
A: Yes, use EF Core with code-first migrations终端窗口行为
调用该工具时,将打开一个新的PowerShell窗口,显示:
- 指示AI代理需要输入的标头
- 代理人表示 原因 因为问
- 全部 问题 作为编号列表
- 数字输入提示(
1>,2>等)——每个答案输入一个 - 窗口自动关闭前的确认消息
如果用户在 10分钟,或者关闭窗口而不回答,代理将收到描述性回退消息,并可以决定如何继续。
建筑
UserPromptMcpServer/
├── UserPromptMcpServer.csproj # Project file (.NET 8)
├── Program.cs # MCP server entry point (stdio transport)
└── Tools/
└── UserPromptTool.cs # Tool implementation内部工作原理
- MCP客户端发送
tools/callstdin上的JSON-RPC请求 - 服务器将问题写入临时JSON文件
- PowerShell脚本在 新终端窗口
- 用户看到问题并按顺序键入答案
- 答案被写入响应JSON文件;终端关闭
- 服务器读取响应文件,格式化它,清理临时文件,并通过stdout返回结果
所有临时文件都是在下创建的 %TEMP%/UserPromptMcpServer// 并在每次调用后进行清理,而不管结果如何。
贡献
欢迎投稿!为了确保您的更改被合并,请 先打开一个问题 在开始工作之前,讨论拟议的变更并获得批准。
- 分叉 存储库
- 创建要素分支 (
git checkout -b feature/my-feature) - 进行更改 确保项目建设干净整洁(
dotnet build) - 提交 带有清晰、描述性的信息
- 打开拉取请求 反对
develop
开发设置
git clone https://github.com/Jacob-J-Thomas/user-context-retrieval-mcp-server.git
cd user-context-retrieval-mcp-server
dotnet restore UserPromptMcpServer/UserPromptMcpServer.csproj
dotnet build UserPromptMcpServer/UserPromptMcpServer.csproj贡献领域
- 与跨平台支持 --macOS和Linux终端的发布目前尚未完成,也未经过测试
- 测试覆盖率 --尚未存在测试项目
- 其他MCP工具 --如果项目范围扩展到单个工具之外
许可证
该项目根据 Apache许可证2.0。参见 许可证 了解详情。
作者
雅各布·托马斯 — @Jacob-J-Thomas
