Computer Control MCP Server — Mouse, Keyboard, OCR
Control your computer with an MCP server for mouse, keyboard and OCR using PyAutoGUI, RapidOCR and ONNXRuntime-zero external dependencies.
uvx computer-control-mcp@latestOverview
This project implements a Model Context Protocol (MCP) server that exposes basic computer-control primitives—mouse, keyboard and OCR—so an MCP-capable agent or client can control a desktop environment programmatically. It wraps common desktop automation and OCR libraries to provide a small set of tools that are callable over a simple HTTP/MCP-style API. The server is intended for local automation, testing, accessibility tooling and agent-driven workflows where an AI or automation system needs to interact with a graphical desktop.
The implementation uses well-known building blocks (PyAutoGUI for input automation, RapidOCR and ONNX Runtime for local OCR) while keeping the surface area minimal so you can run it on a workstation without heavy external services. Because it exposes discrete tool endpoints, it can be plugged into an MCP-enabled agent pipeline or called directly from scripts and CI jobs that require GUI-level interactions and on-screen text extraction.
Features
- Programmatic mouse control: move, click, drag, scroll, position queries
- Keyboard interaction: type text, key presses, hotkeys
- On-screen OCR: extract text from full-screen or region screenshots using RapidOCR and ONNX Runtime
- Simple JSON-based HTTP/MCP interface for tool invocation
- Minimal runtime dependencies and local execution (no cloud OCR required)
- Example clients and payloads for curl and Python requests
Installation / Configuration
Prerequisites: Python 3.8+, pip, and a desktop environment where automated input is permitted.
Quick start:
Run the server (examples — the actual entrypoint may vary):
# If the repo provides a simple script
# Or using an ASGI server if the app exports an app object
Configuration options (examples; actual keys may differ by release):
- OCR_MODEL_PATH: path to a local ONNX OCR model (optional if bundled)
- HOST / PORT: network binding for the HTTP/MCP server
- ENABLE_GUI: whether GUI automation is enabled (sensible default: true on local machines)
Set environment variables before starting:
To install optional GPU-accelerated ONNX Runtime:
Available Tools
The server exposes three primary tools via HTTP/MCP endpoints. Example endpoints and minimal payloads are shown here; consult the repository for exact routes and schema.
Table: tools overview
| Tool | Endpoint (example) | Description |
|---|---|---|
| Mouse | POST /tools/mouse | Move, click, drag, scroll or query pointer |
| Keyboard | POST /tools/keyboard | Type text, press/release keys, hotkeys |
| OCR | POST /tools/ocr | Capture screen or region and return recognized text |
Example: move mouse to coordinates with curl
Example: type a string with Python requests
=
Example: OCR a screen region
Typical request fields
- action: operation to run (move, click, type, capture, etc.)
- x, y, duration: mouse coordinates and movement time
- text: string to type
- region: bounding box for OCR capture
- options: additional flags (confidence thresholds, image preprocessing)
Use Cases
- Automated UI testing: script complex user interactions (drag/drop, hotkeys) and validate on-screen text via OCR.
- Assistive applications: let an agent or automation layer operate the desktop on behalf of a user with limited mobility.
- Agent-driven workflows: AI agents that need to inspect application state visually and interact with UI elements can call the MCP tools to read and control the screen.
- Data extraction from applications: capture regions of proprietary UIs and run offline OCR to harvest text for logging or reporting.
- Remote demonstration and debugging: reproduce sequences of input programmatically and capture the visual output for diagnostics.
Security and safety notes
- This server can control your mouse/keyboard and read your screen—run it only in trusted environments.
- Consider binding to localhost and using access controls if exposing the server on a network.
For implementation details,