block_command
Block specific terminal commands on the Desktop Commander MCP server to prevent their execution until manually unblocked, ensuring controlled command access.
Instructions
Add a command to the blacklist. Once blocked, the command cannot be executed until unblocked.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes |
Implementation Reference
- src/server.ts:236-242 (handler)Handles the "block_command" MCP tool request: parses input args, calls commandManager.blockCommand, and formats response.case "block_command": { const parsed = BlockCommandArgsSchema.parse(args); const blockResult = await commandManager.blockCommand(parsed.command); return { content: [{ type: "text", text: blockResult }], }; }
- src/tools/schemas.ts:23-25 (schema)Zod schema defining input for block_command: requires 'command' string.export const BlockCommandArgsSchema = z.object({ command: z.string(), });
- src/server.ts:102-107 (registration)Registers the block_command tool with MCP server, including name, description, and input schema.{ name: "block_command", description: "Add a command to the blacklist. Once blocked, the command cannot be executed until unblocked.", inputSchema: zodToJsonSchema(BlockCommandArgsSchema), },
- src/command-manager.ts:33-41 (helper)Core implementation: adds command (lowercased, trimmed) to blocked set if not already present, saves to config, returns success boolean.async blockCommand(command: string): Promise<boolean> { command = command.toLowerCase().trim(); if (this.blockedCommands.has(command)) { return false; } this.blockedCommands.add(command); await this.saveBlockedCommands(); return true; }