Skip to main content
Glama

set_window_position

Move a window to precise coordinates (x, y) on macOS by specifying the application name, enabling exact control over window placement within the Moom MCP Server framework.

Instructions

Move a window to a specific position for precise control

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameYesName of the application
xYesX coordinate
yYesY coordinate

Implementation Reference

  • Executes the tool logic by activating the application, bringing its window to front, and setting its position to the specified (x, y) coordinates using AppleScript and System Events.
    async setWindowPosition(appName, x, y) { const processName = this.getProcessName(appName); const script = ` tell application "${appName}" to activate delay 0.5 tell application "System Events" tell process "${processName}" set frontmost to true set position of front window to {${x}, ${y}} end tell end tell `; try { await this.runAppleScript(script); return { content: [{ type: 'text', text: `Successfully positioned ${appName} window at (${x}, ${y})` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error positioning ${appName}: ${error.message}` }] }; } }
  • Defines the input schema for the tool, specifying required parameters: appName (string), x (number), y (number).
    { name: 'set_window_position', description: 'Move a window to a specific position for precise control', inputSchema: { type: 'object', properties: { appName: { type: 'string', description: 'Name of the application', }, x: { type: 'number', description: 'X coordinate', }, y: { type: 'number', description: 'Y coordinate', }, }, required: ['appName', 'x', 'y'], }, },
  • src/index.js:229-230 (registration)
    In the CallToolRequestHandler switch statement, routes the tool call to the setWindowPosition handler method.
    case 'set_window_position': return await this.setWindowPosition(args.appName, args.x, args.y);
  • Helper method to map application names to their process names for use in AppleScript (e.g., 'Visual Studio Code' -> 'Code'), called within the handler.
    getProcessName(appName) { const processMap = { "Visual Studio Code": "Code", "iTerm": "iTerm2", "Safari": "Safari", "Claude": "Claude", "Terminal": "Terminal", "Finder": "Finder", "Chrome": "Google Chrome", "Firefox": "Firefox" }; return processMap[appName] || appName; }
  • Utility method to execute AppleScript commands asynchronously using osascript, used by the handler to perform the window positioning.
    async runAppleScript(script) { try { const { stdout, stderr } = await execAsync(`osascript -e '${script}'`); if (stderr) { throw new Error(stderr); } return stdout.trim(); } catch (error) { throw new Error(`AppleScript error: ${error.message}`); }

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/itrimble/moom-mcp'

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