diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index c711d682f..0be974ce4 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixed -- Fixed `/reload-plugins` not reconnecting MCP servers or refreshing the session's MCP tool registry despite listing MCP in its documented reload scope, so `.mcp.json` edits stayed inactive until restart. The TUI reload pipeline now runs the same disconnect/rediscover/`refreshMCPTools` path as `/mcp reload`, deriving discovery filters from settings so the reload keeps honoring `mcp.enableProjectConfig: false` instead of starting opted-out project servers ([#7189](https://github.com/can1357/oh-my-pi/issues/7189)). +- Fixed `/reload-plugins` not reconnecting MCP servers or refreshing the session's MCP tool and prompt-command registries despite listing MCP in its documented reload scope, so `.mcp.json` edits stayed inactive and removed prompt commands remained invocable until restart. The TUI reload pipeline now clears stale MCP prompt commands and runs the same disconnect/rediscover/`refreshMCPTools` path as `/mcp reload`, deriving discovery filters from settings so the reload keeps honoring `mcp.enableProjectConfig: false` instead of starting opted-out project servers ([#7189](https://github.com/can1357/oh-my-pi/issues/7189)). ## [17.2.1] - 2026-07-30 diff --git a/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts b/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts index 0c9e0fd57..317352089 100644 --- a/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts +++ b/packages/coding-agent/src/modes/controllers/mcp-command-controller.ts @@ -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({ diff --git a/packages/coding-agent/test/reload-plugins-mcp.test.ts b/packages/coding-agent/test/reload-plugins-mcp.test.ts index b805cf1ea..2af69eb08 100644 --- a/packages/coding-agent/test/reload-plugins-mcp.test.ts +++ b/packages/coding-agent/test/reload-plugins-mcp.test.ts @@ -24,6 +24,7 @@ function createFakeCtx(cwd: string, settingsValues: Record = {} }; const session = { refreshMCPTools: vi.fn(async (_tools: unknown) => {}), + setMCPPromptCommands: vi.fn((_commands: unknown) => {}), }; const ctx = { mcpManager, @@ -52,7 +53,7 @@ describe("/reload-plugins MCP reconnect (#7189)", () => { await removeWithRetries(projectDir); }); - test("reconnects MCP servers and rebinds session MCP tools", async () => { + test("reconnects MCP servers, rebinds tools, and clears stale prompt commands", async () => { const { ctx, mcpManager, session, mcpTools } = createFakeCtx(projectDir); const runtime: TuiSlashCommandRuntime = { ctx }; @@ -62,6 +63,8 @@ describe("/reload-plugins MCP reconnect (#7189)", () => { expect(mcpManager.discoverAndConnect).toHaveBeenCalledTimes(1); expect(session.refreshMCPTools).toHaveBeenCalledTimes(1); expect(session.refreshMCPTools).toHaveBeenCalledWith(mcpTools); + expect(session.setMCPPromptCommands).toHaveBeenCalledTimes(1); + expect(session.setMCPPromptCommands).toHaveBeenCalledWith([]); }); test("honors mcp.enableProjectConfig=false so opted-out project servers are not started on reload", async () => {