loading…
Search for a command to run...
loading…
An MCP and HTTP server wrapper for PyAutoGUI that enables LLMs to control mouse and keyboard operations across local or remote distributed environments. It prov
An MCP and HTTP server wrapper for PyAutoGUI that enables LLMs to control mouse and keyboard operations across local or remote distributed environments. It provides comprehensive tools for screen interaction, including clicking, typing, and capturing screenshots.
An MCP and HTTP server wrapper for PyAutoGUI, enabling LLMs to control your mouse and keyboard.
The service supports two deployment architectures:
This architecture separates the MCP server from the tool service, allowing the MCP server to connect to a remote tool service via HTTP.
graph LR
LLM[LLM Client] -->|MCP Protocol| MCP[MCP Server<br/>main.py<br/>Client-based Tools]
MCP -->|HTTP API<br/>with API Key| TOOLA[Tool Service<br/>tool.py<br/>HTTP API Server]
MCP -->|HTTP API<br/>with API Key| TOOLB[Tool Service<br/>tool.py<br/>HTTP API Server]
TOOLA -->|PyAutoGUI| COMPUTERA[Computer Control]
TOOLB -->|PyAutoGUI| COMPUTERB[Computer Control]
style LLM fill:#e1f5ff
style MCP fill:#fff4e1
style TOOLA fill:#ffe1f5
style COMPUTERA fill:#e1ffe1
style COMPUTERB fill:#e1ffe1
Characteristics:
register_computer_tools_with_client)endpoint parameter in MCP tool callsThis architecture uses direct tools where the MCP server directly performs computer control operations.
graph LR
LLM[LLM Client] -->|MCP Protocol<br/>stdio/http| MCP[MCP Server<br/>mcp_local.py<br/>Direct Tools]
MCP -->|PyAutoGUI| COMPUTER[Computer Control]
style LLM fill:#e1f5ff
style MCP fill:#fff4e1
style COMPUTER fill:#e1ffe1
Characteristics:
register_computer_tools)endpoint parameter needed in MCP tool callsuv package manager (recommended)git clone https://github.com/stonehill-2345/mcp-autogui-multinode.git
cd mcp-autogui-multinode
For local development with all features (GUI control + testing):
uv sync --group gui --group dev
For deploying MCP server that connects to remote tool service (no GUI dependencies needed):
uv sync --no-group gui
For deploying HTTP tool service that performs actual computer control (requires GUI):
uv sync --group gui
The service supports two independent servers:
Starts the HTTP API server for computer control:
uv run python tool.py
Starts the MCP server that can connect to remote tool services. The server supports two transport modes:
HTTP Transport Mode:
uv run python mcp_local.py http
stdio Transport Mode (default):
uv run python mcp_local.py stdio
After starting, you can access:
GET / - Root path, returns API informationGET /health - Health check endpointAll computer control actions are available at:
POST /api/computer/{action} - Execute a computer control actionGET /api/computer/actions - List all available actions| Action | Description | Parameters |
|---|---|---|
MoveMouse |
Move mouse cursor | x, y (coordinates) |
ClickMouse |
Click mouse button | x, y, button, press, release |
PressMouse |
Press mouse button (hold) | x, y, button |
ReleaseMouse |
Release mouse button | x, y, button |
DragMouse |
Drag mouse from source to target | source_x, source_y, target_x, target_y |
Scroll |
Scroll mouse wheel | scroll_direction, scroll_amount, x, y |
PressKey |
Press keyboard key(s) | key (e.g., "enter", "ctrl c") |
TypeText |
Type text (uses clipboard) | text |
Wait |
Wait for duration | duration (milliseconds) |
TakeScreenshot |
Capture screen | (no parameters) |
GetCursorPosition |
Get mouse position | (no parameters) |
GetScreenSize |
Get screen resolution | (no parameters) |
curl -X POST "http://localhost:8000/api/computer/MoveMouse" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-secret-api-key-here" \
-d '{"x": 100, "y": 200}'
curl -X POST "http://localhost:8000/api/computer/ClickMouse" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-secret-api-key-here" \
-d '{"x": 100, "y": 200, "button": "left"}'
curl -X POST "http://localhost:8000/api/computer/TakeScreenshot" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-secret-api-key-here" \
-d '{}'
curl -X POST "http://localhost:8000/api/computer/GetCursorPosition" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-secret-api-key-here" \
-d '{}'
Note: If API_KEY_ENABLED=false, the X-API-Key header is optional. If API_KEY_ENABLED=true, the header is required for all requests except health checks and documentation endpoints.
The service also exposes all computer control operations as MCP tools. When running the MCP server, you can use these tools through any MCP-compatible client.
All HTTP API actions are available as MCP tools. The MCP tool names use snake_case, while the HTTP API uses PascalCase:
move_mouse - Move mouse cursor (HTTP: MoveMouse)click_mouse - Click mouse button (HTTP: ClickMouse)press_mouse - Press mouse button (HTTP: PressMouse)release_mouse - Release mouse button (HTTP: ReleaseMouse)drag_mouse - Drag mouse (HTTP: DragMouse)scroll - Scroll mouse wheel (HTTP: Scroll)press_key - Press keyboard key (HTTP: PressKey)type_text - Type text (HTTP: TypeText)wait - Wait for duration (HTTP: Wait)take_screenshot - Take screenshot (HTTP: TakeScreenshot)get_cursor_position - Get cursor position (HTTP: GetCursorPosition)get_screen_size - Get screen size (HTTP: GetScreenSize)The MCP server supports two transport modes:
stdio (default): Standard input/output transport
python mcp_local.py stdiohttp: HTTP-based transport with stateless mode
python mcp_local.py httphttp://localhost:8001/mcpThe service supports two modes of MCP tool registration:
Direct Tools (register_computer_tools): Tools that directly call the local computer control implementation. No endpoint parameter required.
mcp_local.py for local MCP serverClient-based Tools (register_computer_tools_with_client): Tools that use an HTTP client to call a remote tool server. Requires an endpoint parameter.
mcp_server/register.py for remote MCP serverThe local MCP server (mcp_local.py) uses direct tools by default. The remote MCP server uses client-based tools.
⚠️ Warning: This service provides direct control over your computer's mouse and keyboard. Use with caution:
API_KEY_ENABLED=true and configure a strong API_KEY in productionThe service supports optional API key authentication for securing service-to-service communication:
API_KEY_ENABLED=true in your .env fileAPI_KEY=your-secret-api-key-here in your .env fileX-API-Key: your-secret-api-key-here (recommended)Authorization: Bearer your-secret-api-key-here (alternative)Excluded Paths (no authentication required):
/health - Health check endpoint/docs - API documentation/openapi.json - OpenAPI schema/redoc - Alternative API documentationMCP Client Usage with API Key:
from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport
# Create transport with API key
transport = StreamableHttpTransport(
url="http://localhost:8001/mcp",
headers={"X-API-Key": "your-secret-api-key-here"}
)
# Create client with transport
client = Client(transport)
async with client:
response = await client.call_tool("move_mouse", {"x": 100, "y": 200})
The service uses Loguru for structured logging with the following features:
Log files are stored in the logs/ directory:
app_YYYY-MM-DD.log: General application logserror_YYYY-MM-DD.log: Error logs onlyIn development mode, logs are only output to the console. In production mode, logs are written to both console and files.
Run tests using pytest:
# Run all tests
uv pytest
# Run specific test file
uvpytest tests/test_mcp_client.py
# Run with verbose output
pytest -v
The test suite includes:
test_local_mcp_client.py: Tests for local MCP server with HTTP transport (direct tools)test_stdio_mcp_client.py: Tests for local MCP server with stdio transport (direct tools)test_mcp_client.py: Tests for remote MCP server with client-based tools (requires endpoint parameter)If you get a port already in use error:
# Change ports in .env file
PORT=8002
MCP_PORT=8003
For HTTP transport, ensure the MCP server is running and accessible:
# Test MCP endpoint
curl http://localhost:8001/mcp
# Test with API key (if enabled)
curl -H "X-API-Key: your-secret-api-key-here" http://localhost:8001/mcp
For stdio transport, ensure the MCP server is started with stdio mode:
# Start MCP server in stdio mode
uv python mcp_local.py stdio
If you're getting authentication errors:
API_KEY_ENABLED is set correctly in .envAPI_KEY matches between client and serverX-API-Key header or Authorization: Bearer <key> headerIf screenshot functionality fails:
Contributions are welcome! Please feel free to submit a Pull Request.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mcp-autogui-multinode": {
"command": "npx",
"args": []
}
}
}