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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user