link
Links a local package directory to global node_modules for development, optionally specifying the package name.
Instructions
Symlink a local package for development
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the package directory | |
| package | No | Package name to link (omit to link current dir globally) |
Implementation Reference
- src/index.ts:988-1000 (handler)Handler function for the 'link' tool. Runs 'npm link' (or 'npm link <package>') via child_process in the specified directory.
async ({ path, package: pkg }) => { const args = ["link"]; if (pkg) args.push(pkg); 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:981-1001 (handler)Registration and handler for the 'link' tool on the primary server. Defines schema (path required, package optional) and handler logic.
server.tool( "link", "Symlink a local package for development", { path: z.string().describe("Absolute path to the package directory"), package: z.string().optional().describe("Package name to link (omit to link current dir globally)"), }, async ({ path, package: pkg }) => { const args = ["link"]; if (pkg) args.push(pkg); 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:26-38 (helper)Helper function 'run' that executes npm commands via child_process.execFile, used by the link handler.
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); } - src/index.ts:1407-1410 (registration)Registration of the 'link' tool in the sandbox server (with noop handler, for Smithery Sandbox environment).
sandbox.tool("link", "Symlink a local package for development", { path: z.string().describe("Absolute path to the package directory"), package: z.string().optional().describe("Package name to link"), }, noop);