fix(coding-agent): clear stale MCP prompts on reload

MCPManager.disconnectAll clears connections without notifying the session's
prompt-command consumer, so removed or disabled prompt servers left stale
/server:prompt commands after /reload-plugins and /mcp reload.

Clear the session MCP prompt-command registry immediately after disconnect and
before asynchronous rediscovery. Newly loaded prompts repopulate it through
the existing manager callback. Extend the reload regression coverage.

Fixes #7189
This commit is contained in:
roboomp
2026-07-31 16:48:36 +00:00
parent 95744328ef
commit 62d7a7c5c9
3 changed files with 9 additions and 2 deletions
@@ -1997,6 +1997,10 @@ export class MCPCommandController {
// Disconnect all existing servers
await this.ctx.mcpManager.disconnectAll();
// Prompt enrichment is asynchronous. Clear commands before rediscovery so
// removed/disabled servers cannot leave stale `/server:prompt` entries;
// newly loaded prompts repopulate them through the manager callback.
this.ctx.session.setMCPPromptCommands([]);
// Rediscover and connect, mirroring startup's discovery filters.
const result = await this.ctx.mcpManager.discoverAndConnect({