Skip to main content
Glama

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
NameRequiredDescriptionDefault
managerNoPackage manager to usenpm
directoryNoDirectory to install dependencies in (default: current directory)

Implementation Reference

  • 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)' } } } },
  • 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)' } }
  • Dispatcher switch case that routes CallToolRequest for 'install_dependencies' to the handler function.
    case 'install_dependencies': return await this.installDependencies(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TeodorTrotea/mcptest'

If you have feedback or need assistance with the MCP directory API, please join our Discord server