install_dependencies
Install project dependencies using npm, yarn, or pnpm for MCP server development workflows. Specify the package manager and directory to streamline dependency management and ensure consistent builds.
Instructions
Install project dependencies
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Directory to install dependencies in (default: current directory) | |
| manager | No | Package manager to use | npm |
Implementation Reference
- src/index.ts:249-272 (handler)The handler function that installs project dependencies using the specified package manager (npm, yarn, or pnpm) via execSync in the given directory.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:97-111 (schema)Input schema defining parameters for the install_dependencies tool: package manager (enum) and directory.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:94-112 (registration)Registration of the install_dependencies tool in the ListTools handler response, including name, description, and 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:145-146 (registration)Dispatcher case in the CallToolRequestSchema handler that routes to the installDependencies method.case 'install_dependencies': return await this.installDependencies(args);