install_cli
Install the mockzilla CLI using one of three methods: download a prebuilt binary, compile from source with Go install, or use Go run without permanent installation.
Instructions
Install the mockzilla CLI for this user. Three methods — ASK the user which one they want before calling:
• download (recommended): fetch the prebuilt binary for this OS/arch from github.com/mockzilla/mockzilla releases (~38MB). Fast, no toolchain needed.
• go-install: run go install <module>@v<version> to compile from source. Needs Go on PATH.
• go-run: don't install at all — the bridge stores a go run <module>@v<version> invocation. First serve_locally compiles into Go's module cache; later runs are instant. Needs Go.
Files land in the bridge's own cache, never on system PATH; blow it away with rm -rf ~/.cache/mockzilla-mcp.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | download |
Implementation Reference
- lib/tools.js:36-62 (registration)Registration of the 'install_cli' tool in the LOCAL_TOOLS registry, including its description and inputSchema, mapping to the installCli handler.
install_cli: { description: "Install the mockzilla CLI for this user. Three methods — ASK the " + "user which one they want before calling:\n" + " • download (recommended): fetch the prebuilt binary for this " + "OS/arch from github.com/mockzilla/mockzilla releases (~38MB). " + "Fast, no toolchain needed.\n" + " • go-install: run `go install <module>@v<version>` to compile " + "from source. Needs Go on PATH.\n" + " • go-run: don't install at all — the bridge stores a `go run " + "<module>@v<version>` invocation. First serve_locally compiles " + "into Go's module cache; later runs are instant. Needs Go.\n" + "Files land in the bridge's own cache, never on system PATH; " + "blow it away with `rm -rf ~/.cache/mockzilla-mcp`.", inputSchema: { type: "object", properties: { method: { type: "string", enum: ["download", "go-install", "go-run"], default: "download", }, }, additionalProperties: false, }, handler: installCli, }, - lib/tools.js:50-60 (schema)Input schema for install_cli: accepts a 'method' string with enum values 'download', 'go-install', 'go-run' (default 'download').
inputSchema: { type: "object", properties: { method: { type: "string", enum: ["download", "go-install", "go-run"], default: "download", }, }, additionalProperties: false, }, - lib/install.js:58-66 (handler)The installCli handler function. Dispatches to installViaDownload, installViaGoInstall, or installViaGoRun based on the args.method parameter.
export async function installCli(args) { const method = args.method || "download"; await mkdir(CACHE_BIN_DIR, { recursive: true }); if (method === "download") return await installViaDownload(); if (method === "go-install") return await installViaGoInstall(); if (method === "go-run") return await installViaGoRun(); throw new Error(`Unknown install method: ${method}`); } - lib/install.js:160-191 (helper)installViaDownload: downloads the prebuilt mockzilla binary from GitHub releases for the current OS/arch.
async function installViaDownload() { const goos = nodePlatformToGoos(process.platform); const goarch = nodeArchToGoarch(process.arch); if (!goos || !goarch) { throw new Error( `No prebuilt binary for ${process.platform}/${process.arch}. ` + `Try method: "go-install" or "go-run".`, ); } const ext = goos === "windows" ? ".exe" : ""; const assetName = `mockzilla-v${MOCKZILLA_VERSION}-${goos}-${goarch}${ext}`; const url = `https://github.com/mockzilla/mockzilla/releases/download/v${MOCKZILLA_VERSION}/${assetName}`; const tmpPath = `${CACHE_BIN_PATH}.partial`; const res = await fetch(url); if (!res.ok) { throw new Error(`download failed: ${res.status} ${res.statusText} ${url}`); } await pipeline(res.body, createWriteStream(tmpPath)); await chmod(tmpPath, 0o755); await rename(tmpPath, CACHE_BIN_PATH); await writeConfig({ method: "download", version: MOCKZILLA_VERSION }); const { stdout } = await exec(`${shellEscape(CACHE_BIN_PATH)} --version`); return { method: "download", version: stdout.trim().replace(/^v/, ""), path: CACHE_BIN_PATH, asset: assetName, }; } - lib/install.js:193-246 (helper)installViaGoInstall and installViaGoRun: compile from source via 'go install' or configure a 'go run' invocation.
async function installViaGoInstall() { if (!(await hasGo())) { throw new Error( 'Go is not on PATH. Install Go first or use method: "download".', ); } const target = `${MOCKZILLA_MODULE}@v${MOCKZILLA_VERSION}`; const { stdout: gobinRaw } = await exec("go env GOBIN"); let gobin = gobinRaw.trim(); if (!gobin) { const { stdout: gopathRaw } = await exec("go env GOPATH"); gobin = path.join(gopathRaw.trim(), "bin"); } await exec(`go install ${target}`); // The package's main is `cmd/server`, so go install names the binary // `server`. Copy into our cache as `mockzilla` for resolveMockzilla. const compiledPath = path.join( gobin, process.platform === "win32" ? "server.exe" : "server", ); await exec(`cp ${shellEscape(compiledPath)} ${shellEscape(CACHE_BIN_PATH)}`); await chmod(CACHE_BIN_PATH, 0o755); await writeConfig({ method: "go-install", version: MOCKZILLA_VERSION }); const { stdout } = await exec(`${shellEscape(CACHE_BIN_PATH)} --version`); return { method: "go-install", version: stdout.trim().replace(/^v/, ""), path: CACHE_BIN_PATH, source_module: target, }; } async function installViaGoRun() { if (!(await hasGo())) { throw new Error( 'Go is not on PATH. Install Go first or use method: "download".', ); } const invocation = ["go", "run", `${MOCKZILLA_MODULE}@v${MOCKZILLA_VERSION}`]; await writeConfig({ method: "go-run", version: MOCKZILLA_VERSION, invocation, }); return { method: "go-run", version: MOCKZILLA_VERSION, invocation, notes: "Nothing was downloaded. The first serve_locally call will compile " + "via Go's module cache (slow first time, instant after).", }; }