Skip to content

feat(settings): add an MCP section for global MCP servers - #418

Merged
bubbleptr merged 3 commits into
feat/mcp-settings-backendfrom
feat/mcp-settings-page
Oct 1, 2026
Merged

bubbleptr merged 3 commits into
feat/mcp-settings-backendfrom
feat/mcp-settings-page

Conversation

@bubbleptr

@bubbleptr bubbleptr commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #417. No linked issue: implements the UI half of .scratch/mcp-settings/PRD.md.

Summary

  • 设置页新增 MCP 分区(排在 Models 之后),管理全局 mcp.json,UI 自己写,不映射 Pi 的 TUI / ctx.ui。
  • 配置列表(get_mcp_config)先出,连接状态(probe_mcp_servers)单独探测;探测中显示 Checking…,不轮询、窗口聚焦不重探,探测失败时行仍保留。
  • 每行:状态(Connected / Needs sign-in / Failed / Disabled)、transport、工具数与可展开的工具列表、错误信息、启用开关、exposure 选择、OAuth 登录/登出(等待浏览器授权最多 120 秒)、带确认的删除。
  • 添加对话框:名称、Stdio(命令 + 每行一个参数)/ HTTP(URL)、exposure;注明环境变量、请求头、OAuth 客户端设置仍需手改 mcp.json。
  • 分区顶部说明:配置改动对新会话生效;登录后运行中的会话下一轮即用上新凭据。
  • Sign out 只在 hasStoredCredentials 为 true 时出现(不再对所有无 Authorization 头的 HTTP 服务器显示);登录/登出成功后同时刷新配置与探测。
  • dev 浏览器 fallback 与 mock 场景同步补齐。

Test plan

  • settings-mcp.test.tsx 覆盖探测/失败保留行、启用切换、登录等待态、添加、删除确认
  • bun run typecheck / bun run lint / bun run test(167 文件 / 1965 用例)/ bun run build 全绿
  • dev mock 截图核对分区与添加对话框;Transport 分段控件两段等宽(181px / 181px)
  • 真实 Electron + 真实 MCP 服务器(隔离的 PI_CODING_AGENT_DIR / PACE_DATA_DIR):stdio 与 HTTP 显示 Connected 并列出工具、401 显示 Needs sign-in + Sign in、命令不存在显示 Failed + ENOENT;关闭开关写入 "enabled": false;预置 token 的服务器 Sign out 后 mcp-auth.json 条目被删除、按钮消失
  • 对接真实 OAuth 授权服务器走一遍浏览器登录(本地没有授权服务器,未覆盖)

@bubbleptr
bubbleptr added this pull request to stack #419 October 1, 2026 11:10
@bubbleptr bubbleptr changed the title feat/mcp settings page feat(settings): add an MCP section for global MCP servers Oct 1, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +605 to +609
const probes = probeQuery.isFetching
? new Map<string, McpServerProbe>()
: new Map(
(probeQuery.data?.servers ?? []).map((server) => [server.name, server]),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Failed refresh leaves stale server statuses

When probe_mcp_servers fails during a refresh, probes still uses its cached report. Rows show obsolete connection states and tools despite the failed check.

Suggested change
const probes = probeQuery.isFetching
? new Map<string, McpServerProbe>()
: new Map(
(probeQuery.data?.servers ?? []).map((server) => [server.name, server]),
);
const probes = probeQuery.isFetching || probeQuery.isError
? new Map<string, McpServerProbe>()
: new Map(
(probeQuery.data?.servers ?? []).map((server) => [server.name, server]),
);

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Lists servers from the global mcp.json instantly, probes their state separately, and supports sign-in/out, enable/disable, exposure, add and remove. Changes apply to new sessions.
@bubbleptr
bubbleptr force-pushed the feat/mcp-settings-page branch from e33c220 to 3bfaae2 Compare October 1, 2026 11:35
@bubbleptr
bubbleptr merged commit fc1bfae into main Oct 1, 2026
1 of 2 checks passed
@bubbleptr
bubbleptr deleted the feat/mcp-settings-page branch October 1, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant