Universal Game MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Universal Game MCPread my manpower and political power from the HOI4 topbar"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Universal Game MCP (UGM)
English | Tiแบฟng Viแปt (Vietnamese Guide)
Universal Game MCP (UGM) is a lightweight, CPU-friendly open-source Model Context Protocol (MCP) server that empowers AI assistants to observe, read text, locate icons, send DirectInput keyboard/mouse controls, and verify action outcomes in offline games (starting with Hearts of Iron IV).
โก Measured Benchmark & Performance Profile
Benchmarked on AMD Ryzen 5 5500U (6 Cores / 12 Threads, Windows 11 x64) under actual CPU execution:
Subsystem | Measured Latency | Throughput / Speedup | Notes |
Capture (DMA/Memory Buffer) | 2.20 ms | ~450 FPS buffer pull | DXGI Desktop Duplication API / DMA |
ROI Template Match (OpenCV) | 51.27 ms | 14.5x faster than full screen | Multi-scale template matching + NMS |
Full-Screen Template Match | 743.10 ms | Baseline | Full 1080p scan |
Event-driven ROI OCR | 705.05 ms | 3.0x faster than full screen | PP-OCRv4 CPU (no GPU required) |
Full-Screen 1080p OCR | 2,115.99 ms | Heavy (unoptimized) | Avoided at runtime via ROI crop |
Visual Diff Verification | 4.58 ms | Real-time state check | Absdiff + threshold check |
RAM Footprint (Steady State) | 117.65 MB | < 120 MB RAM total | Extremely light on CPU & memory |
Related MCP server: local-game-mcp
๐ Architecture & Design Principles
+-----------------------------------+
| AI Client / LLM Agent |
+-----------------+-----------------+
| (MCP SDK v2 JSON-RPC)
v
+-----------------------------------+
| Universal Game MCP Server |
| (ugm.server) |
+-----------------+-----------------+
|
+---------------------------+---------------------------+
| | |
v v v
+---------------+ +---------------+ +---------------+
| ugm.core | | ugm.adapters | | ugm.safety |
| - capture | | - hoi4 | | - killswitch |
| - ocr | | - offline_sim | | - dry_run |
| - icon | | - generic | | - bounds |
| - input | +---------------+ | - anti-cheat |
| - verifier | +---------------+
+---------------+Game-Agnostic Core: The core subsystems (
capture,ocr,icon,input,verifier,safety) operate entirely independently of any specific title.Modular Adapters (Plugins):
ugm.adapters.hoi4: Hearts of Iron IV plugin (Topbar metrics, research, diplomacy, pause key).ugm.adapters.sim: Self-contained offline strategy simulator for testing without commercial games installed.ugm.adapters.generic: Generic adapter for arbitrary strategy/simulation titles.
Event-Driven ROI OCR: Rather than burning CPU cycles doing continuous 60fps full-screen OCR, UGM captures and OCRs only on demand when triggered by specific events (reading a tooltip, reading topbar statistics, reading dialogue options).
Coordinate Normalization: All returned bounding boxes and points are normalized
[0.0, 1.0]relative to the target game window client rectangle.Safety by Default:
Ambiguity protection: If icon/text detection is ambiguous, UGM reports ambiguity so AI can hover to inspect tooltip rather than clicking blindly.
Out-of-bounds containment: Input commands outside target window are rejected.
Dry-Run mode: Allows simulating clicks without dispatching hardware input.
Emergency Stop: Instant global killswitch blocks all further inputs.
Anti-Cheat Blocker: Strictly refuses execution if online anti-cheat engines (EAC, BattlEye, Vanguard) are detected.
Privacy First: Dataset recording is opt-in (
disabled by default) and automatically excluded from Git.
๐ Standard MCP Tools
Tool Name | Prioritized V1 Capabilities | Description |
| Windows geometry & DPI scaling | Finds and attaches to target game window; returns client rectangle, DPI scale, and focus state. |
| Native resolution capture | Captures current game frame (supports ROI cropping, Base64 preview, and disk saving). |
| Small UI text & ROI OCR | Event-driven RapidOCR reading on normalized ROI with small-text enhancement. |
| Multimodal target resolution | Locates UI elements via icon template, OCR text, or registered selector with ambiguity detection. |
| Backward-compatible alias | Multi-scale OpenCV template matching with NMS and ambiguity detection. |
| Tooltip verification | Hovers mouse at normalized |
| State verification & dynamic targets | Clicks at coordinates |
| DirectInput keystrokes | Sends DirectInput keystrokes (e.g. |
| Visual diff & text check | Computes visual state difference and optional expected text verification. |
| Backward-compatible alias | Legacy alias for visual state change verification. |
| Safety killswitch | Instant emergency killswitch halting all inputs and rejecting subsequent actions. |
| Privacy-first dataset | Opt-in recording of annotated game frames to |
๐ฎ Game Skills Architecture (Modular & Independent)
The game_skills/ directory provides game-independent declarative manifests, UI selectors, templates, and macro skills:
game_skills/
โโโ README.md # Architecture and specifications
โโโ _template/ # Starter template for new games
โ โโโ manifest.json # Versioned manifest schema (1.0.0)
โ โโโ skills/ # Atomic skills (e.g. example_skill.json)
โ โโโ selectors/ # Visual and OCR selectors (e.g. example_selector.json)
โ โโโ templates/ # CV image templates
โโโ hoi4/ # Hearts of Iron IV reference pack
โโโ manifest.json # HOI4 metadata, process names, resolutions
โโโ README.md # HOI4 reference pack documentation
โโโ skills/ # pause_unpause, open_production, select_army_group, increase_speed
โโโ selectors/ # topbar_factories, political_power, pause_button, army_group_leader
โโโ templates/ # PNG templates for template matching
โโโ tests/ # Manifest validation fixturesReference Pack: HOI4 is the first reference game pack, not a dependency of MCP Core.
Dynamic Selectors: Avoids hardcoding screen pixel coordinates; resolves elements dynamically.
Strict Verification: Never reports success based solely on whether a mouse click was sent; compares pre/post frames.
Ambiguity Rejection: Rejects ambiguous targets and outputs structured
VisionAgentEscalationpayloads when uncertain.V1.5 Contract Preparation: Defines lightweight interface specifications for Registry, Knowledge Storage, and Navigation Graph without early implementation.
๐ Quickstart
1. Installation
Requires Python 3.12 on Windows 10/11 x64:
# Clone or enter directory
cd universal-game-mcp
# Create Python 3.12 virtualenv
uv venv --python 3.12 .venv
# or: python -m venv .venv
# Activate virtualenv
.\.venv\Scripts\activate
# Install pinned dependencies
pip install -r requirements.txt2. Generate Test Fixtures & Icons
python scripts/generate_fixtures.py3. Run Automated Tests (No Game Required)
pytest -vAll 58 unit and integration tests run entirely offline using image fixtures.
4. Run the CPU Latency & RAM Benchmark
python scripts/benchmark_cpu_ram.py5. Run the End-to-End Offline Demo
If you do not have Hearts of Iron IV installed, run the self-contained offline simulator demo:
python scripts/demo_offline_sim.pyOr launch the interactive Tkinter game simulator:
python scripts/offline_game_sim.py6. Starting the MCP Server
# Run with stdio transport (for Claude Desktop, Cursor, or Antigravity MCP)
python -m ugm.serverConfiguration snippet for Claude Desktop or MCP client config (mcpServers):
{
"mcpServers": {
"universal-game-mcp": {
"command": "C:\\Users\\<USER>\\...\\universal-game-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "ugm.server"]
}
}
}๐ Safety and Compliance
Offline & Single Player Only: UGM is exclusively created for offline, single-player games and educational testing.
Zero Anti-Cheat Bypass: UGM includes a built-in process blacklist checking for anti-cheat services. Any detection triggers an immediate emergency shutdown.
Dry-run First: AI agents are encouraged to run actions with
dry_run=Truebefore issuing live inputs.
๐ License
Source code authored for UGM is licensed under the MIT License.
Third-party dependencies are acknowledged in THIRD_PARTY_LICENSES.md.
This server cannot be deployed
Maintenance
Related MCP Connectors
Savecraft serves real save game data and expert game knowledge to AI assistants.
- Shiny GenOAuthai.shinygen
AI game maker: build, run, screenshot and play-test Godot and retro console games in a live project
Create, test and play AI-native games through server-authoritative contracts.
Game observability for coding agents: stutters, crashes, custom metrics, dashboards, playtest bots
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to remotely control gaming PCs for automated gameplay with tools for screen capture, mouse/keyboard control, workflows, and system operations.1MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to play local Windows games through low-level keyboard/mouse input, screen capture, OCR, and per-game profiles for semantic actions.-
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to autonomously control Windows 11 and 10 desktops via sub-10ms screen capture, native UI Automation element inspection, and zero-lag keyboard and mouse input. Combines a visual plane with a semantic plane and stall detection so agents can operate real applications reliably without vision-only guessing.0278 PyPI5MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to interact with running games in real time โ introspecting game state, simulating keyboard and mouse input to actually play, capturing screenshots, executing Lua code, hot-reloading files, and receiving push notifications when state changes.8MIT