-
Notifications
You must be signed in to change notification settings - Fork 13
fix mcp install for codex #263
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
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -667,7 +667,9 @@ export async function handleInstall( | |||||||||||||||||
|
|
||||||||||||||||||
| // Client-side format conversion (if --as flag is specified) | ||||||||||||||||||
| // Skip conversion for snippets - they're raw content that doesn't need format conversion | ||||||||||||||||||
| if (options.as && format && format !== pkg.format && effectiveSubtype !== 'snippet') { | ||||||||||||||||||
| // Skip conversion for MCP server packages targeting an MCP editor — they use the dedicated MCP install path | ||||||||||||||||||
| const isMCPToEditor = isMCPServerPackage && MCP_EDITORS.includes(format as MCPEditor); | ||||||||||||||||||
|
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. Suggestion: MCP editor inference is incomplete: when reinstalling from lockfile, Severity Level: Critical 🚨- ❌ Lockfile reinstall targets wrong MCP config file.
- ❌ Codex/Cursor MCP servers may be missing after reinstall.
- ⚠️ PR's editor-specific MCP install behavior regresses.
Suggested change
Steps of Reproduction ✅1. Run lockfile reinstall path (`prpm install` with no package), which goes through
`createInstallCommand()` no-package branch at
`packages/cli/src/commands/install.ts:2071-2081` and calls `installFromLockfile({ as:
convertTo, ... })`.
2. `installFromLockfile()` calls `handleInstall()` at
`packages/cli/src/commands/install.ts:1976-1986` with `as: options.as || lockEntry.format`
but does not pass `editor`.
3. For an MCP package previously installed as Codex/Cursor, `handleInstall()` identifies
MCP path (`isMCPToEditor` logic at `install.ts:671-672`, MCP branch at
`install.ts:1006-1007`) but later resolves editor with fallback `const editor =
options.editor || 'claude'` at `install.ts:1029`.
4. MCP merge writes using Claude default path semantics
(`packages/cli/src/core/mcp.ts:338-367`), so config is written to `.mcp.json`/Claude
location instead of intended `.codex/config.toml` or `.cursor/mcp.json`.Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** packages/cli/src/commands/install.ts
**Line:** 671:671
**Comment:**
*Logic Error: MCP editor inference is incomplete: when reinstalling from lockfile, `as` can be `codex`/`cursor` without `editor` being set, so this path is detected as MCP-to-editor but later defaults to Claude and writes MCP config to the wrong file. Infer and persist `options.editor` from `format` when `format` is an MCP editor to keep installs targeting the expected editor config.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise. |
||||||||||||||||||
| if (options.as && format && format !== pkg.format && effectiveSubtype !== 'snippet' && !isMCPToEditor) { | ||||||||||||||||||
| console.log(` 🔄 Converting from ${pkg.format} to ${format}...`); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Find the main file to convert | ||||||||||||||||||
|
|
@@ -999,8 +1001,10 @@ export async function handleInstall( | |||||||||||||||||
| destPath = '.claude/'; | ||||||||||||||||||
| fileCount = installedFiles.length; | ||||||||||||||||||
| } | ||||||||||||||||||
| // Special handling for MCP server packages (install server configs to .mcp.json) | ||||||||||||||||||
| else if (effectiveFormat === 'mcp' && (effectiveSubtype === 'server' || effectiveSubtype === 'tool')) { | ||||||||||||||||||
| // Special handling for MCP server packages (install server configs to .mcp.json or editor config) | ||||||||||||||||||
| // Match when: native MCP format, OR source is MCP and --as targets an MCP editor (e.g., --as codex) | ||||||||||||||||||
| else if ((effectiveFormat === 'mcp' && (effectiveSubtype === 'server' || effectiveSubtype === 'tool')) || | ||||||||||||||||||
| (isMCPServerPackage && (pkg.subtype === 'server' || pkg.subtype === 'tool') && isMCPToEditor)) { | ||||||||||||||||||
| console.log(` 🔧 Installing MCP Server...`); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Find and parse the MCP server config file | ||||||||||||||||||
|
|
||||||||||||||||||
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.
Suggestion: This test can produce false positives because
.codex/config.tomlis not cleaned by the sharedbeforeEach, so a stale config from earlier MCP Codex tests can satisfy assertions even if this install path regresses. Explicitly remove.codexat the start of this test to guarantee isolation. [logic error]Severity Level: Major⚠️
Steps of Reproduction ✅
Prompt for AI Agent 🤖