fix: MCP Install in a remote dev env#146
Conversation
When installing the Trivy MCP server using the extension, the plugin is correctly installed in the remote environment, but the MCP Server configuration was being written to the host. This checks whether operating in a remote window and writes to the correct config
There was a problem hiding this comment.
Pull request overview
This PR fixes MCP (Model Context Protocol) server configuration in remote development environments. Previously, when using the extension in a remote environment (e.g., Remote-SSH, Dev Containers), the MCP plugin would install correctly in the remote environment, but the configuration was being written to the host machine instead of the remote workspace.
Key Changes:
- Detects remote environments using
vscode.env.remoteNameand writes configuration to the appropriate location (workspace for remote, global for local) - Refactors configuration approach from using VS Code's configuration API to direct JSON file manipulation
- Makes the MCP menu always visible to allow installation even when not yet configured
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/mcp/install.ts | Adds remote environment detection, switches from configuration API to direct JSON file manipulation for MCP settings, and updates both chat config and MCP server config to use the appropriate target (workspace vs global) |
| package.json | Bumps version to 1.8.10 and removes trivy.mcpServerInstalled condition from MCP submenu visibility to allow installation from menu |
| CHANGELOG.md | Documents the remote development environment configuration fix in version 1.8.10 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await vscode.commands.executeCommand(openCommand); | ||
|
|
||
| // Wait for the editor to open | ||
| await new Promise((resolve) => setTimeout(resolve, 100)); |
There was a problem hiding this comment.
The hardcoded 100ms timeout may not be sufficient for the editor to open, especially on slower systems or under heavy load. Consider using a more robust approach such as:
- Polling with
vscode.window.onDidChangeActiveTextEditorevent listener - Using a longer timeout with retry logic
- Or better yet, using the return value from
executeCommandif the command provides it
This timing-based approach could lead to intermittent failures where the configuration file is not properly updated.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
When installing the Trivy MCP server using the extension, the plugin is
correctly installed in the remote environment, but the MCP Server
configuration was being written to the host. This checks whether
operating in a remote window and writes to the correct config
Closes #145