Skip to main content
Glama
SobieskiCodes

MCP-Claude Code Bridge

run_command

Execute shell commands within project directories to manage development tasks, automate processes, and interact with codebases directly from the Claude interface.

Instructions

Run a shell command in the project directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesCommand to execute
project_pathNoDirectory to run command in

Implementation Reference

  • The main runCommand handler function that executes shell commands using Node.js exec() with proper path resolution and output formatting
    async runCommand(command, projectPath = '') {
      return new Promise((resolve) => {
        const fullPath = projectPath ? path.join(this.workingDir, projectPath) : this.workingDir;
        
        exec(command, { cwd: fullPath }, (error, stdout, stderr) => {
          let output = '';
          if (stdout) output += `STDOUT:\n${stdout}\n\n`;
          if (stderr) output += `STDERR:\n${stderr}\n\n`;
          if (error) output += `Error: ${error.message}`;
          
          resolve({
            content: [
              {
                type: "text",
                text: output || 'Command executed with no output'
              }
            ]
          });
        });
      });
    }
  • Tool registration with name, description, and input schema defining the command and optional project_path parameters
      name: "run_command",
      description: "Run a shell command in the project directory",
      inputSchema: {
        type: "object",
        properties: {
          command: {
            type: "string",
            description: "Command to execute"
          },
          project_path: {
            type: "string",
            description: "Directory to run command in"
          }
        },
        required: ["command"]
      }
    }
  • server.js:147-148 (registration)
    Switch case that routes 'run_command' tool calls to the runCommand handler method
    case 'run_command':
      return await this.runCommand(args.command, args.project_path);

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/SobieskiCodes/claude-desktop-mcp-to-claude-agent'

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