Gorked
Computer-use agent framework that uses Grok CLI and MCP to control the desktop via screen OCR, mouse/keyboard actions, and a chat HUD.
README
Gorked
Computer-use agent framework for Grok Build CLI: see the screen, box every text region, target center pixels, and act — with a transparent thought process and a high-tech chat HUD.
Gorked does not call the xAI HTTP API for planning. The brain is the local grok binary (headless mode: streaming thoughts, tools, MCP). The hands and eyes are Gorked (OCR, mouse/keyboard, safety gates).
┌──────────────┐ ┌─────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Capture │ → │ OCR text │ → │ Headless Grok │ → │ Mouse/keyboard │
│ primary mon │ │ boxes+ctr │ │ (CLI + MCP) │ │ (dry-run/live) │
└──────────────┘ └─────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────────────────┐
│ gorked-hud (C++ chat panel) │
│ thoughts · plans · actions │
└──────────────────────────────┘
Features
| Area | What you get |
|---|---|
| Screen vision | Fast screenshots (primary monitor only), RapidOCR boxes, center-pixel click targets |
| Annotation | Color boxes, labels, crosshairs + (x,y) chips on PNGs |
| Computer control | Move, click, double/right-click, type, click-and-type, hotkey, drag, scroll |
| Safety | Dry-run by default; live needs explicit flags + confirmation phrase |
| Brain | Headless grok CLI — streaming thoughts, tool use, JSON-schema plans |
| MCP tools | Grok drives Gorked via MCP (analyze_screen, click_text, hotkey, …) |
| HUD | Frameless C++ messenger (bottom-right): chat in, thoughts out, Esc aborts |
| Thought journal | OBSERVE / REASON / PLAN / ACT / RESULT traces → JSON + HUD bubbles |
Requirements
- Linux with X11 (Wayland-only sessions may need XWayland for capture/input)
- Python 3.11+
- Grok Build CLI on
PATH(grok), authenticated (grok login) - C++17 toolchain + CMake (only if you build the HUD)
- X11 libraries:
libX11,libXft,libXrender,libXrandr, fontconfig, freetype
Optional: dual-monitor setups are fine — only the primary display is captured (secondary/TV ignored to save tokens).
Install
git clone https://github.com/iBerry420/gorked.git
cd gorked
python3 -m venv .venv
source .venv/bin/activate
pip install -e .
# Register project MCP for Grok Build
gorked mcp --install
# Trust the folder once if needed: open with `grok --trust` in this repo
Build the HUD (recommended)
cmake -S hud -B hud/build
cmake --build hud/build -j
# binary: hud/build/gorked-hud
Quick start
# Synthetic UI + OCR + heuristic plan (no Grok call required)
gorked demo
# Live OCR: boxes + center coordinates on primary monitor
gorked analyze
gorked monitors # which display is captured
# Find UI text → absolute click coords
gorked find "Save"
# High-tech chat HUD (leave open)
gorked hud
# Live mouse/keyboard when you send tasks from the HUD:
gorked hud --live
# Headless Grok + MCP tools (dry-run)
gorked drive "Click the Settings button"
# Live computer use (real input)
gorked drive "Open Chrome, search cats" --live
HUD controls
| Input | Action |
|---|---|
| Enter | Newline in composer |
| Ctrl+Enter | Send task → spawns gorked drive |
| Esc | Abort running agent process tree |
| Drag header | Move window (frameless tool window) |
| − | Minimize to pill (flush bottom-right) |
| Restore (on pill) | Expand full panel |
| × | Quit |
Architecture
Two ways to run the agent
1. Drive mode (recommended) — Grok is in charge via MCP:
User / HUD → gorked drive "goal" → grok -p (streaming-json, --yolo, --trust)
↓ MCP tool calls
gorked MCP server
↓
capture · OCR · mouse · keyboard
↓
output/ + HUD bubbles
2. Agent/plan mode — Gorked OCRs, Grok returns structured PlannedAction[], Gorked executes:
gorked agent "goal" # or gorked plan "goal"
Primary-only capture
| mss index | Meaning | Default |
|---|---|---|
| 0 | Virtual all-monitors | Blocked |
| 1… | Physical displays | Primary only (is_primary) |
Env overrides: GORKED_ALLOW_ALL_MONITORS=1, GORKED_ALLOW_MONITOR_OVERRIDE=1, GORKED_MONITOR=primary.
Live vs dry-run
| Layer | Dry-run | Live |
|---|---|---|
| CLI | default | --live |
| HUD | gorked hud |
gorked hud --live |
| MCP process env | GORKED_DRY_RUN=1 |
GORKED_LIVE=1 + GORKED_DRY_RUN=0 |
| Explicit toggle | — | set_live_mode(true, confirm_phrase="I_ACCEPT_LIVE_CONTROL") |
Live mode is not pinned in .grok/config.toml so each run inherits the correct mode from the parent process.
MCP tools
Exposed to headless Grok as server gorked:
| Tool | Purpose |
|---|---|
get_status |
dry_run / live, monitor, paths |
set_live_mode |
Gate real input (or no-op if already live) |
thought |
User-visible reasoning → HUD |
list_monitors / capture_screen |
Display info / raw shot |
analyze_screen / analyze_image |
OCR boxes + centers |
find_text / click_text |
Locate / click labels |
mouse_move / mouse_click / mouse_drag / mouse_scroll |
Pointer |
type_text / click_and_type / hotkey |
Keyboard |
wait_ms / recent_actions |
Timing / audit |
grok mcp list
grok mcp doctor gorked
CLI reference
gorked capture [options] Screenshot primary monitor
gorked analyze [image] OCR + annotate + scene JSON
gorked find QUERY Match text → center coords
gorked plan GOAL Plan only (Grok CLI / heuristic)
gorked agent GOAL Observe → plan → act loop
gorked drive GOAL Full Grok+MCP computer-use loop
gorked demo Synthetic UI end-to-end
gorked monitors List displays + capture policy
gorked mcp [--install] Run or register MCP server
gorked hud [--live] Launch C++ chat HUD
Useful flags: --out, --monitor, --heuristic, --no-tools, --model, --max-turns, --json.
Python API
from gorked.pipeline import VisionPipeline
from gorked.agent import AgentConfig, ComputerUseAgent
from gorked.drive import run_drive
from gorked import computer
# Vision
pipe = VisionPipeline("output")
scene, raw, annotated, journal = pipe.analyze_screen()
for r in scene.regions:
print(r.text, r.click_point.as_tuple())
# Structured agent (dry-run)
agent = ComputerUseAgent(AgentConfig(goal="Click Settings", dry_run=True))
result = agent.run()
# Drive with Grok + MCP
run_drive("Open the browser settings", live=False)
# Low-level actions
ctrl = computer.ComputerController(dry_run=True)
ctrl.execute(computer.click_at(100, 200, rationale="example"))
Project layout
gorked/
├── src/gorked/
│ ├── capture.py # mss screenshots (primary-only policy)
│ ├── ocr.py # RapidOCR → TextRegion + center
│ ├── annotate.py # boxes / crosshairs
│ ├── computer.py # pynput mouse + keyboard
│ ├── models.py # BBox, ScreenScene, PlannedAction, …
│ ├── thought.py # thought journal → HUD bus
│ ├── hud_bus.py # JSONL events for the C++ HUD
│ ├── grok_cli.py # headless `grok` runner (streaming-json)
│ ├── planner.py # structured plans + heuristic fallback
│ ├── agent.py # observe → plan → act loop
│ ├── drive.py # Grok + MCP drive mode
│ ├── mcp_server.py # FastMCP tool surface
│ ├── pipeline.py # capture → detect → annotate
│ └── cli.py # typer entrypoints
├── hud/ # C++17 X11/Xft frameless messenger
│ ├── src/
│ ├── CMakeLists.txt
│ └── README.md
├── .grok/skills/ # computer-use skill for Grok Build
├── AGENTS.md # project rules for Grok
├── pyproject.toml
└── README.md
Artifacts under output/ (gitignored): captures, annotated PNGs, scene JSON, thought traces, hud.jsonl.
Environment variables
| Variable | Purpose |
|---|---|
GORKED_MONITOR |
primary (default) or index |
GORKED_LIVE |
1 → real input at MCP boot |
GORKED_DRY_RUN |
1 → simulate input |
GORKED_OUTPUT_DIR |
Artifact directory |
GORKED_HUD_STREAM |
Path to HUD JSONL stream |
GORKED_HUD_LIVE |
HUD-spawned drives use --live |
GORKED_BIN |
Path to gorked CLI for the HUD |
GORKED_GROK_BIN |
Path to grok if not on PATH |
GORKED_ALLOW_ALL_MONITORS |
Allow virtual dual-desktop capture |
GORKED_ALLOW_MONITOR_OVERRIDE |
Allow non-primary indices |
Copy .env.example for a starting point (never commit real secrets).
Safety notes
- Dry-run is the default. Live control can move the mouse and type for real.
- Prefer keeping the Grok TUI / HUD from covering the UI the agent must click.
- Esc in the HUD aborts the active drive process group (
SIGTERM→SIGKILL). - Do not run live mode unattended on sensitive sessions without allowlists.
Development
source .venv/bin/activate
pip install -e ".[dev]"
# Reinstall after code changes (editable)
pip install -e .
# Rebuild HUD
cmake --build hud/build -j
Roadmap
- [x] Capture + OCR boxes + center click targets
- [x] Computer primitives + dry-run
- [x] Thought journal + HUD stream
- [x] Headless Grok CLI planner + drive mode
- [x] MCP tool surface for Grok
- [x] Frameless C++ chat HUD (send / abort / live)
- [ ] Multi-step re-OCR verification loops
- [ ] Action allowlists / forbidden zones
- [ ] Native Grok computer-use handoff when available
License
MIT — see LICENSE.
Acknowledgments
- Grok Build / xAI — headless agent CLI
- RapidOCR — ONNX text detection
- mss — screenshots
- pynput — input
- MCP — tool protocol
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。