* feat(sdk): add mcp_server_added daemon event type (T2.8 #4514)
Schema-only addition. New event fires on POST /workspace/mcp/servers
success including replace and same-fingerprint no-op, carrying
{name, transport, replaced, shadowedSettings, toolCount, originatorClientId}.
Also exports DAEMON_KNOWN_EVENT_TYPE_VALUES from the public SDK
surface so drift-insurance tests can assert on the known-event roster.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(sdk): add mcp_server_removed daemon event type (T2.8 #4514)
Counterpart to mcp_server_added. Fires on DELETE /workspace/mcp/servers/:name
that actually dropped an entry. Idempotent skip ('not_present') does NOT emit.
Payload {name, wasShadowingSettings, originatorClientId}.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(sdk): add runtime MCP add/remove request + result types (T2.8 #4514)
Discriminated unions for add/remove results so caller can narrow on
.skipped vs success. Add request mirrors the route body shape.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(core): add Config.addRuntimeMcpServer / removeRuntimeMcpServer (T2.8 #4514)
Runtime-only overlay map separate from this.mcpServers (settings layer).
Bypasses the initialized-guard on addMcpServers since the entire point is
post-init mutation. getMcpServers() cascade extension comes in the next
task.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* docs(core): tighten Config.addRuntimeMcpServer JSDoc wording (T2.8 #4514)
"intentionally bypasses the guard" implied a suppressed if-throw; clarify
to "does not enforce the guard" since there is nothing to bypass.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(core): runtime MCP overlay in getMcpServers cascade (T2.8 #4514)
runtimeMcpServers Map is applied as the last (winning) layer over
extensions + this.mcpServers, then filtered by allowedMcpServers.
Shadow semantics for T2.8 fall out of merge order — runtime entries
override settings entries by name; removeRuntimeMcpServer un-shadows.
excludedMcpServers exclusion continues to flow through isMcpServerDisabled
(UI layer), unchanged from prior behaviour.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(core): McpClientManager.{add,remove}RuntimeMcpServer + budget/pool wiring (T2.8 #4514)
Adds runtime MCP server lifecycle on the manager:
- addRuntimeMcpServer: budget tryReserve → Config runtime overlay → pool acquire
- removeRuntimeMcpServer: Config drop → pool drain → budget release
Shadow-over-settings detected via getSettingsMcpServers raw-map accessor on
Config. Idempotent replace via fingerprint dedup at pool layer. Budget warn
mode returns skipped soft-refuse rather than spawning. New error classes:
McpBudgetWouldExceedError, McpServerSpawnFailedError, InvalidMcpConfigError.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(acp-bridge): add T2.8 error kinds (mcp_budget_would_exceed, mcp_server_spawn_failed, invalid_config) (#4514)
Mirrored on the SDK via DAEMON_ERROR_KINDS export. Bridge maps the matching
typed error classes (McpBudgetWouldExceedError, McpServerSpawnFailedError,
InvalidMcpConfigError) to these kinds in sendBridgeError (next task).
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(acp-bridge): host-side {add,remove}RuntimeMcpServer methods + event fan-out (T2.8 #4514)
Bridge round-trips qwen/control/workspace/mcp/runtime-{add,remove} ACP
ext-methods and emits mcp_server_added / mcp_server_removed via
broadcastWorkspaceEvent. Soft-refuse (budget_warning_only) and idempotent
skip (not_present) paths do NOT emit events.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(acp-bridge): qwen/workspace/mcp/runtime-{add,remove} ext-methods (T2.8 #4514)
Child-side ACP handlers delegate to McpClientManager.{add,remove}RuntimeMcpServer.
Mirror /workspace/mcp/:server/restart registration pattern including typed-error
→ ACP error mapping (code field preserved for sendBridgeError mapping at the HTTP
layer in Task 10).
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(serve): POST /workspace/mcp/servers route (T2.8 #4514)
Mutate-strict route validates name + config shape, parses + validates
X-Qwen-Client-Id, forwards to HttpAcpBridge.addRuntimeMcpServer. Errors
propagated from ACP via RequestError(data.errorKind) and mapped to HTTP
status in sendBridgeError: mcp_budget_would_exceed → 409,
mcp_server_spawn_failed → 502 (body includes exitCode/stderr/timeout),
invalid_config → 400, acp_channel_unavailable → 503.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(serve): DELETE /workspace/mcp/servers/:name route (T2.8 #4514)
Mutate-strict route validates :name path param (alphanumeric + _-,
≤ MAX_SERVER_NAME_LENGTH), parses + validates X-Qwen-Client-Id, forwards
to HttpAcpBridge.removeRuntimeMcpServer. Idempotent: missing entry returns
200 {skipped:true, reason:'not_present'}.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(serve): mcp_server_runtime_mutation capability tag (T2.8 #4514)
Always-on tag in SERVE_CAPABILITY_REGISTRY. Pre-flight check before
POST /workspace/mcp/servers — older daemons silently 404.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* feat(sdk): DaemonClient.{add,remove}RuntimeMcpServer helpers (T2.8 #4514)
Thin wrappers around POST /workspace/mcp/servers and
DELETE /workspace/mcp/servers/:name. Mirrors restartMcpServer helper.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* docs(serve): document runtime MCP server mutation routes (T2.8 #4514)
POST /workspace/mcp/servers + DELETE /workspace/mcp/servers/:name
with shadow-over-settings semantics, ephemeral persistence,
mcp_server_runtime_mutation capability tag, and event emission.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* fix(test): index-signature property access in acpAgent T2.8 test (#4514)
Pre-commit typecheck (cli workspace) flagged err.data.errorKind /
err.data.serverName needing bracket notation. Switch to data?.['errorKind']
to satisfy noPropertyAccessFromIndexSignature.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* fix(serve): address 5 Critical review items from wenshao (T2.8 #4514)
C1: Flatten spawn_failed details at ACP layer (spread err.details, not
nest under data.details) so HTTP 502 body exposes exitCode/stderr/timeout.
C2: Add toolRegistry.removeMcpToolsByServer + removeMCPServerStatus +
stopHealthCheck to removeRuntimeMcpServer (mirrors removeServer cleanup).
C3: Bridge throws error with data.errorKind='acp_channel_unavailable' instead
of SessionNotFoundError so sendBridgeError maps to documented 503.
C4: Require X-Qwen-Client-Id header on POST/DELETE runtime MCP routes —
return 400 missing_client_id instead of coercing to empty string.
C5: Remove releaseSlotName in standalone replace path — budget slot carries
over to the new entry, preventing accounting leak.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* fix(core+cli): address round 4-6 Critical review items (T2.8 #4514)
- Replace flow: add toolRegistry.removeMcpToolsByServer + stopHealthCheck
before disconnecting old entry (fixes stale tool + timer leak)
- Spawn-failure catch: add toolRegistry.removeMcpToolsByServer +
stopHealthCheck (fixes orphaned tools from partial discover)
- Strip `trust` field from config in acpAgent ext-method handler
(security: prevents runtime-added servers from bypassing permission gates)
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* fix(serve): address rounds 5-7 review items — build, security, correctness (T2.8 #4514)
Build breakers (Critical):
- events.ts: add missing /** JSDoc opener for DaemonMcpServerAddedData
- events.ts: add missing `: undefined` arm in followup_suggestion ternary
- events.ts: close isFollowupSuggestionData function body (missing ); })
Security (Critical):
- acpAgent: strip authProviderType, includeTools, excludeTools, cwd from
runtime-added server configs (prevents SSRF via cloud creds leak and
arbitrary cwd spawn)
- mcp-client-manager: reject servers in excludedMcpServers blocklist
- acpAgent: add Array.isArray guard to config validation
Correctness:
- mcp-client-manager: identity-check on pooledConnections.delete in remove
(prevents concurrent add+remove race deleting NEW pool entry)
- mcp-client-manager: add client.disconnect() in catch block for
standalone path (prevents transport/process leak)
- mcp-client-manager: add consecutiveFailures, isReconnecting,
dropRefusalEntry cleanup in removeRuntimeMcpServer
- mcp-client-manager: emit mcp-client-update on spawn failure cleanup
- mcp-client-manager: extract exitCode from error when available
- mcp-client-manager: fix replaced=true → false for same-fingerprint
idempotent re-add (no transport was torn down)
- server.ts: whitelist error fields in sendBridgeError responses
(prevent unbounded internal ACP data spread)
- bridge.ts: remove dead try/catch in addRuntimeMcpServer (all branches
just re-threw)
- bridge.ts: add try/catch to removeRuntimeMcpServer for error mapping
- bridge.ts: narrow AddOk.transport to literal union type
SDK / DX:
- DaemonClient: add timeoutMs param to addRuntimeMcpServer (default 330s,
matching restartMcpServer — prevents 30s SDK timeout vs 5min bridge)
- mcp-client-manager: add debugLogger.info at method entry
Docs:
- qwen-serve.md: clarify replaced:true vs replaced:false semantics
* fix(serve): strip env field, add status cleanup and name validation (T2.8 #4514)
Security:
- Strip `env` from runtime-added MCP server configs (prevents
NODE_OPTIONS/LD_PRELOAD injection via HTTP body)
Correctness:
- Add `removeMCPServerStatus(name)` in spawn-failure catch block
(prevents stale CONNECTING entry in status registry)
Hardening:
- Add name validation (charset + length) to ACP ext-method handlers
for both add and remove (matches HTTP route validation)
* fix(serve): strip oauth/headers, reject __proto__ names, fix remove timeout (T2.8 #4514)
Security:
- Strip `oauth` and `headers` from runtime-added configs (prevents
credential exfiltration via OAuth flow and header injection)
- Reject `__proto__`, `constructor`, `prototype` as server names
(prevents prototype pollution when name becomes object key)
SDK:
- Add timeoutMs to removeRuntimeMcpServer (match add's 330s default)
Docs:
- Remove `env` from POST example (stripped by daemon since 66dc4ce1c)
- Document stripped fields list
* fix(serve): strip type field, add __proto__ rejection to HTTP routes (T2.8 #4514)
Security:
- Strip `type` from runtime config (prevents SDK transport routing bypass)
- Add __proto__/constructor/prototype rejection to HTTP POST route
(ACP handlers already had this; HTTP routes were missing it)
Docs:
- Add includeTools, excludeTools, type to stripped-fields list
* fix(serve): add name validation + __proto__ guard to DELETE route (T2.8 #4514)
* fix(serve): remove dead code in DELETE route validation (T2.8 #4514)
* fix(serve): restore MAX_SERVER_NAME_LENGTH in DELETE, add __proto__ to POST (T2.8 #4514)
* fix(serve): split validation into precise error messages + add test coverage (T2.8 #4514)
Split combined regex + reserved-name validation into separate checks with
distinct error messages on both POST and DELETE routes. Added tests for
__proto__/constructor/prototype rejection on POST, and MAX_SERVER_NAME_LENGTH +
reserved-name rejection on DELETE.