Skip to main content
Glama

get_monitors

Retrieve monitor configuration data to adapt window layouts on macOS for improved workspace organization.

Instructions

Get monitor configuration data for layout adaptation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function that runs 'displayplacer list', parses output using parseDisplayInfo, and returns formatted monitor configuration.
    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 (registration)
    Tool registration entry in ListTools response defining name, description, and empty input schema.
    { name: 'get_monitors', description: 'Get monitor configuration data for layout adaptation', inputSchema: { type: 'object', properties: {}, }, },
  • src/index.js:227-228 (registration)
    Dispatch case in CallToolRequest handler that routes to the getMonitors implementation.
    case 'get_monitors': return await this.getMonitors();
  • Input schema definition (empty object, no parameters required).
    inputSchema: { type: 'object', properties: {}, },
  • Helper function to parse displayplacer output into structured monitor data (width, height, position, main status).
    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; }

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