Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(core,web): MCP Server 可以停用而不必删除,填好的配置留着

lmliheng1c83d5939443
diff --git a/changelog/unreleased/2026-10-18-mcp-server-enabled-switch.md b/changelog/unreleased/2026-10-18-mcp-server-enabled-switch.md
new file mode 100644
index 00000000..369ef4f5
--- /dev/null
+++ b/changelog/unreleased/2026-10-18-mcp-server-enabled-switch.md
@@ -0,0 +1,30 @@
+# An MCP Server can be switched off without deleting it
+
+- **Date:** 2026-10-18
+- **Type:** feature
+- **Scope:** `core`, `web`, `docs`, `plugins`
+- **Breaking:** no — an entry without `enabled` behaves exactly as before
+
+[中文版](2026-10-18-mcp-server-enabled-switch.zh.md)
+
+The MCP Servers block in the agent settings now has a per-row on/off switch. Switched off, the
+entry and every field of it stay in the config, but no turn connects that server and its
+`mcp__*` tools leave the tool list. Until now the only way to stop a server from being connected
+on every turn was to delete its entry and type it in again later — which is why an installed
+plugin's bridge (the WPS add-in's, for one) kept showing up in every conversation even when the
+plugin was not being used.
+
+## Details
+
+- The switch writes `enabled: false` into the entry's `config`; turning it back on removes the
+ key, so an active entry keeps following the default. The same field can be set by hand in
+ `system_config.yaml`, and the docs (`/docs/tools` § MCP Servers) describe it in both languages.
+- Core's resolver drops a switched-off entry **before** it looks at the transport: a parked entry
+ whose target no longer exists (an uninstalled plugin's bridge) produces no warning on every
+ session, and cannot fail one.
+- `enabled` must be a boolean. A quoted `"false"` is rejected instead of silently reading as on.
+- `POST /config/mcp-test` still probes a switched-off entry, so a server can be tested before it
+ is turned on; the probe does not save anything.
+- The WPS add-in's bridge no longer reconnects forever when the session it remembers is gone: a
+ 404/410 on a session stream now stops the subscription and logs one line at info level. It used
+ to treat every failure as transient and write a warning every 10 seconds, indefinitely.
diff --git a/changelog/unreleased/2026-10-18-mcp-server-enabled-switch.zh.md b/changelog/unreleased/2026-10-18-mcp-server-enabled-switch.zh.md
new file mode 100644
index 00000000..4749d508
--- /dev/null
+++ b/changelog/unreleased/2026-10-18-mcp-server-enabled-switch.zh.md
@@ -0,0 +1,18 @@
+# MCP Server 可以停用,而不必删掉
+
+- **Date:** 2026-10-18
+- **Type:** feature
+- **Scope:** `core`, `web`, `docs`, `plugins`
+- **Breaking:** 否 —— 没有 `enabled` 的条目行为与以前完全一样
+
+[English](2026-10-18-mcp-server-enabled-switch.md)
+
+Agent 设置里的 MCP Server 区块现在每行都有一个开关。关掉之后,条目和它的每个字段都留在配置里,但任何一轮都不会连接这个 Server,它的 `mcp__*` 工具也从工具列表里消失。此前想让它「别再每轮都连一次」,只能把条目删掉、以后要用再重新填一遍 —— 插件装上的桥(比如 WPS 加载项的桥)于是即使不用也一直留在每一轮对话里。
+
+## 细节
+
+- 开关往条目的 `config` 里写 `enabled: false`;再打开时把该键删掉,开着的条目继续跟随默认值。同一个字段也可以在 `system_config.yaml` 里手写,文档(`/docs/tools` 的 MCP Servers 一节)中英文都已写明。
+- core 的解析在**看传输方式之前**就丢掉停用的条目:停用的条目目标已经不存在(插件卸了、桥没了)也不会每轮报一条警告,更不会把会话弄失败。
+- `enabled` 必须是布尔值。带引号的 `"false"` 会被判为无效,而不会被悄悄当成「开着」。
+- `POST /config/mcp-test` 对停用的条目照常能测,所以可以先测通再打开;测试不保存任何东西。
+- WPS 加载项的桥不再对它记住的、已经不存在的会话无限重连:会话流返回 404/410 时停止订阅并在 info 级别记一条。此前它把每一次失败都当临时故障,于是每 10 秒写一条警告,永不停止。
diff --git a/packages/core/src/environment/mcp/config.ts b/packages/core/src/environment/mcp/config.ts
index 6023a4b3..5ea21292 100644
--- a/packages/core/src/environment/mcp/config.ts
+++ b/packages/core/src/environment/mcp/config.ts
@@ -18,6 +18,10 @@
* `permission` sets the approval level Adelie applies to every tool of the server —
* `"auto"` (the default) trusts each tool's own `readOnlyHint`, `"r"` or `"rw"` overrides it.
*
+ * `enabled: false` switches a server off without deleting it: the entry stays in the config
+ * (transport and all) but never reaches the runtime, so it costs no connection per turn and
+ * its tools stay out of the schema. The settings page's per-row switch writes this field.
+ *
* Invalid entries never break Session creation: each problem is reported as a warning and
* the entry is skipped (the same stance Environment takes on unrecognized builtin tool
* names), so one typo in a hand-edited YAML cannot take the whole Agent down.
@@ -113,6 +117,16 @@ function readPermission(value: unknown): ToolPermission | undefined | null {
return null;
}
+/**
+ * Reads the optional switch; `false` = configured but out of the runtime, `true` or absent =
+ * active, `null` = invalid (a quoted `"false"` must not silently read as on).
+ */
+function readEnabled(value: unknown): boolean | undefined | null {
+ if (value === undefined) return undefined;
+ if (typeof value !== "boolean") return null;
+ return value;
+}
+
/**
* Resolves one entry; throws with a human-readable reason on an invalid one (the caller
* turns it into a warning and skips the entry).
@@ -205,6 +219,11 @@ export function resolveMCPServer(entry: MCPServerConfig): ResolvedMCPServer {
if (permission === null) {
throw new Error(`"permission" must be "auto", "r" or "rw"`);
}
+ // `true` is the default and stays out of the resolved shape: only the off switch matters
+ // to the caller, which drops such an entry before it ever reaches the provider.
+ if (readEnabled(config["enabled"]) === null) {
+ throw new Error(`"enabled" must be true or false`);
+ }
return {
name,
@@ -217,14 +236,19 @@ export function resolveMCPServer(entry: MCPServerConfig): ResolvedMCPServer {
}
/**
- * Resolves a whole `mcpServers` list: invalid entries and duplicate names become warnings
- * and are skipped; the rest come back typed and ready to connect.
+ * Resolves a whole `mcpServers` list: entries switched off (`enabled: false`) are dropped
+ * silently — being out of the runtime is the point of the switch, not a problem to warn
+ * about — invalid entries and duplicate names become warnings and are skipped; the rest
+ * come back typed and ready to connect.
*/
export function resolveMCPServers(entries: MCPServerConfig[]): ResolveMCPServersResult {
const servers: ResolvedMCPServer[] = [];
const warnings: string[] = [];
const seen = new Set<string>();
for (const entry of entries) {
+ // Before resolution on purpose: a switched-off entry may hold a transport that no longer
+ // works (an uninstalled plugin's bridge), and that must not warn on every Session.
+ if (isRecord(entry?.config) && entry.config["enabled"] === false) continue;
let resolved: ResolvedMCPServer;
try {
resolved = resolveMCPServer(entry);
diff --git a/packages/core/test/mcp-config.test.ts b/packages/core/test/mcp-config.test.ts
index f4edc6f0..696c329f 100644
--- a/packages/core/test/mcp-config.test.ts
+++ b/packages/core/test/mcp-config.test.ts
@@ -148,3 +148,32 @@ describe("resolveMCPServers — list semantics", () => {
expect(resolveMCPServers([])).toEqual({ servers: [], warnings: [] });
});
});
+
+describe("resolveMCPServers — the on/off switch", () => {
+ it("drops a switched-off entry without a warning, keeping the rest in order", () => {
+ const { servers, warnings } = resolveMCPServers([
+ { name: "off", config: { command: "node", args: ["bridge.mjs"], enabled: false } },
+ { name: "on", config: { command: "srv" } },
+ { name: "plain-off", config: { url: "https://x/mcp", enabled: true } },
+ ]);
+ expect(servers.map((s) => s.name)).toEqual(["on", "plain-off"]);
+ expect(warnings).toEqual([]);
+ });
+
+ it("does not try to resolve the transport of a switched-off entry", () => {
+ // The entry's target may be gone (an uninstalled plugin's bridge) — being off means
+ // nothing looks at it, so no warning lands on every Session.
+ const { servers, warnings } = resolveMCPServers([
+ { name: "stale", config: { enabled: false } },
+ { name: "typo", config: { command: "a", permission: "readonly", enabled: false } },
+ ]);
+ expect(servers).toEqual([]);
+ expect(warnings).toEqual([]);
+ });
+
+ it("rejects a non-boolean switch instead of reading it as on", () => {
+ expect(() =>
+ resolveMCPServer({ name: "a", config: { command: "x", enabled: "false" } }),
+ ).toThrow(/"enabled" must be true or false/);
+ });
+});
diff --git a/packages/docs/content/tools.en.md b/packages/docs/content/tools.en.md
index 234e770b..0bce9181 100644
--- a/packages/docs/content/tools.en.md
+++ b/packages/docs/content/tools.en.md
@@ -410,6 +410,9 @@ All three transports share these optional fields:
| `timeoutMs` | Execution timeout for every tool of that Server; the Environment default when unset |
| `maxOutputLength` | Output cap for every tool of that Server; the Environment default when unset |
| `permission` | `auto` / `r` / `rw`, default `auto`; see [Permission mapping](#permission-mapping) |
+| `enabled` | `true` (default) / `false`; `false` keeps the entry but takes the Server out of the runtime |
+
+`enabled: false` parks a Server without deleting it: the entry — transport and every other field — stays in the config, but no turn connects it and its tools stay out of the tool list. It is the way to switch off a bridge installed by a plugin (the WPS add-on's bridge, say) without losing the entry you would have to re-add later. The settings page's per-row switch writes this field. Anything other than `true` or `false` is invalid, so a quoted `"false"` cannot silently read as on.
`connectTimeoutMs`, `timeoutMs` and `maxOutputLength` must be positive numbers here; an entry with a value of 0 or less is invalid. `headers` are attached to every HTTP request to that Server, SSE stream included, so they can carry auth headers such as `Authorization`.
diff --git a/packages/docs/content/tools.zh.md b/packages/docs/content/tools.zh.md
index 5f742fdf..ce85d4a3 100644
--- a/packages/docs/content/tools.zh.md
+++ b/packages/docs/content/tools.zh.md
@@ -410,6 +410,9 @@ tools:
| `timeoutMs` | 这个 Server 每个工具的执行超时;未设置时使用 Environment 默认值 |
| `maxOutputLength` | 这个 Server 每个工具的输出上限;未设置时使用 Environment 默认值 |
| `permission` | `auto` / `r` / `rw`,默认 `auto`;见[权限映射](#权限映射) |
+| `enabled` | `true`(默认)/ `false`;`false` 保留条目,但把这个 Server 移出运行时 |
+
+`enabled: false` 是把一个 Server 停用而不是删掉:条目(传输方式和其他每个字段)都留在配置里,但任何一轮都不会连接它,它的工具也不再出现在工具列表里。插件装上的桥(比如 WPS 加载项的桥)想关又不想丢掉重新登记的那份配置,用它最合适。设置页每行的开关写的就是这个字段。取值不是 `true` 或 `false` 时算无效,所以带引号的 `"false"` 不会被当成「开着」。
这里的 `connectTimeoutMs`、`timeoutMs` 和 `maxOutputLength` 必须是正数,取值小于等于 0 的条目无效。`headers` 会附加到发往这个 Server 的每一个 HTTP 请求上,SSE 流也不例外,因此可以携带 `Authorization` 这类认证头。
diff --git a/packages/web/src/features/agents/mcp-servers-form.ts b/packages/web/src/features/agents/mcp-servers-form.ts
index f45dcc37..d96f6c57 100644
--- a/packages/web/src/features/agents/mcp-servers-form.ts
+++ b/packages/web/src/features/agents/mcp-servers-form.ts
@@ -24,6 +24,8 @@ export const MCP_PERMISSION_DEFAULT: McpPermissionMode = "auto";
/** Editable string state backing the Add/Edit modal (multiline fields stay raw text). */
export interface McpServerFormState {
name: string;
+ /** The row's on/off switch: off keeps the entry (and its fields) but removes it from the runtime. */
+ enabled: boolean;
transport: McpTransportKind;
command: string;
/** One argument per line (blank lines ignored). */
@@ -90,6 +92,7 @@ export const MCP_BUDGET_DEFAULTS = {
} as const;
const KNOWN_CONFIG_KEYS = new Set([
+ "enabled",
"transport",
"command",
"args",
@@ -106,6 +109,8 @@ const KNOWN_CONFIG_KEYS = new Set([
export function emptyMcpForm(): McpServerFormState {
return {
name: "",
+ // A server added from this page is meant to be used: it starts on.
+ enabled: true,
// The Add modal opens on http: remote servers are the common case, and a URL field is
// the gentler first impression than command/args.
transport: "http",
@@ -140,6 +145,11 @@ export function transportOf(entry: MCPServerConfig): McpTransportKind {
: "stdio";
}
+/** Effective switch state of a stored entry: only an explicit `false` reads as off. */
+export function enabledOf(entry: MCPServerConfig): boolean {
+ return entry.config["enabled"] !== false;
+}
+
/** Effective permission mode of a stored entry (an unrecognized value reads as the default). */
export function permissionOf(entry: MCPServerConfig): McpPermissionMode {
const p = entry.config["permission"];
@@ -156,6 +166,7 @@ export function serverToForm(entry: MCPServerConfig): McpServerFormState {
}
return {
name: entry.name,
+ enabled: enabledOf(entry),
transport,
command: typeof c["command"] === "string" ? c["command"] : "",
argsText: Array.isArray(c["args"]) ? c["args"].map((a) => String(a)).join("\n") : "",
@@ -266,6 +277,8 @@ export function formToServer(form: McpServerFormState): McpFormResult {
// Same normalization as the budgets: the default is not written, so the entry keeps
// following the default rather than pinning today's value.
if (form.permission !== MCP_PERMISSION_DEFAULT) config["permission"] = form.permission;
+ // Only the off state is stored (core reads an absent `enabled` as on).
+ if (!form.enabled) config["enabled"] = false;
if (Object.keys(errors).length > 0) return { ok: false, errors };
return { ok: true, server: { name, config } };
diff --git a/packages/web/src/features/agents/mcp-servers-section.tsx b/packages/web/src/features/agents/mcp-servers-section.tsx
index f0bf3dc3..f51dd9fb 100644
--- a/packages/web/src/features/agents/mcp-servers-section.tsx
+++ b/packages/web/src/features/agents/mcp-servers-section.tsx
@@ -15,6 +15,11 @@
* The permission control mirrors the builtin tool table's, with a third `auto` state: it
* decides which of the server's tool calls stop for approval, and nothing about what the
* remote server is able to do.
+ *
+ * Each row carries an on/off switch (`config.enabled`): off keeps the entry and every field
+ * of it, but the server is not connected in any turn, so its `mcp__*` tools leave the tool
+ * list. That is the way to park a plugin's bridge (the WPS add-on, say) without deleting it
+ * and having to re-add it later; the row dims while it is off.
*/
import { useState } from "react";
import type { MCPServerConfig } from "@adelie/core/interfaces";
@@ -27,6 +32,7 @@ import {
OptionMenu,
Segmented,
SettingsEmpty,
+ Switch,
Table,
TableBody,
TableCell,
@@ -45,6 +51,7 @@ import { apiErrorText } from "../../lib/api-error";
import { useProject } from "../../state/project";
import {
emptyMcpForm,
+ enabledOf,
formToServer,
permissionOf,
serverToForm,
@@ -289,6 +296,25 @@ export function McpServersSection({
closeModal();
};
+ /** Flips one row's switch and persists it; the whole list is PUT back, like every edit here. */
+ const toggleEnabled = async (index: number) => {
+ const entry = servers[index];
+ if (!entry) return;
+ const next = servers.map((s, i) => {
+ if (i !== index) return s;
+ if (!enabledOf(s)) {
+ // Back on: drop the key rather than store `true`, so the entry keeps following the
+ // default (core reads an absent `enabled` as on — same normalization as the form).
+ const config = { ...s.config };
+ delete config["enabled"];
+ return { name: s.name, config };
+ }
+ return { name: s.name, config: { ...s.config, enabled: false } };
+ });
+ const err = await persist(next);
+ if (err !== null) toastError(err);
+ };
+
const confirmDelete = async () => {
if (deleting === null) return;
const err = await persist(servers.filter((_, i) => i !== deleting));
@@ -317,6 +343,7 @@ export function McpServersSection({
) : (
<Table tableClassName="min-w-[520px]">
<TableHead>
+ <TableHeaderCell>{S.agent.mcpEnabled}</TableHeaderCell>
<TableHeaderCell>{S.agent.mcpName}</TableHeaderCell>
<TableHeaderCell>{S.agent.mcpTransport}</TableHeaderCell>
<TableHeaderCell>{S.agent.mcpPermission}</TableHeaderCell>
@@ -339,14 +366,33 @@ export function McpServersSection({
<TableBody>
{servers.map((entry, index) => (
<TableRow key={entry.name}>
- <TableCell className="font-mono text-xs">{entry.name}</TableCell>
+ <TableCell>
+ <Switch
+ checked={enabledOf(entry)}
+ disabled={busy}
+ onChange={() => void toggleEnabled(index)}
+ title={enabledOf(entry) ? S.agent.mcpDisableHint : S.agent.mcpEnableHint}
+ aria-label={`${entry.name} ${S.agent.mcpEnabled}`}
+ />
+ </TableCell>
+ <TableCell
+ className={`font-mono text-xs ${enabledOf(entry) ? "" : "text-gray-400 dark:text-gray-500"}`}
+ >
+ {entry.name}
+ </TableCell>
<TableCell className="font-mono text-xs text-gray-500 dark:text-gray-400">
{transportOf(entry)}
</TableCell>
<TableCell className="font-mono text-xs text-gray-500 dark:text-gray-400">
{permissionOf(entry)}
</TableCell>
- <TableCell className="max-w-[360px] truncate font-mono text-xs text-gray-500 dark:text-gray-400">
+ <TableCell
+ className={`max-w-[360px] truncate font-mono text-xs ${
+ enabledOf(entry)
+ ? "text-gray-500 dark:text-gray-400"
+ : "text-gray-400 dark:text-gray-500"
+ }`}
+ >
{targetOf(entry)}
</TableCell>
{showBadges && (
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 7ecc0b7c..712edb69 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -1576,6 +1576,10 @@ export const en: Strings = {
mcpDesc:
"Connect external MCP Servers: their tools join this agent's toolset as mcp__<name>__<tool>. Changes in this block save immediately.",
mcpEmpty: "No MCP Servers configured yet",
+ mcpEnabled: "enabled",
+ mcpEnableHint: "Turn on: this Server connects again from the next turn on",
+ mcpDisableHint:
+ "Turn off: the configuration stays, but the Server is no longer connected and its tools leave the tool list",
mcpAdd: "Add MCP Server",
mcpEditTitle: "Edit MCP Server",
mcpRemove: "Remove",
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 45a0383f..086b87d7 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -1599,6 +1599,9 @@ export const zh = {
mcpDesc:
"连接外部 MCP Server:其工具以 mcp__<name>__<tool> 并入本 Agent 的工具列表。此区块的改动即时保存。",
mcpEmpty: "尚未配置 MCP Server",
+ mcpEnabled: "enabled",
+ mcpEnableHint: "启用:下次对话起重新连接这个 Server",
+ mcpDisableHint: "停用:配置保留,但不再连接,它的工具从工具列表里消失",
mcpAdd: "添加 MCP Server",
mcpEditTitle: "编辑 MCP Server",
mcpRemove: "删除",
diff --git a/packages/web/test/mcp-servers-form.test.ts b/packages/web/test/mcp-servers-form.test.ts
index 78065747..72dc70ca 100644
--- a/packages/web/test/mcp-servers-form.test.ts
+++ b/packages/web/test/mcp-servers-form.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
emptyMcpForm,
+ enabledOf,
formToServer,
parseKeyValueLines,
permissionOf,
@@ -39,6 +40,14 @@ describe("serverToForm", () => {
expect(bad.extras).toEqual({});
});
+ it("loads the on/off switch: only an explicit false reads as off, and it is not an extra", () => {
+ expect(serverToForm({ name: "a", config: { command: "x" } }).enabled).toBe(true);
+ expect(serverToForm({ name: "a", config: { command: "x", enabled: true } }).enabled).toBe(true);
+ const off = serverToForm({ name: "a", config: { command: "x", enabled: false } });
+ expect(off.enabled).toBe(false);
+ expect(off.extras).toEqual({});
+ });
+
it("loads an http entry and keeps unknown config keys as extras", () => {
const form = serverToForm({
name: "web",
@@ -100,6 +109,19 @@ describe("formToServer", () => {
});
});
+ it("writes the off state and normalizes on away", () => {
+ const base = { ...emptyMcpForm(), name: "a", url: "https://x/mcp" };
+ expect(formToServer({ ...base, enabled: false })).toEqual({
+ ok: true,
+ server: { name: "a", config: { transport: "http", url: "https://x/mcp", enabled: false } },
+ });
+ // On is the default: not written, so the entry keeps following it.
+ expect(formToServer({ ...base, enabled: true })).toEqual({
+ ok: true,
+ server: { name: "a", config: { transport: "http", url: "https://x/mcp" } },
+ });
+ });
+
it("merges extras back and lets known fields win", () => {
const form = {
...emptyMcpForm(),
@@ -169,6 +191,14 @@ describe("parseKeyValueLines", () => {
});
});
+describe("enabledOf", () => {
+ it("treats an absent or unrecognized value as on, an explicit false as off", () => {
+ expect(enabledOf({ name: "a", config: { command: "x" } })).toBe(true);
+ expect(enabledOf({ name: "a", config: { command: "x", enabled: "false" } })).toBe(true);
+ expect(enabledOf({ name: "a", config: { command: "x", enabled: false } })).toBe(false);
+ });
+});
+
describe("permissionOf", () => {
it("reports the effective mode of a stored entry", () => {
expect(permissionOf({ name: "a", config: { command: "x", permission: "rw" } })).toBe("rw");