deny_command
Reject pending macOS terminal commands with a reason to maintain security controls in the Mac Shell MCP Server.
Instructions
Deny a pending command
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commandId | Yes | ID of the command to deny | |
| reason | No | Reason for denial |
Implementation Reference
- src/index.ts:482-515 (handler)The main execution handler for the 'deny_command' tool. Validates input with Zod schema, calls CommandService.denyCommand, and returns a success or error response.private async handleDenyCommand(args: unknown) { const schema = z.object({ commandId: z.string(), reason: z.string().optional(), }); const { commandId, reason } = schema.parse(args); try { this.commandService.denyCommand(commandId, reason); return { content: [ { type: 'text', text: `Command denied${reason ? `: ${reason}` : ''}`, }, ], }; } catch (error) { if (error instanceof Error) { return { content: [ { type: 'text', text: `Command denial failed: ${error.message}`, }, ], isError: true, }; } throw error; } }
- src/index.ts:197-213 (schema)The input schema definition for the 'deny_command' tool, registered in the ListTools response.{ name: 'deny_command', description: 'Deny a pending command', inputSchema: { type: 'object', properties: { commandId: { type: 'string', description: 'ID of the command to deny', }, reason: { type: 'string', description: 'Reason for denial', }, }, required: ['commandId'], },
- src/index.ts:238-239 (registration)The dispatch/registration of the 'deny_command' handler in the CallToolRequestSchema switch statement.case 'deny_command': return await this.handleDenyCommand(args);
- The supporting denyCommand method in CommandService that handles the actual denial logic: removes from pending, emits event, and rejects the promise.public denyCommand(commandId: string, reason: string = 'Command denied'): void { const pendingCommand = this.pendingCommands.get(commandId); if (!pendingCommand) { throw new Error(`No pending command with ID: ${commandId}`); } // Remove from pending queue this.pendingCommands.delete(commandId); // Emit event for denied command this.emit('command:denied', { commandId, reason }); // Reject the original promise pendingCommand.reject(new Error(reason)); } }