ci
Installs npm dependencies cleanly from lockfile, ensuring reproducible builds in CI environments.
Instructions
Clean install dependencies from lockfile (for CI environments)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the package directory |
Implementation Reference
- src/index.ts:844-861 (handler)The tool handler for 'ci'. It receives a 'path' argument and runs 'npm ci' in the specified directory using the 'run' helper function.
server.tool( "ci", "Clean install dependencies from lockfile (for CI environments)", { path: z.string().describe("Absolute path to the package directory"), }, async ({ path }) => { const args = ["ci"]; try { const { stdout, stderr } = await run(args, path); return { content: [{ type: "text", text: stdout + stderr }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, - src/index.ts:844-861 (registration)The tool 'ci' is registered via server.tool() with the name 'ci', description, Zod schema, and handler.
server.tool( "ci", "Clean install dependencies from lockfile (for CI environments)", { path: z.string().describe("Absolute path to the package directory"), }, async ({ path }) => { const args = ["ci"]; try { const { stdout, stderr } = await run(args, path); return { content: [{ type: "text", text: stdout + stderr }] }; } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.stderr || e.message}` }], isError: true, }; } }, - src/index.ts:848-849 (schema)The input schema for the 'ci' tool — requires a 'path' (string) describing the absolute path to the package directory.
path: z.string().describe("Absolute path to the package directory"), }, - src/index.ts:26-38 (helper)The 'run' helper function that executes npm commands (including 'npm ci') via child_process.execFile with timeout, buffer limits, and optional .npmrc token config.
async function run( args: string[], cwd?: string, ): Promise<{ stdout: string; stderr: string }> { const fullArgs = [...args, ...npmrcArgs]; const opts: { cwd?: string; timeout: number; env: NodeJS.ProcessEnv; maxBuffer: number } = { timeout: 120_000, maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large outputs env: { ...process.env, NO_COLOR: "1" }, }; if (cwd) opts.cwd = cwd; return exec(NPM, fullArgs, opts); }