Fix MCP lazy loading in headless mode #8028
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When running the Continue CLI in headless mode (using the
-p
flag), MCP (Model Context Protocol) tools were not being loaded. This was caused by lazy initialization of the MCP service - thegetAllTools()
function would check if MCP was ready synchronously, and if not, it would silently skip MCP tools with a comment// MCP is lazy
.Solution
This PR ensures that in headless mode,
getAllTools()
waits for the MCP service to fully initialize before proceeding. The fix:getService()
to wait for MCP initialization to completeChanges
extensions/cli/src/stream/handleToolCalls.ts
:getService
to enable async service retrievalgetAllTools()
to check headless mode statusTesting
This ensures MCP tools are available when needed in headless mode while preserving the existing behavior for interactive TUI mode.
This agent session was created by nate and co-authored by Continue [email protected].
Summary by cubic
Fixes missing MCP tools in headless CLI mode (-p) by waiting for the MCP service to initialize in getAllTools(). Keeps lazy loading behavior for TUI.