Skip to main content
Glama

run_command

Execute shell commands in your project directory to run npm install, git operations, tests, and other development tasks directly from Claude Desktop.

Instructions

Execute a shell command in the projects directory. Use for running npm install, git commands, tests, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesShell command to execute
cwdNoWorking directory (relative to projects directory or absolute)

Implementation Reference

  • The main handler function for the 'run_command' tool. It resolves the working directory, executes the shell command using execAsync, captures stdout and stderr, and returns the output in the MCP response format.
    async runCommand(command, cwd) { const resolvedCwd = cwd ? this.resolvePath(cwd) : PROJECTS_DIR; const { stdout, stderr } = await execAsync(command, { cwd: resolvedCwd }); let output = ''; if (stdout) output += `Output:\n${stdout}\n`; if (stderr) output += `Errors:\n${stderr}\n`; return { content: [ { type: 'text', text: output || 'Command executed successfully (no output)', }, ], }; }
  • Input schema definition for the 'run_command' tool, specifying 'command' as required string and 'cwd' as optional string.
    inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Shell command to execute', }, cwd: { type: 'string', description: 'Working directory (relative to projects directory or absolute)', }, }, required: ['command'], },
  • index.js:115-132 (registration)
    Registration of the 'run_command' tool in the tools array passed to server.setTools(), including name, description, and schema.
    { name: 'run_command', description: 'Execute a shell command in the projects directory. Use for running npm install, git commands, tests, etc.', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'Shell command to execute', }, cwd: { type: 'string', description: 'Working directory (relative to projects directory or absolute)', }, }, required: ['command'], }, },
  • index.js:175-176 (registration)
    Request handler switch case that routes 'run_command' calls to the runCommand method.
    case 'run_command': return await this.runCommand(args.command, args.cwd);

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/talentedmrweb/local-dev-bridge-mcp'

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