Skip to main content
Glama

deny_command

Block pending macOS terminal commands on the Mac Shell MCP Server by providing a command ID and reason for denial. Enhances security by enabling controlled command execution.

Instructions

Deny a pending command

Input Schema

NameRequiredDescriptionDefault
commandIdYesID of the command to deny
reasonNoReason for denial

Input Schema (JSON Schema)

{ "properties": { "commandId": { "description": "ID of the command to deny", "type": "string" }, "reason": { "description": "Reason for denial", "type": "string" } }, "required": [ "commandId" ], "type": "object" }

Implementation Reference

  • MCP tool handler for 'deny_command' that validates input schema, calls the command service's denyCommand method, 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-214 (registration)
    Registration of the 'deny_command' tool in the MCP server's list of tools, including name, description, and input schema.
    { 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'], }, },
  • Core helper method in CommandService that handles denying a pending command by removing it from the queue, emitting a 'command:denied' event, and rejecting the associated 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)); } }
  • Zod schema for input validation in the deny_command handler, matching the tool's inputSchema.
    const schema = z.object({ commandId: z.string(), reason: z.string().optional(), });

Other Tools

Related 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