Skip to main content
Glama
cfdude

Super Shell MCP Server

approve_command

Authorize pending shell commands for execution across Windows, macOS, and Linux systems. This security tool enables controlled command approval through a whitelisting mechanism.

Instructions

Approve a pending command

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandIdYesID of the command to approve

Implementation Reference

  • Main handler for the 'approve_command' MCP tool. Parses commandId argument, calls CommandService.approveCommand, handles the result or error, and returns formatted MCP response.
    private async handleApproveCommand(args: any) {
      const schema = z.object({
        commandId: z.string(),
      });
    
      logger.debug(`handleApproveCommand called with args: ${JSON.stringify(args)}`);
    
      const { commandId } = schema.parse(args);
    
      // Log the approval attempt
      logger.debug(`[Approval Attempt] ID: ${commandId}`);
    
      // Check if the command exists in our local pending approvals map
      const localPending = this.pendingApprovals.has(commandId);
      logger.debug(`Command found in local pendingApprovals: ${localPending ? 'yes' : 'no'}`);
    
      // Check if the command exists in the CommandService's pending queue
      const pendingCommands = this.commandService.getPendingCommands();
      logger.debug(`CommandService pending commands: ${pendingCommands.length}`);
      const pendingCommand = pendingCommands.find(cmd => cmd.id === commandId);
      logger.debug(`Command found in CommandService pending queue: ${pendingCommand ? 'yes' : 'no'}`);
      
      if (pendingCommand) {
        logger.debug(`Pending command details: ${JSON.stringify({
          id: pendingCommand.id,
          command: pendingCommand.command,
          args: pendingCommand.args,
          requestedAt: pendingCommand.requestedAt
        })}`);
      }
    
      try {
        logger.debug(`Calling CommandService.approveCommand with ID: ${commandId}`);
        // Use the CommandService's approveCommand method directly
        const result = await this.commandService.approveCommand(commandId);
        
        logger.debug(`[Command Approved] ID: ${commandId}, Output length: ${result.stdout.length}`);
        logger.debug(`Command output: ${result.stdout.substring(0, 100)}${result.stdout.length > 100 ? '...' : ''}`);
        
        return {
          content: [
            {
              type: 'text',
              text: `Command approved and executed successfully.\nOutput: ${result.stdout}`,
            },
            {
              type: 'text',
              text: result.stderr ? `Error output: ${result.stderr}` : '',
            },
          ],
        };
      } catch (error) {
        logger.error(`[Approval Error] ID: ${commandId}, Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
        
        if (error instanceof Error) {
          return {
            content: [
              {
                type: 'text',
                text: `Command approval failed: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    }
  • src/index.ts:242-255 (registration)
    MCP tool registration in the ListTools handler response. Defines name, description, and input schema for 'approve_command'.
    {
      name: 'approve_command',
      description: 'Approve a pending command',
      inputSchema: {
        type: 'object',
        properties: {
          commandId: {
            type: 'string',
            description: 'ID of the command to approve',
          },
        },
        required: ['commandId'],
      },
    },
  • Zod schema for input validation in the handler.
    const schema = z.object({
      commandId: z.string(),
    });
  • Core logic for approving and executing a pending command. Retrieves pending command, executes it via execFileAsync, emits events, and resolves/rejects the promise.
    public async approveCommand(commandId: string): Promise<CommandResult> {
      const pendingCommand = this.pendingCommands.get(commandId);
      if (!pendingCommand) {
        throw new Error(`No pending command with ID: ${commandId}`);
      }
    
      try {
        const { stdout, stderr } = await execFileAsync(
          pendingCommand.command,
          pendingCommand.args,
          { shell: this.useShell ? this.shell : false }
        );
    
        // Remove from pending queue
        this.pendingCommands.delete(commandId);
        
        // Emit event for approved command
        this.emit('command:approved', { commandId, stdout, stderr });
        
        // Resolve the original promise
        pendingCommand.resolve({ stdout, stderr });
        
        return { stdout, stderr };
      } catch (error) {
        // Remove from pending queue
        this.pendingCommands.delete(commandId);
        
        // Emit event for failed command
        this.emit('command:failed', { commandId, error });
        
        if (error instanceof Error) {
          // Reject the original promise
          pendingCommand.reject(error);
          throw error;
        }
        
        const genericError = new Error('Command execution failed');
        pendingCommand.reject(genericError);
        throw genericError;
      }
    }
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 implies a mutation ('Approve') but doesn't specify permissions required, whether the action is reversible, or what happens after approval (e.g., does it trigger execution?). This leaves critical behavioral traits unclear for a tool that likely changes system state.

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 directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to parse quickly.

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?

For a mutation tool with no annotations and no output schema, the description is insufficient. It lacks details on behavioral outcomes, error conditions, or integration with sibling tools (e.g., how approval relates to 'execute_command'), leaving gaps in understanding the tool's role in the broader context.

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 the single parameter 'commandId' well-documented in the schema. The description adds no additional meaning about the parameter beyond what the schema provides, such as format examples or sourcing guidance, so it meets the baseline for high schema coverage.

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 ('Approve') and the target resource ('a pending command'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'deny_command' beyond the opposite action, missing explicit differentiation that would warrant a score of 5.

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 'deny_command' or 'execute_command', nor does it mention prerequisites such as needing a pending command from 'get_pending_commands'. This lack of contextual direction leaves the agent without usage instructions.

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/cfdude/super-shell-mcp'

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