-
Notifications
You must be signed in to change notification settings - Fork 306
fix: support 'mcp' as command-line argument #241
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -82,8 +82,7 @@ export const add = new Command() | |||||||
|
|
||||||||
| if (availableAgents.length === 0 && isNonInteractive && !agentArg) { | ||||||||
| logger.break(); | ||||||||
| logger.success("All legacy agents are already installed."); | ||||||||
| logger.log("Run without -y to add MCP."); | ||||||||
| logger.success("All agents are already installed."); | ||||||||
| logger.break(); | ||||||||
| process.exit(0); | ||||||||
| } | ||||||||
|
|
@@ -111,6 +110,25 @@ export const add = new Command() | |||||||
|
|
||||||||
| agentIntegration = validAgent; | ||||||||
|
|
||||||||
| // Handle MCP specially - it needs server configuration, not package installation | ||||||||
| if (validAgent === "mcp") { | ||||||||
| const mcpSpinner = spinner("Installing MCP server.").start(); | ||||||||
| const didInstall = await promptMcpInstall(); | ||||||||
| if (!didInstall) { | ||||||||
| mcpSpinner.fail(); | ||||||||
| logger.break(); | ||||||||
| process.exit(1); | ||||||||
| } | ||||||||
| mcpSpinner.succeed(); | ||||||||
| logger.break(); | ||||||||
| logger.log( | ||||||||
| `${highlighter.success("Success!")} MCP server has been configured.`, | ||||||||
| ); | ||||||||
| logger.log("Restart your agents to activate."); | ||||||||
| logger.break(); | ||||||||
| projectInfo.installedAgents = [...projectInfo.installedAgents, "mcp"]; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Missing early exit after MCP installation. The success path within this Prompt for AI agents
Suggested change
|
||||||||
| } | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing early exit after MCP installation causes unintended behaviorHigh 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 |
||||||||
|
|
||||||||
| if (projectInfo.installedAgents.length > 0 && !isNonInteractive) { | ||||||||
| const installedNames = formatInstalledAgentNames( | ||||||||
| projectInfo.installedAgents, | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,11 +8,12 @@ export const AGENTS = [ | |
| "ami", | ||
| "droid", | ||
| "copilot", | ||
| "mcp", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MCP appears in interactive legacy agent selection listMedium Severity Adding
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Adding Prompt for AI agents |
||
| ] as const; | ||
|
|
||
| export type Agent = (typeof AGENTS)[number]; | ||
|
|
||
| export type AgentIntegration = Agent | "mcp" | "none"; | ||
| export type AgentIntegration = Agent | "none"; | ||
|
|
||
| export const AGENT_NAMES: Record<Agent, string> = { | ||
| "claude-code": "Claude Code", | ||
|
|
@@ -24,17 +25,17 @@ export const AGENT_NAMES: Record<Agent, string> = { | |
| ami: "Ami", | ||
| droid: "Droid", | ||
| copilot: "Copilot", | ||
| mcp: "MCP", | ||
| }; | ||
|
|
||
| export const getAgentDisplayName = (agent: string): string => { | ||
| if (agent === "mcp") return "MCP"; | ||
| if (agent in AGENT_NAMES) { | ||
| return AGENT_NAMES[agent as Agent]; | ||
| } | ||
| return agent; | ||
| }; | ||
|
|
||
| export const PROVIDERS = AGENTS.filter((agent) => agent !== "ami").map( | ||
| export const PROVIDERS = AGENTS.filter((agent) => agent !== "ami" && agent !== "mcp").map( | ||
| (agent) => `@react-grab/${agent}` as const, | ||
| ); | ||
|
|
||
|
|
@@ -49,7 +50,7 @@ export const NEXT_APP_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" & | |
| export const NEXT_APP_ROUTER_SCRIPT_WITH_AGENT = ( | ||
| agent: AgentIntegration, | ||
| ): string => { | ||
| if (agent === "none") return NEXT_APP_ROUTER_SCRIPT; | ||
| if (agent === "none" || agent === "mcp") return NEXT_APP_ROUTER_SCRIPT; | ||
|
|
||
| return `{process.env.NODE_ENV === "development" && ( | ||
| <Script | ||
|
|
@@ -77,7 +78,7 @@ export const NEXT_PAGES_ROUTER_SCRIPT = `{process.env.NODE_ENV === "development" | |
| export const NEXT_PAGES_ROUTER_SCRIPT_WITH_AGENT = ( | ||
| agent: AgentIntegration, | ||
| ): string => { | ||
| if (agent === "none") return NEXT_PAGES_ROUTER_SCRIPT; | ||
| if (agent === "none" || agent === "mcp") return NEXT_PAGES_ROUTER_SCRIPT; | ||
|
|
||
| return `{process.env.NODE_ENV === "development" && ( | ||
| <Script | ||
|
|
@@ -101,7 +102,7 @@ export const VITE_SCRIPT = `<script type="module"> | |
| </script>`; | ||
|
|
||
| export const VITE_SCRIPT_WITH_AGENT = (agent: AgentIntegration): string => { | ||
| if (agent === "none") return VITE_SCRIPT; | ||
| if (agent === "none" || agent === "mcp") return VITE_SCRIPT; | ||
|
|
||
| return `<script type="module"> | ||
| if (import.meta.env.DEV) { | ||
|
|
@@ -116,7 +117,7 @@ export const WEBPACK_IMPORT = `if (process.env.NODE_ENV === "development") { | |
| }`; | ||
|
|
||
| export const WEBPACK_IMPORT_WITH_AGENT = (agent: AgentIntegration): string => { | ||
| if (agent === "none") return WEBPACK_IMPORT; | ||
| if (agent === "none" || agent === "mcp") return WEBPACK_IMPORT; | ||
|
|
||
| return `if (process.env.NODE_ENV === "development") { | ||
| import("react-grab"); | ||
|
|
@@ -131,7 +132,7 @@ export const TANSTACK_EFFECT = `useEffect(() => { | |
| }, []);`; | ||
|
|
||
| export const TANSTACK_EFFECT_WITH_AGENT = (agent: AgentIntegration): string => { | ||
| if (agent === "none") return TANSTACK_EFFECT; | ||
| if (agent === "none" || agent === "mcp") return TANSTACK_EFFECT; | ||
|
|
||
| return `useEffect(() => { | ||
| if (import.meta.env.DEV) { | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Adding 'mcp' via command-line argument triggers a false 'already installed' prompt because the code updates
projectInfo.installedAgentswith 'mcp' before checkingif (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