fix(desktop): resolve actual desktop-mcp bin path for setup snippet#353
fix(desktop): resolve actual desktop-mcp bin path for setup snippet#353
Conversation
desktop-mcp is a workspace-private TS bin with no global install, so `claude mcp add superset-browser -s local -- desktop-mcp` registered a command the shell can't resolve (Status: failed). browserAutomation.getMcpStatus now resolves the bin at runtime (`bun <repo>/packages/desktop-mcp/src/bin.ts` in dev; falls back to the bare name in packaged builds) and returns it as `serverCommand`. The snippet generator builds a Claude CLI / TOML block from those exact argv tokens so copy-pasting the instructions actually starts the server.
📝 Walkthroughウォークスルーブラウザ自動化ルーターにMCPサーバーコマンド解決ロジックを追加し、開発環境ではbunから実行、本番環境ではdesktop-mcpコマンドを使用するよう条件分岐を実装。SessionConnectModalを通じてサーバーコマンド情報をスニペット生成に渡し、CLIスニペットとClaudeコード設定に動的に反映させました。 変更内容
推定レビュー工数🎯 3 (Moderate) | ⏱️ ~20 分 詩
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/BrowserPane/components/SessionConnectModal/SessionConnectModal.tsx`:
- Around line 147-154: The copy/snippet flow ignores mcpStatus/resolver
availability and may produce a failing "desktop-mcp" snippet; update
handleCopySnippet (and the other similar handlers that call
getSnippetForSession) to check mcpStatus?.serverCommand?.available (or
serverCommand.available) before calling getSnippetForSession and prevent
copying/show a clear error / disable the copy action when available is false or
mcpStatus is not loaded; ensure you reference serverCommand and
getSnippetForSession so the guard is applied everywhere this snippet is
generated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6622ea87-7fe2-40db-a537-23bbeddba73b
📒 Files selected for processing (3)
apps/desktop/src/lib/trpc/routers/browser-automation/index.tsapps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/BrowserPane/components/SessionConnectModal/SessionConnectModal.tsxapps/desktop/src/renderer/stores/browser-automation.ts
| const serverCommand = mcpStatus?.serverCommand; | ||
|
|
||
| const handleCopySnippet = async () => { | ||
| if (!session) return; | ||
| try { | ||
| await navigator.clipboard.writeText(getSnippetForSession(session)); | ||
| await navigator.clipboard.writeText( | ||
| getSnippetForSession(session, serverCommand), | ||
| ); |
There was a problem hiding this comment.
serverCommand.available を尊重して、失敗するスニペットのコピーを防いでください。
mcpStatus が未ロード、または resolver が available: false を返した場合でも、現在は getSnippetForSession のフォールバックで bare desktop-mcp が表示/コピーされます。これは今回直した /mcp failed の経路を再発させます。
修正案
- const serverCommand = mcpStatus?.serverCommand;
+ const serverCommand = mcpStatus?.serverCommand ?? null;
const handleCopySnippet = async () => {
- if (!session) return;
+ if (!session) return;
+ if (!serverCommand?.available) {
+ toast.error("MCP server command is still unavailable");
+ return;
+ }
try {
await navigator.clipboard.writeText(
getSnippetForSession(session, serverCommand),
); <SetupPanel
session={session}
mcpConfigPath={
session.provider === "Codex"
? (mcpStatus?.codexConfigPath ?? null)
: (mcpStatus?.claudeConfigPath ?? null)
}
serverCommand={serverCommand}
onCopy={handleCopySnippet}
/> function SetupPanel({
session,
mcpConfigPath,
serverCommand,
onCopy,
}: {
session: AutomationSession;
mcpConfigPath: string | null;
- serverCommand?: ServerCommand;
+ serverCommand: ServerCommand | null;
onCopy: () => void;
}) {
- const snippet = getSnippetForSession(session, serverCommand);
+ const snippet = serverCommand?.available
+ ? getSnippetForSession(session, serverCommand)
+ : "MCP server command is not available in this build.";- <Button size="sm" variant="outline" onClick={onCopy}>
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={onCopy}
+ disabled={!serverCommand?.available}
+ >Also applies to: 252-253, 457-465, 517-520
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/BrowserPane/components/SessionConnectModal/SessionConnectModal.tsx`
around lines 147 - 154, The copy/snippet flow ignores mcpStatus/resolver
availability and may produce a failing "desktop-mcp" snippet; update
handleCopySnippet (and the other similar handlers that call
getSnippetForSession) to check mcpStatus?.serverCommand?.available (or
serverCommand.available) before calling getSnippetForSession and prevent
copying/show a clear error / disable the copy action when available is false or
mcpStatus is not loaded; ensure you reference serverCommand and
getSnippetForSession so the guard is applied everywhere this snippet is
generated.
|
実装方針を変更 (独立 MCP パッケージ + PID 自動マッチング)。新規 PR で再実装します。 |
Summary
PR #345 でセットアップ snippet に `desktop-mcp` という裸のコマンドを出していたが、これは monorepo 内部のプライベート TS bin (`packages/desktop-mcp/src/bin.ts`) でグローバル PATH に無く、`claude mcp add ... -- desktop-mcp` を実行すると Claude 側で `/mcp` が `failed` になっていた。
修正:
背景 — この PR の出し方について
元々 PR #345 のレビュー対応中に同じ修正を直接 main に push してしまい、レビューなしで入ってしまった (commit b925620)。その commit を revert した上でこの PR に切り出し直している。内容は revert 前と同じ。
Test plan
Summary by CodeRabbit
リリースノート
新機能
改善