Skip to main content
Glama

execute_command

Run shell commands on your system to automate tasks, manage files, and control PC operations through direct command execution.

Instructions

Execute shell commands on the system. SECURITY WARNING: This tool provides direct system access. Only use with trusted commands. Commands run with the same permissions as the MCP server process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe shell command to execute
workingDirectoryNoThe working directory for command execution (optional)

Implementation Reference

  • Handler for the 'execute_command' tool. Executes the shell command using the promisified 'exec' function from Node.js child_process module, with optional working directory. Returns stdout, stderr, and success status in JSON format.
    case "execute_command": { const command = args.command as string; const workingDirectory = args.workingDirectory as string | undefined; const options = workingDirectory ? { cwd: workingDirectory } : {}; const { stdout, stderr } = await execAsync(command, options); return { content: [ { type: "text", text: JSON.stringify( { stdout: stdout, stderr: stderr, success: true, }, null, 2 ), }, ], }; }
  • Input schema definition for the 'execute_command' tool, specifying a required 'command' string parameter and an optional 'workingDirectory' string.
    inputSchema: { type: "object", properties: { command: { type: "string", description: "The shell command to execute", }, workingDirectory: { type: "string", description: "The working directory for command execution (optional)", }, }, required: ["command"], },
  • src/index.ts:172-189 (registration)
    Registration of the 'execute_command' tool in the TOOLS array, which is returned by the ListTools handler. Includes name, description, and input schema.
    { name: "execute_command", description: "Execute shell commands on the system. SECURITY WARNING: This tool provides direct system access. Only use with trusted commands. Commands run with the same permissions as the MCP server process.", inputSchema: { type: "object", properties: { command: { type: "string", description: "The shell command to execute", }, workingDirectory: { type: "string", description: "The working directory for command execution (optional)", }, }, required: ["command"], }, },

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/koopatroopa787/first_mcp'

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