fix: support 'mcp' as command-line argument#241
fix: support 'mcp' as command-line argument#241Jah-yee wants to merge 1 commit intoaidenybai:mainfrom
Conversation
- Add 'mcp' to AGENTS array in templates.ts - Add 'mcp' to AGENT_NAMES - Simplify AgentIntegration type (mcp is now part of Agent) - Add MCP handling in add.ts when passed as argument - Update script template functions to handle 'mcp' specially - Filter 'mcp' from PROVIDERS (no npm package needed) - Update success message for non-interactive mode Fixes: aidenybai#240
|
Error agent completed without reporting progress |
|
Someone is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| logger.log("Restart your agents to activate."); | ||
| logger.break(); | ||
| projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"]; | ||
| } |
There was a problem hiding this comment.
Missing early exit after MCP installation causes unintended behavior
High Severity
After the MCP-specific installation block completes successfully at line 130, the code falls through to the generic agent installation flow instead of exiting. This causes getPackagesToInstall("mcp", false) at line 418 to return ["@react-grab/mcp"], which then gets installed as a local dev dependency via npm install -D @react-grab/mcp — this is unintended since MCP uses npx -y @react-grab/mcp --stdio on-demand. The user also sees duplicate success messages and a confusing "Adding MCP." spinner after configuration already completed.
| "ami", | ||
| "droid", | ||
| "copilot", | ||
| "mcp", |
There was a problem hiding this comment.
MCP appears in interactive legacy agent selection list
Medium Severity
Adding "mcp" to AGENTS means it now appears in availableAgents used by the interactive agent selection prompt (the "legacy" flow in add.ts). If a user chooses "Legacy" connection mode and then selects "MCP" from the agent list, promptMcpInstall() is never called — the code instead tries a standard package installation flow, which is incorrect for MCP.
There was a problem hiding this comment.
3 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/cli/src/commands/add.ts">
<violation number="1" location="packages/cli/src/commands/add.ts:129">
P1: Adding 'mcp' via command-line argument triggers a false 'already installed' prompt because the code updates `projectInfo.installedAgents` with 'mcp' before checking `if (installedAgents.length > 0)`. This causes the prompt to trigger even on fresh installation. If the user selects 'Replace', the just-installed MCP agent gets immediately uninstalled.</violation>
<violation number="2" location="packages/cli/src/commands/add.ts:129">
P1: Missing early exit after MCP installation. The success path within this `if (validAgent === "mcp")` block falls through to the generic agent installation flow below, which will attempt standard package installation for "mcp" and display duplicate success messages. The failure path correctly calls `process.exit(1)`, so the success path should similarly exit.</violation>
</file>
<file name="packages/cli/src/utils/templates.ts">
<violation number="1" location="packages/cli/src/utils/templates.ts:11">
P2: Adding `"mcp"` to the `AGENTS` array means it will appear in the interactive legacy agent selection prompt. If a user selects "MCP" through the interactive legacy flow, the code follows the standard package installation path instead of calling `promptMcpInstall()`. Consider filtering `"mcp"` out of the interactive agent choices (similar to how it's filtered from `PROVIDERS`), or adding MCP-specific handling in the interactive legacy flow.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| ); | ||
| logger.log("Restart your agents to activate."); | ||
| logger.break(); | ||
| projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"]; |
There was a problem hiding this comment.
P1: Adding 'mcp' via command-line argument triggers a false 'already installed' prompt because the code updates projectInfo.installedAgents with 'mcp' before checking if (installedAgents.length > 0). This causes the prompt to trigger even on fresh installation. If the user selects 'Replace', the just-installed MCP agent gets immediately uninstalled.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/src/commands/add.ts, line 129:
<comment>Adding 'mcp' via command-line argument triggers a false 'already installed' prompt because the code updates `projectInfo.installedAgents` with 'mcp' before checking `if (installedAgents.length > 0)`. This causes the prompt to trigger even on fresh installation. If the user selects 'Replace', the just-installed MCP agent gets immediately uninstalled.</comment>
<file context>
@@ -111,6 +110,25 @@ export const add = new Command()
+ );
+ logger.log("Restart your agents to activate.");
+ logger.break();
+ projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"];
+ }
+
</file context>
| ); | ||
| logger.log("Restart your agents to activate."); | ||
| logger.break(); | ||
| projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"]; |
There was a problem hiding this comment.
P1: Missing early exit after MCP installation. The success path within this if (validAgent === "mcp") block falls through to the generic agent installation flow below, which will attempt standard package installation for "mcp" and display duplicate success messages. The failure path correctly calls process.exit(1), so the success path should similarly exit.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/src/commands/add.ts, line 129:
<comment>Missing early exit after MCP installation. The success path within this `if (validAgent === "mcp")` block falls through to the generic agent installation flow below, which will attempt standard package installation for "mcp" and display duplicate success messages. The failure path correctly calls `process.exit(1)`, so the success path should similarly exit.</comment>
<file context>
@@ -111,6 +110,25 @@ export const add = new Command()
+ );
+ logger.log("Restart your agents to activate.");
+ logger.break();
+ projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"];
+ }
+
</file context>
| projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"]; | |
| projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"]; | |
| process.exit(0); |
| "ami", | ||
| "droid", | ||
| "copilot", | ||
| "mcp", |
There was a problem hiding this comment.
P2: Adding "mcp" to the AGENTS array means it will appear in the interactive legacy agent selection prompt. If a user selects "MCP" through the interactive legacy flow, the code follows the standard package installation path instead of calling promptMcpInstall(). Consider filtering "mcp" out of the interactive agent choices (similar to how it's filtered from PROVIDERS), or adding MCP-specific handling in the interactive legacy flow.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/src/utils/templates.ts, line 11:
<comment>Adding `"mcp"` to the `AGENTS` array means it will appear in the interactive legacy agent selection prompt. If a user selects "MCP" through the interactive legacy flow, the code follows the standard package installation path instead of calling `promptMcpInstall()`. Consider filtering `"mcp"` out of the interactive agent choices (similar to how it's filtered from `PROVIDERS`), or adding MCP-specific handling in the interactive legacy flow.</comment>
<file context>
@@ -8,11 +8,12 @@ export const AGENTS = [
"ami",
"droid",
"copilot",
+ "mcp",
] as const;
</file context>



Summary
This PR fixes issue #240 where running
npx -y grab@latest add mcpfails with "Invalid agent: mcp".Changes
Testing
The fix allows users to run:
to install MCP server for React Grab.
Fixes #240
Note
Low Risk
Low risk: scoped to CLI validation/template generation and adds a special-case MCP install path, with no changes to core runtime or security-sensitive logic.
Overview
Fixes
grab add mcpby treatingmcpas a first-class agent inAGENTS/AGENT_NAMESand validating it like other integrations.Updates
addto special-casemcpin non-interactive/arg-driven flows by runningpromptMcpInstall()(server configuration only) and marking it installed, while excludingmcpfromPROVIDERSand ensuring script/template helpers don’t emit agent-specific client imports formcp.Written by Cursor Bugbot for commit 5aec9ee. This will update automatically on new commits. Configure here.
Summary by cubic
Allow
mcpas agrab addargument and set up the MCP server in non-interactive mode, fixing the “Invalid agent: mcp” error. Templates and providers treat MCP as server-only (no client package).mcpinAGENTS/AGENT_NAMES; simplifyAgentIntegration.add.ts, runpromptMcpInstall()whenmcpis passed and record it as installed.mcpfromPROVIDERS(@react-grab/<agent>) and skip agent imports in all script/template helpers.npx -y grab@latest add mcpnow works. Fixes MCP Install fails with "Invalid agent" #240.Written for commit 5aec9ee. Summary will update on new commits.