Skip to content

fix: prevent disabled MCP servers from starting processes and show correct status #6084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Jul 22, 2025

This PR fixes the issue where disabled MCP servers were still starting processes and showing incorrect status indicators in the UI. It also ensures that when MCP is globally disabled, all servers are immediately disconnected and prevented from starting.

Problem

  • Disabled MCP servers were still attempting to start processes
  • UI showed incorrect status indicators for disabled servers
  • When "Enable MCP Servers" was unchecked globally, servers continued running until plugin reload
  • Error messages and retry buttons were shown for disabled servers

Solution

When "Enable MCP Servers" is unchecked globally:

All MCP servers are now immediately disconnected and prevented from starting.

image

When individual MCP server toggle is set to off:

The individual MCP server is properly disabled and shows correct status.

image

Changes Made

Backend Changes

McpHub.ts

  • Added isMcpEnabled() helper to centralize MCP enabled state checking
  • Created createPlaceholderConnection() helper to eliminate duplicate code
  • Modified connectToServer() to check both global MCP state and individual server disabled state
  • Updated refreshAllConnections() to respect global MCP setting
  • Enhanced toggleServerDisabled() to properly disconnect/reconnect servers
  • Fixed type safety by allowing null client/transport in McpConnection type
  • Added proper null checks throughout the codebase
  • Only setup file watchers for enabled servers

webviewMessageHandler.ts

  • Added logic to actively disconnect all running MCP servers when MCP is globally disabled
  • Added error handling to server disconnection loop
  • Servers automatically reconnect when MCP is re-enabled

Frontend Changes (McpView.tsx)

  • Updated getStatusColor() to always show grey (--vscode-descriptionForeground) for disabled servers
  • Modified UI to hide error messages and retry buttons for disabled servers
  • Prevented expansion of disabled servers in the UI
  • Added isExpandable computed property to centralize expansion logic
  • Updated cursor and chevron display logic for disabled servers

Test Coverage (McpHub.spec.ts)

  • Added comprehensive tests for toggling global MCP enabled state while servers are active
  • Added tests for handling refreshAllConnections() when MCP is disabled
  • Added tests for skipping connection restart when MCP is disabled
  • Added tests to verify servers don't start when MCP is globally disabled
  • Added tests for toggling individual server disabled state
  • Added edge case tests for various scenarios

Result

  • Disabled servers no longer attempt to start processes
  • UI shows a clear grey status indicator for disabled servers
  • No misleading error messages or retry buttons are shown for disabled servers
  • Servers are immediately disconnected when MCP is globally disabled
  • The full configuration (including disabled servers) is maintained in the mcp.json file for user management
  • Improved code maintainability with helper functions and better type safety

Fixes #6036

Co-authored-by: Hannes Rudolph hrudolph@gmail.com


Important

Fixes MCP server management to prevent disabled servers from starting and updates UI to reflect correct status.

  • Behavior:
    • Disabled MCP servers no longer start processes and show correct status in UI.
    • Global MCP disable immediately disconnects all servers.
    • UI hides error messages and retry buttons for disabled servers.
  • Backend Changes:
    • McpHub.ts: Added isMcpEnabled() and createPlaceholderConnection() helpers.
    • Updated connectToServer() and refreshAllConnections() to respect global MCP state.
    • Enhanced toggleServerDisabled() to handle server state changes.
  • Frontend Changes:
    • McpView.tsx: Updated getStatusColor() to show grey for disabled servers.
    • Prevented expansion of disabled servers in UI.
    • Added isExpandable property for server expansion logic.
  • Test Coverage:
    • Added tests for global MCP state toggling and server state handling in McpHub.spec.ts.

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

@roomote roomote bot requested review from mrubens, cte and jr as code owners July 22, 2025 22:19
@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 22, 2025
…rrect status

- Backend: Skip connecting to disabled servers in connectToServer()
- Backend: Handle enable/disable state changes properly in toggleServerDisabled()
- Backend: Only setup file watchers for enabled servers
- Frontend: Show grey status indicator for disabled servers
- Frontend: Hide error messages and retry buttons for disabled servers
- Frontend: Prevent expansion of disabled server rows

Fixes #6036
@roomote roomote bot force-pushed the fix/disabled-mcp-servers-status branch from c6b819d to a2a8bfc Compare July 22, 2025 22:28
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 22, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 22, 2025
@hannesrudolph hannesrudolph deleted the fix/disabled-mcp-servers-status branch July 22, 2025 22:50
@hannesrudolph hannesrudolph restored the fix/disabled-mcp-servers-status branch July 23, 2025 04:54
@hannesrudolph hannesrudolph reopened this Jul 23, 2025
@github-project-automation github-project-automation bot moved this from Done to New in Roo Code Roadmap Jul 23, 2025
@github-project-automation github-project-automation bot moved this from Done to Triage in Roo Code Roadmap Jul 23, 2025
- Added check for global mcpEnabled state in connectToServer method
- Updated refreshAllConnections to respect global MCP setting
- Updated restartConnection to check global MCP state
- Added tests to verify servers don't start when MCP is disabled
- Ensures disabled servers show correct status in UI
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 23, 2025
- Modified webviewMessageHandler to actively disconnect all running MCP servers when the 'Enable MCP Servers' checkbox is unchecked
- Added logic to reconnect servers when MCP is re-enabled
- This ensures servers are shut down immediately without requiring a plugin reload
- Extract duplicate placeholder connection creation logic into createPlaceholderConnection helper
- Fix type safety by allowing null client/transport in McpConnection type
- Add proper null checks throughout the codebase
- Add error handling to server disconnection loop in webviewMessageHandler
- Centralize MCP enabled state checking with isMcpEnabled helper
- Extract repeated UI condition into isExpandable computed property
- Add comprehensive test coverage for edge cases including:
  - Toggling global MCP enabled state while servers are active
  - Handling refreshAllConnections when MCP is disabled
  - Skipping connection restart when MCP is disabled
@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 23, 2025
@hannesrudolph hannesrudolph removed the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 23, 2025
@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 24, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 24, 2025
* @param enabled Whether MCP should be enabled or disabled
* @returns Promise<void>
*/
async handleMcpEnabledChange(enabled: boolean): Promise<void> {
Copy link

Choose a reason for hiding this comment

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

The handleMcpEnabledChange method cleanly disconnects all servers when MCP is globally disabled and then refreshes connections. However, inline fallback strings (using the || operator) in translation calls should be removed to adhere to i18n best practices.

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

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 - Needs Review size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused
Projects
Status: PR [Needs Review]
Development

Successfully merging this pull request may close these issues.

Disabled MCP servers still start processes and show incorrect status indicators
3 participants