Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 21, 2025

Fixes #6036

This PR fixes the issue where disabled MCP servers were still starting processes and showing incorrect status indicators in the UI.

Changes:

  • Added disabled check in updateServerConnections() to prevent connecting to disabled servers
  • Modified toggleServerDisabled() to disconnect servers when disabling and reconnect when enabling
  • Updated UI to show grey/disabled color for disabled servers
  • Added comprehensive tests for disabled server behavior

All existing tests pass and new tests verify the fix works correctly.


Important

Fixes issue where disabled MCP servers incorrectly start processes and show incorrect status by updating server connection logic and UI.

  • Behavior:
    • Prevents disabled MCP servers from starting processes by adding a disabled check in updateServerConnections() in McpHub.ts.
    • Modifies toggleServerDisabled() in McpHub.ts to disconnect servers when disabling and reconnect when enabling.
    • Updates UI in McpView.tsx to show grey/disabled color for disabled servers.
  • Tests:
    • Adds comprehensive tests for disabled server behavior in McpHub.spec.ts, including tests for initialization, toggling, and error handling.
  • Misc:
    • Removes reference counting in McpHub.ts to prevent premature disposal.

This description was created by Ellipsis for a1f24ec. You can customize this summary. It will automatically update as commits are pushed.

…rrect status

- Add disabled check in updateServerConnections() before connecting to servers
- Disconnect servers immediately when toggling to disabled state
- Update UI to show grey/disabled color for disabled servers
- Add comprehensive tests for disabled server behavior

Fixes #6036
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 21, 2025 22:11
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working UI/UX UI/UX related or focused labels Jul 21, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 21, 2025
- Centralize disabled state validation in connectToServer() method
- Add protection against race conditions in toggleServerDisabled()
- Remove redundant grey color indicator (keep only opacity)
- Remove unnecessary status checks in toggle logic
- Add comprehensive test coverage for edge cases
- Fix failing test by ensuring correct disabled state in config
- Modified getServers() to filter out disabled servers (for prompt system)
- getAllServers() returns all servers including disabled (for UI)
- Updated updateServerConnections to create connection objects for disabled servers
- Fixed toggleServerDisabled to properly handle re-enabling servers
- Added test coverage for getAllServers() method

This ensures disabled servers appear in the UI with visual indicators while preventing their use in prompts and tool calls.
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 22, 2025
…om restarting

- Removed redundant refCount logic from McpHub that conflicted with singleton pattern
- Made registerClient/unregisterClient no-ops to maintain API compatibility
- Added checks in restartConnection and setupFileWatcher to skip disabled servers
- Added comprehensive test coverage for disabled server restart prevention
- This fixes the issue where moving the Roo view between panes could disconnect all MCP servers
@hannesrudolph hannesrudolph force-pushed the fix/disabled-mcp-servers-issue-6036 branch from 67635d3 to b4e1337 Compare July 22, 2025 18:17

// Create a placeholder connection for disabled servers
// This is needed so the server still appears in the UI
const parsedConfig = JSON.parse(storedConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider wrapping the JSON.parse call on storedConfig in a try/catch block to guard against invalid JSON and log parsing errors for easier debugging.

This comment was generated because it violated a code review rule: irule_PTI8rjtnhwrWq6jS.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Jul 22, 2025
- Add isInitializing flag to prevent file watchers from creating duplicate connections
- Refactor constructor to use async initialization method
- Skip config change handling during initialization phase
- Add test to verify no duplicate connections are created
- Fixes issue where Docker (MCP) processes were duplicated on startup
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 22, 2025
…watcher

- Added check in handleConfigFileChange to ignore file change events for servers with active toggle operations
- This prevents the race condition where disabling a server triggers a config write, which triggers the file watcher, which would restart the server
- Fixes the issue where disabled servers would immediately restart after being shut down
…rvers

- Added null checks in deleteConnection to prevent errors when closing disabled servers
- Disabled servers have null client and transport, so we need to check before calling close()
- Updated test expectations for concurrent toggle operations (now allows multiple executions)
- Fixes the 'Cannot read properties of null' error when toggling server state
…state

- Use configChangeDebounceTimers map to flag programmatic config changes
- Set null timer value before updating config to signal file watcher to skip
- File watcher checks for null flag and skips processing if found
- Automatically clear flag after 1 second to restore normal operation
- Added debug logging to trace execution flow
- Fixes issue where both toggleServerDisabled and file watcher would call updateServerConnections
@hannesrudolph hannesrudolph moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jul 22, 2025
@hannesrudolph hannesrudolph self-assigned this Jul 22, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Draft / In Progress size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Disabled MCP servers still start processes and show incorrect status indicators

3 participants