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 your local environment.

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 core handler function that executes the provided shell command in the resolved working directory (defaulting to PROJECTS_DIR), captures stdout and stderr, and returns formatted text output.
    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 for the 'run_command' tool, requiring a 'command' string and optionally accepting 'cwd'.
    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 ListToolsRequestSchema response, including name, description, and input 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'], }, },
  • Dispatch handler within the CallToolRequestSchema switch statement 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