Conversation
Re-implements the --env feature from PR #30 to allow users to pass environment variables when installing MCP servers. Changes: - Add --env option to CLI that accepts key-value pairs - Add parseEnvVars() function to convert array format to object - Update setServerConfig() to properly handle env vars for different clients: - Goose: uses 'envs' field instead of 'env' - Zed: uses 'env' field - All other clients: uses 'env' field - Apply env vars to URL-based and command-based installations - Update Warp config output to include env vars Usage: npx install-mcp <server> --client <client> --env KEY1 value1 --env KEY2 value2 Closes #30
|
Claude finished @Dhravya's task —— View job Code Review CompleteI've completed a thorough review of PR #34's implementation of the Todo List
✅ StrengthsGood Implementation Choices:
Code Quality:
|
| source: 'custom', | ||
| command: serverConfig.command, | ||
| args: serverConfig.args, | ||
| env: {}, | ||
| env: serverConfig.env || {}, | ||
| ...serverConfig, // Allow overriding defaults | ||
| } | ||
| } else if (client === 'opencode') { |
There was a problem hiding this comment.
Bug: The OpenCode client configuration handler silently discards environment variables from serverConfig.env, hardcoding an empty environment object for local servers and omitting it for remote ones.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
When installing a server for the OpenCode client using the --env flag, the provided environment variables are silently ignored. For local servers, the environment property is hardcoded to an empty object ({}). For remote servers, the property is omitted entirely. This behavior is inconsistent with other clients like Zed and Warp, which correctly apply the environment variables from serverConfig.env. This leads to a silent failure where users believe their configuration is applied, but it is not, potentially causing misconfigured server setups.
💡 Suggested Fix
In the OpenCode handler for local servers, replace the hardcoded environment: {} with environment: serverConfig.env || {} to correctly pass through the environment variables provided by the user.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/commands/install.ts#L30-L54
Potential issue: When installing a server for the OpenCode client using the `--env`
flag, the provided environment variables are silently ignored. For local servers, the
`environment` property is hardcoded to an empty object (`{}`). For remote servers, the
property is omitted entirely. This behavior is inconsistent with other clients like Zed
and Warp, which correctly apply the environment variables from `serverConfig.env`. This
leads to a silent failure where users believe their configuration is applied, but it is
not, potentially causing misconfigured server setups.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8130120
Re-implements the --env feature from PR #30 to allow users to pass environment variables when installing MCP servers.
Changes:
Usage:
npx install-mcp --client --env KEY1 value1 --env KEY2 value2
Closes #30