Skip to main content
Glama

Windows Automation MCP Server

press_key

Simulate keyboard key presses to automate Windows system interactions. Send individual keys or combinations with modifiers like control, shift, and alt for automated input tasks.

Instructions

按下键盘按键

Input Schema

NameRequiredDescriptionDefault
keyYes按键名称(如 enter, tab, escape)
modifiersNo修饰键(如 control, shift, alt)

Input Schema (JSON Schema)

{ "properties": { "key": { "description": "按键名称(如 enter, tab, escape)", "type": "string" }, "modifiers": { "description": "修饰键(如 control, shift, alt)", "items": { "type": "string" }, "type": "array" } }, "required": [ "key" ], "type": "object" }

Implementation Reference

  • The pressKey method implements the core logic of the 'press_key' tool. It uses robotjs.keyTap to press the specified key, supporting optional modifiers like control, shift, etc., and returns success/failure with details.
    pressKey(key, modifiers = []) { try { if (modifiers.length > 0) { this.robot.keyTap(key, modifiers); } else { this.robot.keyTap(key); } return { success: true, key, modifiers, message: '按键已按下' }; } catch (error) { return { success: false, error: error.message }; } }
  • The tool definition in getToolDefinitions(), providing the name, description, and inputSchema for validation of 'press_key' tool parameters.
    { name: 'press_key', description: '按下键盘按键', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '按键名称(如 enter, tab, escape)' }, modifiers: { type: 'array', items: { type: 'string' }, description: '修饰键(如 control, shift, alt)' }, }, required: ['key'], }, },
  • In the executeTool switch statement, the case for 'press_key' that dispatches to the pressKey handler.
    case 'press_key': return this.pressKey(args.key, args.modifiers);
  • src/server.js:46-46 (registration)
    Instantiates the MouseKeyboardTools class in the main server, which provides the 'press_key' tool among others, enabling its registration via getToolDefinitions().
    mouseKeyboard: new MouseKeyboardTools(),
  • The canHandle method lists 'press_key' as one of the tools this module can handle, used by the server to route calls correctly.
    canHandle(toolName) { const tools = ['move_mouse', 'mouse_click', 'type_text', 'press_key', 'get_mouse_position', 'get_screen_size']; return tools.includes(toolName);

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