trigger_command
Trigger a single Hotkeyless command by its exact name, with automatic blacklist enforcement and existence verification, to execute predefined automation tasks.
Instructions
Trigger one Hotkeyless command by exact name using /trigger. Enforces blacklist and verifies command exists.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Exact command name returned by discover_commands. |
Implementation Reference
- CommandExecutionService.trigger() — the core handler that validates the command against the blacklist, looks it up via discovery, and delegates to the HTTP client.
public async trigger(command: string): Promise<EndpointActionResult> { if (this.safety.isBlocked(command)) { throw new CommandBlockedError(command); } const availableCommands = await this.discoveryService.getCommands(); const normalizedInput = normalizeCommandForComparison(command); const matchedCommand = availableCommands.find( (entry) => normalizeCommandForComparison(entry.command) === normalizedInput, ); if (!matchedCommand) { throw new CommandNotFoundError(command); } return this.client.triggerCommand({ command: matchedCommand.command }); } public async sendKeys(input: SendKeysRequest): Promise<EndpointActionResult> { return this.client.sendKeys(input); } public async mouseMove(input: MouseMoveRequest): Promise<EndpointActionResult> { return this.client.mouseMove(input); } } - HotkeylessAhkClient.triggerCommand() — makes the actual HTTP GET request to the /trigger endpoint.
public async triggerCommand(payload: TriggerRequest): Promise<EndpointActionResult> { return this.requestJson(`${this.config.endpoints.trigger}${this.buildUrl(payload.command)}`, { method: 'GET', body: JSON.stringify(payload.params ?? {}), }); } private async tryOptionalEndpoint( payload: unknown, endpointName: string, ): Promise<EndpointActionResult> { const obj: TriggerRequest = { command: endpointName, params: payload as Record<string, unknown>, } return this.triggerCommand(obj); } public async sendKeys(payload: SendKeysRequest): Promise<EndpointActionResult> { return this.tryOptionalEndpoint(payload, 'send_keys'); } public async mouseMove(payload: MouseMoveRequest): Promise<EndpointActionResult> { return this.tryOptionalEndpoint(payload, 'mouse_move'); } } - mcp-server/src/mcp/tools/registration.ts:144-192 (registration)Registration of the 'trigger_command' tool with name, description, input schema (command string), and the async handler that calls executionService.trigger().
server.registerTool( 'trigger_command', { description: 'Trigger one Hotkeyless command by exact name using /trigger. Enforces blacklist and verifies command exists.', inputSchema: { command: z .string() .trim() .min(1) .describe('Exact command name returned by discover_commands.'), }, }, async ({ command }) => { logInfo('tool.trigger_command.start', { command, }); try { const result = await executionService.trigger(command); logInfo('tool.trigger_command.success', { command, status: result.status, }); return { content: [ { type: 'text', text: JSON.stringify( { status: result.status, ok: true, response: result.body, }, null, 2, ), }, ], }; } catch (error) { logError('tool.trigger_command.failure', error, { command, }); return toErrorResult(error); } }, ); - mcp-server/src/types.ts:6-9 (schema)TriggerRequest type definition used by the trigger command.
export interface TriggerRequest { command: string; params?: Record<string, unknown>; } - BlacklistSafety — helper class that checks if a command is blocked before triggering.
import { normalizeCommandForComparison } from '@/domain/commands'; export class BlacklistSafety { private readonly blacklistSet: Set<string>; public constructor(blacklist: string[]) { this.blacklistSet = new Set(blacklist.map((item) => normalizeCommandForComparison(item))); } public isBlocked(command: string): boolean { return this.blacklistSet.has(normalizeCommandForComparison(command)); } }