trigger_moom_action
Control window layouts on macOS by triggering Moom actions like resize, move, or center windows using keyboard shortcuts.
Instructions
Trigger common Moom actions via keyboard shortcuts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Moom action to trigger |
Implementation Reference
- src/index.js:342-394 (handler)Executes the tool by mapping the action parameter to specific Moom keyboard shortcuts and running the corresponding AppleScript via System Events.async triggerMoomAction(action) { // Map actions to Moom keyboard shortcuts const shortcuts = { 'grow': { key: '=', modifiers: 'control down, option down' }, 'shrink': { key: '-', modifiers: 'control down, option down' }, 'move-left': { key: '123', modifiers: 'control down, option down' }, // left arrow 'move-right': { key: '124', modifiers: 'control down, option down' }, // right arrow 'move-up': { key: '126', modifiers: 'control down, option down' }, // up arrow 'move-down': { key: '125', modifiers: 'control down, option down' }, // down arrow 'center': { key: 'c', modifiers: 'control down, option down' }, 'fill-screen': { key: 'return', modifiers: 'control down, option down' }, }; const shortcut = shortcuts[action]; if (!shortcut) { return { content: [ { type: 'text', text: `Unknown action: ${action}`, }, ], }; } const script = ` tell application "System Events" ${shortcut.key.length > 1 ? `key code ${shortcut.key} using {${shortcut.modifiers}}` : `keystroke "${shortcut.key}" using {${shortcut.modifiers}}`} end tell `; try { await this.runAppleScript(script); return { content: [ { type: 'text', text: `Successfully triggered Moom action: ${action}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], }; } }
- src/index.js:62-72 (schema)Defines the input schema for the trigger_moom_action tool, specifying the 'action' parameter as a string enum.inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['grow', 'shrink', 'move-left', 'move-right', 'move-up', 'move-down', 'center', 'fill-screen'], description: 'Moom action to trigger', }, }, required: ['action'], },
- src/index.js:60-73 (registration)Registers the trigger_moom_action tool in the ListTools response, including name, description, and input schema.name: 'trigger_moom_action', description: 'Trigger common Moom actions via keyboard shortcuts', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['grow', 'shrink', 'move-left', 'move-right', 'move-up', 'move-down', 'center', 'fill-screen'], description: 'Moom action to trigger', }, }, required: ['action'], }, },
- src/index.js:213-214 (registration)Dispatches calls to the trigger_moom_action tool by invoking the handler method in the main CallToolRequest handler.case 'trigger_moom_action': return await this.triggerMoomAction(args.action);