Skip to main content
Glama

run_command

Execute allowed shell commands like clasp, npm, git, and dir to manage scripts, dependencies, version control, and directory operations within the Revenue Engine MCP server environment.

Instructions

Execute allowed shell commands (clasp, npm, git, dir). For clasp commands, run from apps-script folder.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesCommand to run (must be in allowed list)
workingDirectoryNoDirectory to run command in (optional, defaults to revenue-engine-mcp)

Implementation Reference

  • Handler for run_command tool: validates command and directory, executes using child_process.execAsync, returns stdout/stderr.
    case "run_command": { const { command, workingDirectory } = args; if (!isCommandAllowed(command)) { throw new Error(`Command not allowed: ${command}. Allowed commands: ${Object.keys(ALLOWED_COMMANDS).join(', ')}`); } const cwd = workingDirectory || 'C:\\Users\\Node1\\revenue-engine-mcp'; if (!isPathAllowed(cwd)) { throw new Error(`Working directory not allowed: ${cwd}`); } debugLog(`Running command: ${command} in ${cwd}`); const { stdout, stderr } = await execAsync(command, { cwd }); result = { success: true, command: command, workingDirectory: cwd, stdout: stdout, stderr: stderr }; break; }
  • index.js:595-612 (registration)
    Registration of run_command tool in ListTools response, including name, description, and input schema.
    { name: "run_command", description: "Execute allowed shell commands (clasp, npm, git, dir). For clasp commands, run from apps-script folder.", inputSchema: { type: "object", properties: { command: { type: "string", description: "Command to run (must be in allowed list)" }, workingDirectory: { type: "string", description: "Directory to run command in (optional, defaults to revenue-engine-mcp)" } }, required: ["command"] } }
  • Helper function to validate if a command is in the allowed list.
    function isCommandAllowed(command) { const cmd = command.trim(); return Object.keys(ALLOWED_COMMANDS).some(allowed => cmd.startsWith(allowed) ); }
  • Configuration object listing all allowed commands for run_command.
    const ALLOWED_COMMANDS = { 'clasp push': 'Sync local files to Google Apps Script', 'clasp pull': 'Sync Google Apps Script to local files', 'clasp deploy': 'Deploy Apps Script as web app', 'clasp status': 'Check sync status', 'clasp list': 'List Apps Script projects', 'npm install': 'Install node packages', 'git status': 'Check git status', 'git add': 'Stage changes', 'git commit': 'Commit changes', 'git init': 'Initialize git repository', 'git remote': 'Manage remote repositories', 'git push': 'Push to remote', 'git branch': 'Manage branches', 'mkdir': 'Create directory', 'md': 'Create directory (Windows)', 'dir': 'List directory contents', 'ls': 'List directory contents', 'del': 'Delete files (Windows)', 'rm': 'Remove files (Unix)', };
  • Helper function to check if working directory is allowed.
    function isPathAllowed(filePath) { const normalized = filePath.replace(/\//g, '\\'); return ALLOWED_PATHS.some(allowedPath => normalized.startsWith(allowedPath) ); }

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/PromptishOperations/mcpSpec'

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