install_dependencies
Install project dependencies using npm, yarn, or pnpm to prepare development environments for building and testing applications.
Instructions
Install project dependencies
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| manager | No | Package manager to use | npm |
| directory | No | Directory to install dependencies in (default: current directory) |
Implementation Reference
- src/index.ts:249-272 (handler)Implements the core logic for installing dependencies using the specified package manager (npm, yarn, or pnpm) via execSync in the target directory, with timeout and error handling.private async installDependencies(args: any) { const manager = args?.manager || 'npm'; const directory = args?.directory || process.cwd(); const command = `${manager} install`; try { const output = execSync(command, { cwd: directory, encoding: 'utf8', timeout: 600000 // 10 minutes }); return { content: [ { type: 'text', text: `Dependencies installed successfully!\nCommand: ${command}\nDirectory: ${directory}\nOutput:\n${output}` } ] }; } catch (error: any) { throw new Error(`Dependency installation failed: ${error.message}\nStderr: ${error.stderr || 'N/A'}`); } }
- src/index.ts:94-112 (registration)Registers the 'install_dependencies' tool in the ListToolsRequestHandler response, defining its name, description, and input schema.{ name: 'install_dependencies', description: 'Install project dependencies', inputSchema: { type: 'object', properties: { manager: { type: 'string', description: 'Package manager to use', enum: ['npm', 'yarn', 'pnpm'], default: 'npm' }, directory: { type: 'string', description: 'Directory to install dependencies in (default: current directory)' } } } },
- src/index.ts:97-110 (schema)Defines the input schema for the tool, specifying properties for package manager and directory with types, descriptions, enum, and defaults.inputSchema: { type: 'object', properties: { manager: { type: 'string', description: 'Package manager to use', enum: ['npm', 'yarn', 'pnpm'], default: 'npm' }, directory: { type: 'string', description: 'Directory to install dependencies in (default: current directory)' } }
- src/index.ts:145-146 (handler)Dispatcher switch case that routes CallToolRequest for 'install_dependencies' to the handler function.case 'install_dependencies': return await this.installDependencies(args);