Skip to main content
Glama
cfdude

Mac Shell MCP Server

approve_command

Approve pending macOS terminal commands for execution through the Mac Shell MCP Server's security whitelisting system.

Instructions

Approve a pending command

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandIdYesID of the command to approve

Implementation Reference

  • The handler function for the 'approve_command' tool. It validates the input using Zod, calls the CommandService to approve and execute the command, and returns a formatted response with stdout and stderr.
    private async handleApproveCommand(args: unknown) {
      const schema = z.object({
        commandId: z.string(),
      });
    
      const { commandId } = schema.parse(args);
    
      try {
        const result = await this.commandService.approveCommand(commandId);
    
        return {
          content: [
            {
              type: 'text',
              text: `Command approved and executed successfully.\nOutput: ${result.stdout}`,
            },
            {
              type: 'text',
              text: result.stderr ? `Error output: ${result.stderr}` : '',
            },
          ],
        };
      } catch (error) {
        if (error instanceof Error) {
          return {
            content: [
              {
                type: 'text',
                text: `Command approval failed: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
  • JSON schema defining the input parameters for the 'approve_command' tool, requiring a 'commandId' string.
    inputSchema: {
      type: 'object',
      properties: {
        commandId: {
          type: 'string',
          description: 'ID of the command to approve',
        },
      },
      required: ['commandId'],
    },
  • src/index.ts:236-237 (registration)
    Registration and dispatch for the 'approve_command' tool in the switch statement of the CallToolRequest handler.
    case 'approve_command':
      return await this.handleApproveCommand(args);
  • Helper method in CommandService that approves a pending command by executing it with execFileAsync, emitting events, and resolving the associated 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.shell,
        });
    
        // 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 full burden for behavioral disclosure. 'Approve' implies a mutation that changes state, but the description doesn't clarify what happens after approval (e.g., does it trigger execution, log the action, or require additional steps?), potential side effects, permission requirements, or error conditions. This leaves significant gaps for a tool that likely involves security-sensitive operations.

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, direct sentence with no wasted words. It front-loads the core action and resource efficiently, making it easy to parse and understand at a glance.

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 lack of annotations and output schema, and the tool's likely role in a security/command workflow (inferred from sibling tools), the description is insufficient. It doesn't explain the outcome of approval, how it interacts with other tools (e.g., 'execute_command'), or any system constraints, leaving the agent with incomplete context for safe and effective use.

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' clearly documented in the schema. The description adds no additional parameter semantics beyond implying that 'commandId' refers to a pending command, which is already inferred from the tool's purpose. This 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'), which is specific and unambiguous. However, it doesn't differentiate this tool from its sibling 'deny_command' beyond the opposite action, nor does it explain what 'approve' entails in this context versus simply executing or modifying the command.

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'. It doesn't specify prerequisites (e.g., that the command must be in a pending state) or contextual cues for selection, leaving the agent to infer usage from the tool name 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/cfdude/mac-shell-mcp'

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