get_monitors
Retrieve monitor configuration data to adapt Moom window layouts on macOS, enabling precise customization and control for optimal workspace organization.
Instructions
Get monitor configuration data for layout adaptation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:568-589 (handler)The main handler function for the 'get_monitors' MCP tool. It executes 'displayplacer list' via execSync, parses the output using the parseDisplayInfo helper, and returns a formatted text response with monitor configurations including resolution, position, and main display status.async getMonitors() { try { const output = execSync('displayplacer list', { encoding: 'utf8' }); const displays = this.parseDisplayInfo(output); return { content: [{ type: 'text', text: `Monitor Configuration:\n${displays.map((d, i) => `Display ${i + 1}: ${d.width}x${d.height} at (${d.x}, ${d.y})${d.isMain ? ' [Main]' : ''}` ).join('\n')}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error getting monitor info: ${error.message}` }] }; } }
- src/index.js:150-157 (schema)The schema definition for the 'get_monitors' tool, registered in the ListToolsRequestSchema handler. It specifies no input parameters.{ name: 'get_monitors', description: 'Get monitor configuration data for layout adaptation', inputSchema: { type: 'object', properties: {}, }, },
- src/index.js:227-228 (registration)The registration/dispatch logic in the CallToolRequestSchema handler that routes calls to the 'get_monitors' tool to its handler function.case 'get_monitors': return await this.getMonitors();
- src/index.js:594-624 (helper)Helper function that parses the raw output from 'displayplacer list' into a structured array of display objects containing id, type, width, height, x, y, and isMain properties.parseDisplayInfo(output) { const displays = []; const lines = output.split('\n'); let currentDisplay = {}; for (const line of lines) { if (line.includes('Persistent screen id:')) { if (currentDisplay.id) displays.push(currentDisplay); currentDisplay = { id: line.split(': ')[1] }; } else if (line.includes('Type:')) { currentDisplay.type = line.split(': ')[1]; } else if (line.includes('Resolution:')) { const res = line.match(/(\d+)x(\d+)/); if (res) { currentDisplay.width = parseInt(res[1]); currentDisplay.height = parseInt(res[2]); } } else if (line.includes('Origin:')) { const origin = line.match(/\((-?\d+),(-?\d+)\)/); if (origin) { currentDisplay.x = parseInt(origin[1]); currentDisplay.y = parseInt(origin[2]); } } else if (line.includes('Main Display: Yes')) { currentDisplay.isMain = true; } } if (currentDisplay.id) displays.push(currentDisplay); return displays; }