Skip to content

Removing .roo/mcp.json doesn't unload MCP servers until workspace reloadΒ #4431

@hannesrudolph

Description

@hannesrudolph

App Version

v3.19.5

API Provider

Not Applicable / Other

Model Used

N/A

πŸ” Steps to Reproduce

  1. Open a VSCode workspace with Roo Code extension installed
  2. Create a .roo/mcp.json file with MCP server configurations
  3. Verify MCP servers are connected in the MCP Servers view
  4. Delete the .roo/mcp.json file from the file system
  5. Check the MCP Servers view

πŸ’₯ Outcome Summary

Expected: MCP servers from the deleted .roo/mcp.json should be immediately disconnected and removed from the MCP Servers view
Actual: MCP servers remain connected and active until the VSCode workspace is reloaded

πŸ“„ Relevant Logs or Errors

No specific error messages are shown. The servers simply remain active despite the configuration file being deleted.

Technical Context (from codebase exploration)

Based on my investigation:

  • The issue is in src/services/mcp/McpHub.ts
  • The watchProjectMcpFile() method (line 279) watches for file saves but not deletions
  • The handleConfigFileChange() method (line 255) reads the file content but doesn't handle the case where the file no longer exists
  • When the file is deleted, the file watcher triggers, but the subsequent fs.readFile() would fail, and the error is caught without properly cleaning up the project MCP servers
  • The updateServerConnections() method (line 815) properly handles server removal when servers are removed from the config, but it's never called with an empty server list when the file is deleted

Related Code

  • watchProjectMcpFile() uses vscode.workspace.onDidSaveTextDocument which doesn't capture file deletion events
  • Need to also watch for file deletion using vscode.workspace.createFileSystemWatcher with onDidDelete event
  • Should call cleanupProjectMcpServers() when the project MCP file is deleted

Related Discussions

Related to PR #4267 which adds MCP server refresh functionality but doesn't address file deletion handling.

Metadata

Metadata

Assignees

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions