check_cli
Check whether the mockzilla CLI is available on the system or in cache, and present installation options if not found.
Instructions
Check whether the mockzilla CLI is available — either on the system PATH, in the bridge's own cache (~/.cache/mockzilla-mcp/), or via a go run invocation. Call FIRST when the user wants to try mockzilla locally. If nothing resolves, the response carries install_options; suggest install_cli to the user and ask them which method (download / go-install / go-run) they prefer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- lib/install.js:33-56 (handler)The handler function for the 'check_cli' tool. Checks if mockzilla CLI is available (system PATH, bridge cache, or go-run invocation) and returns {installed: true/false} with appropriate details or install options.
export async function checkCli() { const resolved = await resolveMockzilla(); if (resolved) { return { installed: true, source: resolved.source, version: resolved.version, ...(resolved.type === "binary" ? { path: resolved.path } : { invocation: resolved.invocation }), }; } const goAvailable = await hasGo(); return { installed: false, install_options: buildInstallOptions(goAvailable), notes: "No mockzilla CLI on PATH or in the bridge cache. Suggest " + "`install_cli`; ask the user whether they want to download the " + "prebuilt binary, build from source via `go install`, or skip " + "install entirely and use `go run`.", }; } - lib/tools.js:20-34 (registration)Registration of the 'check_cli' tool in the LOCAL_TOOLS registry with description, empty inputSchema, and handler pointing to checkCli function.
check_cli: { description: "Check whether the mockzilla CLI is available — either on the " + "system PATH, in the bridge's own cache (~/.cache/mockzilla-mcp/), " + "or via a `go run` invocation. Call FIRST when the user wants to " + "try mockzilla locally. If nothing resolves, the response carries " + "`install_options`; suggest `install_cli` to the user and ask them " + "which method (download / go-install / go-run) they prefer.", inputSchema: { type: "object", properties: {}, additionalProperties: false, }, handler: checkCli, }, - lib/tools.js:28-32 (schema)Input schema for 'check_cli' — an empty object with no properties since the tool takes no arguments.
inputSchema: { type: "object", properties: {}, additionalProperties: false, }, - lib/install.js:73-118 (helper)Helper function called by checkCli that resolves mockzilla availability (system PATH → bridge cache → go-run invocation).
export async function resolveMockzilla() { try { const { stdout } = await exec("mockzilla --version"); return { type: "binary", path: "mockzilla", version: stdout.trim().replace(/^v/, ""), source: "system", }; } catch { /* not on PATH */ } const config = await readConfig(); if (config && (config.method === "download" || config.method === "go-install")) { try { const { stdout } = await exec( `${shellEscape(CACHE_BIN_PATH)} --version`, ); return { type: "binary", path: CACHE_BIN_PATH, version: stdout.trim().replace(/^v/, ""), source: "cache", }; } catch { /* cache binary missing or broken */ } } if ( config && config.method === "go-run" && Array.isArray(config.invocation) && (await hasGo()) ) { return { type: "go-run", invocation: config.invocation, version: config.version, source: "go-run", }; } return null; } - lib/install.js:120-158 (helper)Helper function that builds the install_options array returned by checkCli when CLI is not installed.
function buildInstallOptions(goAvailable) { const options = [ { method: "download", recommended: true, requires: ["network access to github.com"], summary: `Pull the prebuilt mockzilla v${MOCKZILLA_VERSION} binary for ` + `${process.platform}/${process.arch} into the bridge cache.`, }, ]; if (goAvailable) { options.push({ method: "go-install", requires: ["go on PATH"], summary: `Compile mockzilla v${MOCKZILLA_VERSION} from source via ` + `\`go install\`. Audit-friendly; needs the Go toolchain.`, }); options.push({ method: "go-run", requires: ["go on PATH"], summary: `Skip install: future serve_locally calls will use ` + `\`go run ${MOCKZILLA_MODULE}@v${MOCKZILLA_VERSION}\`. ` + `First run compiles into Go's module cache; later runs are instant.`, }); } else { for (const method of ["go-install", "go-run"]) { options.push({ method, requires: ["go on PATH"], available: false, summary: "Go is not on PATH; install Go first if you want this method.", }); } } return options; }