[PR #9163] fix: defer MCP command loading to background #13013

Open
opened 2026-02-16 18:17:53 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9163

State: open
Merged: No


What does this PR do?

Prevents Command.state() from waiting on MCP prompt loading, allowing user commands to appear immediately on startup without being blocked by MCP initialization.

Key changes:

  • Separates user command loading (synchronous) from MCP command loading (background)
  • Initializes MCP commands asynchronously via Command.initMCPCommands() called during bootstrap
  • Publishes command.updated event when MCP commands are ready, syncing the TUI without blocking
  • Reduces startup impact from slow or failing remote MCPs (which attempt two transports sequentially: StreamableHTTP → SSE)
  • Adds guard clause in Session.prompt.command() to handle missing commands gracefully

How did you verify your code works?

  • Tested with multiple remote MCPs configured
  • Verified custom user commands appear immediately on startup without waiting for MCP initialization
  • Confirmed MCP commands appear progressively as each MCP finishes loading

Issues

Fixes #8868
Fixes #8017

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9163 **State:** open **Merged:** No --- ### What does this PR do? Prevents `Command.state()` from waiting on MCP prompt loading, allowing user commands to appear immediately on startup without being blocked by MCP initialization. **Key changes:** - Separates user command loading (synchronous) from MCP command loading (background) - Initializes MCP commands asynchronously via `Command.initMCPCommands()` called during bootstrap - Publishes `command.updated` event when MCP commands are ready, syncing the TUI without blocking - Reduces startup impact from slow or failing remote MCPs (which attempt two transports sequentially: StreamableHTTP → SSE) - Adds guard clause in `Session.prompt.command()` to handle missing commands gracefully ### How did you verify your code works? - Tested with multiple remote MCPs configured - Verified custom user commands appear immediately on startup without waiting for MCP initialization - Confirmed MCP commands appear progressively as each MCP finishes loading ### Issues Fixes #8868 Fixes #8017
yindo added the pull-request label 2026-02-16 18:17:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13013