Skip to main content
Glama

set_window_position

Move application windows to exact screen coordinates for precise positioning control in macOS window management.

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

  • The handler function that executes the set_window_position tool. It constructs and runs an AppleScript to activate the specified application and set the position of its front window to the given (x, y) coordinates.
    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 set_window_position tool, specifying required parameters appName (string), x (number), and y (number).
    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)
    Registers the tool handler in the CallToolRequestSchema switch statement, dispatching to the setWindowPosition method.
    case 'set_window_position': return await this.setWindowPosition(args.appName, args.x, args.y);
  • src/index.js:158-179 (registration)
    Registers the tool in the ListToolsRequestSchema response, providing name, description, and input schema.
    { 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'], }, },
  • Helper function to map application names to their process names, used in setWindowPosition to target the correct System Events process.
    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; }

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