Skip to content

Conversation

continue[bot]
Copy link
Contributor

@continue continue bot commented Sep 30, 2025

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 - the getAllTools() 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:

  1. Checks if we're in headless mode using the ToolPermissionService state
  2. If in headless mode and MCP is not ready, awaits getService() to wait for MCP initialization to complete
  3. If in TUI mode, maintains the existing lazy loading behavior

Changes

  • Modified extensions/cli/src/stream/handleToolCalls.ts:
    • Added import for getService to enable async service retrieval
    • Updated getAllTools() to check headless mode status
    • Added conditional logic to wait for MCP service in headless mode
    • Improved logging to indicate when waiting for MCP service

Testing

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.

  • Bug Fixes
    • Detect headless mode via ToolPermissionService and await getService(MCP) until ready.
    • In TUI, continue without MCP tools if MCP isn’t ready (lazy load).
    • Added debug logs; updated extensions/cli/src/stream/handleToolCalls.ts to import and use getService.

When running in headless mode (-p flag), MCP tools were not being
loaded because the service initialization was lazy. The getAllTools()
function would check if MCP was ready synchronously, and if not, it
would silently skip MCP tools with a comment '// MCP is lazy'.

This fix ensures that in headless mode, getAllTools() waits for the
MCP service to fully initialize before proceeding. This is done by:

1. Checking if we're in headless mode using the ToolPermissionService
2. If in headless mode and MCP is not ready, await getService() to wait
   for MCP initialization to complete
3. If in TUI mode, maintain the existing lazy loading behavior

This ensures MCP tools are available when needed in headless mode
while preserving the existing behavior for interactive TUI mode.

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <[email protected]>
@continue continue bot requested a review from a team as a code owner September 30, 2025 03:19
@continue continue bot requested review from RomneyDa and removed request for a team September 30, 2025 03:19
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 30, 2025
Copy link

⚠️ PR Title Format

Your PR title doesn't follow the conventional commit format, but this won't block your PR from being merged. We recommend using this format for better project organization.

Expected Format:

<type>[optional scope]: <description>

Examples:

  • feat: add changelog generation support
  • fix: resolve login redirect issue
  • docs: update README with new instructions
  • chore: update dependencies

Valid Types:

feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert

This helps with:

  • 📝 Automatic changelog generation
  • 🚀 Automated semantic versioning
  • 📊 Better project history tracking

This is a non-blocking warning - your PR can still be merged without fixing this.

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation feels a bit off, e.g. getting isHEadless from tool permission state vs just passing through to the getTools functions, spaghetti logic, and no unit tests

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Sep 30, 2025
@RomneyDa
Copy link
Collaborator

RomneyDa commented Oct 6, 2025

closing for #8110

@RomneyDa RomneyDa closed this Oct 6, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Oct 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants