Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

execute_command

Execute terminal commands with timeout control, allowing background continuation for long-running operations.

Instructions

Execute a terminal command with timeout. Command will continue running in background if it doesn't complete within timeout.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
timeout_msNo

Implementation Reference

  • The core handler function for the 'execute_command' tool. Parses input arguments, validates the command, executes via terminalManager, and formats the response with PID and initial output.
    export async function executeCommand(args: unknown) { const parsed = ExecuteCommandArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for execute_command: ${parsed.error}`); } if (!commandManager.validateCommand(parsed.data.command)) { throw new Error(`Command not allowed: ${parsed.data.command}`); } const result = await terminalManager.executeCommand( parsed.data.command, parsed.data.timeout_ms ); return { content: [{ type: "text", text: `Command started with PID ${result.pid}\nInitial output:\n${result.output}${ result.isBlocked ? '\nCommand is still running. Use read_output to get more output.' : '' }` }], }; }
  • Zod schema for execute_command input: 'command' (string, required), 'timeout_ms' (number, optional).
    export const ExecuteCommandArgsSchema = z.object({ command: z.string(), timeout_ms: z.number().optional(), });
  • src/server.ts:60-65 (registration)
    Tool registration in the MCP server's listTools response, defining name, description, and input schema.
    { name: "execute_command", description: "Execute a terminal command with timeout. Command will continue running in background if it doesn't complete within timeout.", inputSchema: zodToJsonSchema(ExecuteCommandArgsSchema), },
  • src/server.ts:216-219 (registration)
    Dispatch logic in callTool handler that routes 'execute_command' calls to the handler function after parsing arguments.
    case "execute_command": { const parsed = ExecuteCommandArgsSchema.parse(args); return executeCommand(parsed); }

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/StrawHatAI/claude-dev-tools'

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