Files
plugins/packages/chat/lib
yetone 39de03001d page-chat 0.1.6: one switch uses every MCP server in magpie's Library (Magiczerowxy/magpie-chat#4)
ferocknew asked for a way to give new chats every MCP server without
ticking each one. The MCP list in the settings sidebar now starts with a
switch, "使用 magpie 的全部 MCP 服务器". On, a chat uses every server in
library.json, read again on each chat, so a server added to magpie later
is in too; the rows show checked and disabled. Off (the default, and what
a 0.1.5 settings.json reads as), ticking works as before, and the ticks
set before turning it on come back.

The whole path: the setting is mcpAll in the service's settings
(cleanSettings keeps it, default false). runChat wants tools when mcpAll
is on even with nothing ticked, and pickServers() picks every Library
server; "检查连接" (/api/mcp/tools) checks the same set. The page sends
useTools when mcpAll is on. The service picks servers from the saved
settings, while the page saves them 320ms after a change, so send() now
saves pending settings before /api/chat; a switch flipped just before
sending (or a server just ticked) counts.

Run (mote, bun 1.4.2, HOME a temp dir): bun test chat.test.mjs, 28 pass;
bun scripts/check.mjs chat ok. Three new tests: a chat against two fake
Streamable-HTTP MCP servers gets only the ticked one with the switch off,
both with it on and nothing ticked, a third added to library.json after
turning it on, and /api/mcp/tools lists all three; a 0.1.5 settings.json
reads as off; the page's wantsTools and the save-before-send.
Broken by hand: pickServers ignoring mcpAll fails the first two tests;
cleanSettings dropping mcpAll fails the same two; useTools back to
"mcp ticked" fails the third.
Real page, Playwright 1.62.0, 1200 and 760 wide: switch off by default
with the old tick, on makes every row checked and disabled, flipping it
and pressing Enter saves settings before /api/chat with useTools true,
still on after reload, off brings back the old tick, rows clickable.
Chromium on mote, 18 of 18; WebKit on Linux (WSL magpie-desktop), 18 of
18, since WebKit on mote didn't launch within 180s (other sessions'
WebKit processes were running there).

Not tried: a real magpie window with real MCP servers and a real model
call (the gateway in the browser run was absent; tool lists came from
fakes); stdio servers under the switch (same pick, only http was run);
macOS WebKit; languages other than Chinese (the page has no i18n).
2026-10-31 12:25:16 +08:00
..