Skip to main content
Glama

block_command

Prevent specific terminal commands from executing by adding them to a blacklist within the Desktop Commander MCP server.

Instructions

Add a command to the blacklist. Once blocked, the command cannot be executed until unblocked.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes

Implementation Reference

  • Core handler function that implements the block_command tool logic: normalizes the command, checks if already blocked, adds to internal set if not, persists to config file, and returns boolean success.
    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; }
  • Zod schema for input validation of block_command tool, requiring a 'command' string.
    export const BlockCommandArgsSchema = z.object({ command: z.string(), });
  • src/server.ts:103-107 (registration)
    Registers the block_command tool in the MCP server's list of tools, specifying 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), },
  • MCP server dispatch handler for block_command: parses input args using schema and delegates to commandManager.blockCommand, formats response.
    case "block_command": { const parsed = BlockCommandArgsSchema.parse(args); const blockResult = await commandManager.blockCommand(parsed.command); return { content: [{ type: "text", text: blockResult }], }; }

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/MrGNSS/ClaudeDesktopCommander'

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