Skip to main content
Glama
AbdurRaahimm

MCP Terminal & Git Server

by AbdurRaahimm

execute_command

Execute terminal commands in specific directories to automate development tasks, manage files, and run scripts directly from the MCP Terminal & Git Server interface.

Instructions

Execute a terminal command in a specified directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe command to execute (e.g., 'npm install', 'ls -la')
cwdNoWorking directory for the command (defaults to current directory)

Implementation Reference

  • Handler for the execute_command tool: destructures command and optional cwd from arguments, resolves the working directory, executes the command using execa with shell enabled, and returns stdout/stderr in a text content response.
    case "execute_command": {
      const { command, cwd } = args as { command: string; cwd?: string };
      const workingDir = cwd ? resolvePath(cwd) : process.cwd();
      
      // Execute command
      const { stdout, stderr } = await execa(command, {
        shell: true,
        cwd: workingDir,
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Command executed successfully:\n\nOutput:\n${stdout}\n${stderr ? `\nErrors/Warnings:\n${stderr}` : ""}`,
          },
        ],
      };
    }
  • Input schema for execute_command tool defining properties for 'command' (required string) and optional 'cwd' (string).
    inputSchema: {
      type: "object",
      properties: {
        command: {
          type: "string",
          description: "The command to execute (e.g., 'npm install', 'ls -la')",
        },
        cwd: {
          type: "string",
          description: "Working directory for the command (defaults to current directory)",
        },
      },
      required: ["command"],
    },
  • src/index.ts:77-94 (registration)
    Registration of the execute_command tool in the ListTools response, specifying name, description, and input schema.
    {
      name: "execute_command",
      description: "Execute a terminal command in a specified directory",
      inputSchema: {
        type: "object",
        properties: {
          command: {
            type: "string",
            description: "The command to execute (e.g., 'npm install', 'ls -la')",
          },
          cwd: {
            type: "string",
            description: "Working directory for the command (defaults to current directory)",
          },
        },
        required: ["command"],
      },
    },
  • Helper function resolvePath used in the handler to resolve the cwd parameter, supporting ~ expansion for home directory.
    function resolvePath(inputPath: string): string {
      if (inputPath.startsWith("~")) {
        return path.join(os.homedir(), inputPath.slice(1));
      }
      return path.resolve(inputPath);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action but doesn't mention risks (e.g., destructive commands, security implications), permissions required, or output handling (e.g., stdout/stderr capture). For a command execution tool with zero annotation coverage, this is a significant gap in safety and operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('Execute a terminal command') and adds necessary context ('in a specified directory'). There is zero waste, making it easy for an agent to parse quickly without extraneous details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of command execution (potential for destructive actions, security risks) and lack of annotations or output schema, the description is incomplete. It doesn't address behavioral traits like error handling, command safety, or output format, leaving critical gaps for safe and effective tool use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters: 'command' (e.g., 'npm install') and 'cwd' (working directory with default). The description adds minimal value beyond the schema, only implying directory context without detailing parameter interactions or constraints. Baseline 3 is appropriate as the schema handles most documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('execute') and resource ('terminal command'), specifying it occurs 'in a specified directory'. It distinguishes from siblings like 'check_directory' or 'git_clone' by focusing on command execution rather than directory inspection or Git operations. However, it doesn't explicitly differentiate from installation tools, leaving some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'install_next_project' or 'open_in_vscode'. It lacks context about prerequisites, such as needing a terminal environment, or exclusions, like avoiding dangerous commands. Without such guidance, the agent must infer usage from tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/AbdurRaahimm/mcp-git-terminal-server'

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