Skip to main content
Glama

execute_command

Execute commands on a VPS to manage services, configure domains, set up SSL certificates, and deploy applications via SSH connections.

Instructions

Execute a command on the connected VPS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesCommand to execute

Implementation Reference

  • The main handler function for the MCP 'execute_command' tool. It validates the input arguments, checks if SSH is connected, executes the command using SSHService, and formats the response with stdout, stderr, and exit code.
    private async handleExecuteCommand(
      args: unknown
    ): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
      if (!this.sshService) {
        throw new Error('SSH connection not established. Please connect first.');
      }
    
      const { command } = z.object({ command: z.string() }).parse(args);
      const result = await this.sshService.executeCommand(command);
    
      return {
        content: [
          {
            type: 'text',
            text: `Command: ${command}\nExit Code: ${result.exitCode}\nOutput:\n${result.stdout}\n${result.stderr ? `Error:\n${result.stderr}` : ''}`,
          },
        ],
      };
    }
  • Input schema definition for the 'execute_command' tool, specifying the required 'command' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        command: { type: 'string', description: 'Command to execute' },
      },
      required: ['command'],
    },
  • Registration of the 'execute_command' tool handler in the CallToolRequestSchema switch statement.
    case 'execute_command':
      return await this.handleExecuteCommand(args);
  • Tool definition and registration in the ListToolsRequestSchema response, including name, description, and schema.
      name: 'execute_command',
      description: 'Execute a command on the connected VPS',
      inputSchema: {
        type: 'object',
        properties: {
          command: { type: 'string', description: 'Command to execute' },
        },
        required: ['command'],
      },
    },
  • Core helper function that performs the actual SSH command execution using node-ssh library, handling connection check, execution, logging, and error handling.
    async executeCommand(command: string): Promise<CommandResult> {
      if (!this.isConnected) {
        throw new Error('SSH connection not established');
      }
    
      try {
        logger.debug('Executing command', { command });
        const result = await this.ssh.execCommand(command);
    
        const commandResult: CommandResult = {
          success: result.code === 0,
          stdout: result.stdout,
          stderr: result.stderr,
          exitCode: result.code || 0,
        };
    
        if (commandResult.success) {
          logger.debug('Command executed successfully', {
            command,
            exitCode: commandResult.exitCode,
          });
        } else {
          logger.warn('Command execution failed', {
            command,
            exitCode: commandResult.exitCode,
            stderr: commandResult.stderr,
          });
        }
    
        return commandResult;
      } catch (error) {
        logger.error('Error executing command', {
          command,
          error: error instanceof Error ? error.message : 'Unknown error',
        });
        return {
          success: false,
          stdout: '',
          stderr: error instanceof Error ? error.message : 'Unknown error',
          exitCode: -1,
        };
      }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is to 'Execute a command' but lacks critical details: it doesn't specify permissions required, whether commands run with elevated privileges, potential side effects (e.g., data modification or system changes), error handling, or output format. This is inadequate for a tool that likely performs mutations on a VPS.

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, clear sentence with zero wasted words. It is appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration, making it highly efficient for an agent to parse.

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 tool's complexity (executing commands on a VPS implies potential mutations and security risks), lack of annotations, and no output schema, the description is incomplete. It fails to address behavioral aspects like safety, permissions, or result handling, leaving significant gaps for an agent to operate safely and effectively.

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?

The schema description coverage is 100%, with the single parameter 'command' documented in the schema as 'Command to execute'. The description adds no additional meaning beyond this, such as examples of valid commands, syntax constraints, or security considerations. Given the high schema coverage, a baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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 a command') and target resource ('on the connected VPS'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its siblings like 'ssh_connect' or 'vps_initialize', which might also involve VPS operations, leaving some ambiguity about its unique role.

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 offers no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., whether the VPS must be initialized or connected first), exclusions, or comparisons to sibling tools like 'ssh_connect' for remote access, leaving the agent to infer usage context.

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/oxy-Op/DevPilot'

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