From 8013a92148ea5f6721a4589e318518ad3170456f Mon Sep 17 00:00:00 2001 From: dadachi Date: Sun, 24 May 2026 17:40:30 +0900 Subject: [PATCH] fix(plugin): pin generator MCP server to @latest (cwd-shadow resolution bug) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bundled generator MCP server failed to start with `sh: nativeapptemplate-agent-mcp: command not found` (confirmed in Claude's mcp-logs). MCP servers spawn with cwd = the project root; when that root is the `nativeapptemplate-agent` package's own repo, `npx -p nativeapptemplate-agent` resolves the *local* package and the bin isn't on the path it expects. Pinning `nativeapptemplate-agent@latest` forces registry resolution regardless of cwd — verified with a live MCP initialize handshake from inside the repo. README updated to document why both `-p` and `@latest` are required. Note: the `mobile-mcp` "✘ failed" seen alongside is unrelated — it's the user's identical global mobile-mcp config (a standalone third-party package, no cwd shadowing), whose connection closed during first-run npx download; it stays alive when run standalone. Co-Authored-By: Claude Opus 4.7 (1M context) --- plugin/.mcp.json | 2 +- plugin/README.md | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugin/.mcp.json b/plugin/.mcp.json index 1ca2db7..9aa431b 100644 --- a/plugin/.mcp.json +++ b/plugin/.mcp.json @@ -2,7 +2,7 @@ "mcpServers": { "nativeapptemplate-agent": { "command": "npx", - "args": ["-y", "-p", "nativeapptemplate-agent", "nativeapptemplate-agent-mcp"] + "args": ["-y", "-p", "nativeapptemplate-agent@latest", "nativeapptemplate-agent-mcp"] }, "mobile-mcp": { "command": "npx", diff --git a/plugin/README.md b/plugin/README.md index 77c6e87..e44aa1b 100644 --- a/plugin/README.md +++ b/plugin/README.md @@ -32,10 +32,16 @@ plugin/ `NATIVEAPPTEMPLATE_VISUAL=1` generate run — see the skill for details). - **Bundled MCP servers** (`/mcp` to check): the generator server (`nativeapptemplate-agent`, wired as - `npx -y -p nativeapptemplate-agent nativeapptemplate-agent-mcp` — the MCP entry - point is a **bin** of the package, not its own package, hence `-p`) and + `npx -y -p nativeapptemplate-agent@latest nativeapptemplate-agent-mcp`) and `mobile-mcp` (`@mobilenext/mobile-mcp`) for device automation. + Two non-obvious bits in that generator command: the MCP entry point is a **bin** + of the `nativeapptemplate-agent` package, not its own package, so `-p` is + required; and the **`@latest`** is load-bearing — without a version spec, `npx` + resolves the *local* package when the server is spawned from inside the agent's + own repo (cwd shadowing) and fails with `command not found`. `@latest` forces + registry resolution regardless of cwd. + ## Requirements - Node.js 22+ and an `ANTHROPIC_API_KEY` with access to `claude-opus-4-7`.