Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

get_screen_size

Retrieve the dimensions of your Windows display to ensure proper window placement and content scaling.

Instructions

获取屏幕尺寸

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function implementing get_screen_size tool logic, retrieving screen size via robotjs or fallback default values.
    getScreenSize() {
      try {
        if (this.robotAvailable) {
          const size = this.robot.getScreenSize();
          return { success: true, width: size.width, height: size.height };
        } else {
          // 备用方法:使用 PowerShell
          return { success: true, width: 1920, height: 1080, note: '使用默认值' };
        }
      } catch (error) {
        return { success: false, error: error.message };
      }
    }
  • Schema definition for the get_screen_size tool, specifying name, description, and empty input schema.
    {
      name: 'get_screen_size',
      description: '获取屏幕尺寸',
      inputSchema: {
        type: 'object',
        properties: {},
      },
    },
  • Registration and dispatch of get_screen_size in the executeTool method's switch statement.
    case 'get_screen_size':
      return this.getScreenSize();
  • Tool name registered in the canHandle method's supported tools array.
    const tools = ['move_mouse', 'mouse_click', 'type_text', 'press_key', 
                   'get_mouse_position', 'get_screen_size'];
    return tools.includes(toolName);
  • Helper condition in executeTool allowing get_screen_size to run without robotjs dependency.
    if (!this.robotAvailable && name !== 'get_screen_size') {
      return { 
        success: false, 
        error: 'robotjs 未安装。请运行: npm install robotjs(需要 Windows Build Tools)' 
      };
    }

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/eva-wanxin-git/windows-automation-mcp'

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