Skip to content

fix(mcp): refresh prompt slash commands#32129

Open
rekram1-node wants to merge 3 commits into
devfrom
mcp-prompt-refresh
Open

fix(mcp): refresh prompt slash commands#32129
rekram1-node wants to merge 3 commits into
devfrom
mcp-prompt-refresh

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #28579

Related to #28567

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

MCP prompts are part of the cached command catalog. When an MCP server connects after that cache is initialized, disconnects, is replaced, or sends notifications/prompts/list_changed, the slash-command list can remain stale.

This adds a prompt catalog invalidation flow that publishes an MCP catalog event when prompt availability may have changed, rebuilds the command catalog, publishes command.changed, and refreshes command state in the app and TUI clients. Notifications from disconnected or replaced clients are ignored, and the notification handler is registered only when the server advertises prompts.listChanged.

Command refresh failures are handled so event-driven refreshes do not create unhandled promise rejections.

How did you verify your code works?

  • Added integration coverage proving a prompt-list notification removes stale slash commands, adds replacement commands, and publishes command.changed.
  • Added coverage for MCP catalog invalidation on prompt-list notifications and client replacement.
  • Added app reducer coverage for command refresh dispatch.
  • Ran bun test test/mcp/lifecycle.test.ts in packages/opencode (33 passing).
  • Ran bun test src/context/global-sync/event-reducer.test.ts in packages/app (15 passing).
  • Ran bun typecheck in packages/opencode, packages/app, and packages/tui.

Screenshots / recordings

Not applicable.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: MCP prompts are no longer listed after connecting MCP server

2 participants