Repository navigation
feat(composer): 支持显式选择 MCP 服务器与工具 - #1409
Merged
Merged
Conversation
Allow users to select enabled MCP capabilities from the composer while preserving runtime discovery, project scope and execution permissions. Resolve exact identities at submission and activate queued selections only when their steering message is consumed. Initialize MCP discovery before cold-start validation so the first command after restart works without visiting settings. Cover selection, lifecycle, permission and composer interactions with regression and E2E scenarios. closes vastsa#1377
Keep the latest usable model selection across new chats and restarts, while preserving each existing conversation binding. Expose three recent provider/model pairs directly in the composer menu. Remove the fixed chat-default settings controls without changing legacy settings used by scheduled jobs or the independent image model selection. Cover persistence, unavailable bindings and model menu interactions.
Only accepted messages update model history, so opening an old chat or browsing model choices cannot change the next chat's inherited model. Keep search and recent choices together, with other models expanded inline.
Recent entries missed the shared model group styles and rendered larger than the expanded catalog. Reuse that group and check computed typography in the Electron interaction test.
Pointer hover must not leave a model marked as the keyboard target after moving to the inline disclosure. Clear the keyboard cursor on pointer movement and when search loses focus, preserving native hover feedback.
…codex/feat-composer-mcp-1377
The documentation gate requires an ADR heading and an index entry for each decision record. Include both so docs validation and the recursive workspace test job can complete.
…ection feat(composer): 新聊天沿用上次模型并优先显示最近三项
A bare MCP selection currently sends only a tool-selection instruction, leaving the model to infer what to do. Require task text or attachment context before creating a turn while preserving attachment-only requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1377
使用方式
输入框的
/菜单支持显式选择 MCP 服务器或具体工具,让用户能指出这次任务要用哪个 MCP。/mcp:time 查询上海当前时间/mcp:time:get_current_time 查询上海当前时间get_current_time工具/mcp:agent-recall:search_sessions 查找上周的会话选择只把命令填入输入框,不会立即执行工具。发送后,模型仍负责判断是否调用、填写参数和处理结果。只有命令而没有任务正文时,也不自动执行一个猜测的操作。具体命令 ID 以菜单为准,服务器和工具名称中的特殊字符会做 URI 编码。
具体实现
输入框目录和补全
composer-ipc.ts从现有 User MCP runtime 读取服务器记录和工具目录,只为已启用、当前项目可用、连接就绪且有工具的服务器生成命令。获取目录复用原有连接初始化流程,因此冷启动后无需先打开 MCP 设置。共享的
ComposerCommand增加mcp类型,携带mcpServerId和可选的mcpToolName。输入框复用现有斜杠菜单、搜索、鼠标和键盘补全,不新增另一套工具执行入口。目录不包含连接地址、凭据或工具参数 schema,现有命令重名时保持原有优先级。提交时解析和校验
composer-mcp.ts解析消息开头的/mcp:…,并匹配 Main 在发送时重新读取的命令目录。校验依据是这条会话绑定的项目,不是界面当前打开的项目。Main 将原始输入保留在消息的
command字段,供历史展示;模型收到一条简短的用户选择说明及任务正文。例如,服务器选择会说明用户为本次请求选择了哪个 MCP。实际选择同时通过内部 RPC 的mcpServerIds、mcpToolNames传递,工具激活不依赖模型识别这句说明。服务器已禁用、项目范围不匹配、工具不存在等情况会明确失败,不会当普通文本继续发送,也不会把无效的具体工具选择扩大为整个服务器。Desktop 管理的 MCP 选择不用于原生 Pi 会话。
Runtime 激活和模型上下文
mcp-tool-selection.ts用目录中的服务器 ID 和完整工具名校验归属,再按当前模式过滤可用工具,不靠工具名前缀判断权限。普通消息在发起模型请求前激活。运行中的追加消息将选择与消息一起保存,等消息真正进入模型上下文时才激活并同步声明,避免提前影响正在进行的请求。未携带 MCP 选择的消息继续使用原来的按需发现方式。
主要改动在输入框命令目录、Main 提交解析和 Agent Runtime 工具激活;没有数据库迁移,没有新增 Plugin SDK 或 Rust Host 协议字段。相关 ADR、工具权限规范、组件规范和 E2E 场景同步更新。
验证
e13259df78cc已合入主线abfeeb21852e。文档检查覆盖 557 个页面、85 对中英文文档,13 项文档测试及 VitePress 构建通过。tools/call的结果进入后续模型请求;覆盖选择服务器后直接调用第六个工具,避免只激活 ToolSearch 首批结果。本轮 CI 修复针对 ADR 标题和目录索引:缺少
ADR标题前缀及索引项同时导致 Docs 检查和 JS 流水线中的文档测试失败。修复没有修改 MCP 执行代码。类型为
feat。仓库当前外部贡献范围限于fix/perf,此功能是否接受需由维护者决定。