Pult Agent
README.md
# Pult Agent
**Pult Agent** is a local Windows MCP server for guarded desktop control. It combines PyAutoGUI for mouse input, OpenCV for screen-template matching, and an Esc kill-switch. A host agent connects over **stdio**; no control port is opened on the network.
## Quick start
1. Install 64-bit Python 3.11+ and Git. Python 3.14 was verified during this build. Keep the target application open.
2. Open PowerShell in this repository:
```powershell
py -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install -e .
```
3. Register the server with Codex. Replace `Roblox Studio` with a distinctive fragment of the target application's window title:
```powershell
codex mcp add pult-agent --env "PULT_ALLOWED_WINDOW_TITLE=Roblox Studio" -- "C:\Users\HP\Documents\Pult-Agent\.venv\Scripts\python.exe" -m pult_agent.server
codex mcp list
```
If the repository is in another folder, update the Python executable path. Restart Codex after registering the server.
4. Focus the target application, then ask the agent:
```text
Use Pult Agent. Call pult_status, then capture_screen. Do not click until I approve the target and you have a fresh screen_id. After each UI action, capture again and verify the resulting state.
```
5. Press **Esc** at any time to disarm all input. Restart the MCP server to re-arm it. `pult_stop` also disarms it.
## What the agent gets
| MCP tool | Purpose | Guard |
| --- | --- | --- |
| `pult_status` | Screen size, cursor, foreground window, safety state | Read only |
| `capture_screen` | Fresh screen ID, metadata, and image in one response | Allowed foreground app only |
| `move_mouse` | Move to `(x, y)` | Latest screen ID, age ≤ 10 s, bounds check |
| `click_at` | Send one left/right/middle click | Same fresh-screen and foreground checks; no retry |
| `drag_exact` | Bounded drag between two points | Latest screen ID, bounds checks, ≤ 2 s, releases button in `finally` |
| `match_template` | OpenCV match against `templates/` | Safe filename, image type and size limits |
| `click_template` | Fresh match, then one click | Confidence threshold and foreground recheck |
| `pult_metrics` | Recent step IDs, durations, outcomes | Read only |
| `pult_stop` | Set the process-wide stop flag | One-way until server restart |
## Safety contract
- The foreground-window title must contain `PULT_ALLOWED_WINDOW_TITLE`; otherwise input fails closed. The server never focuses, launches, or switches applications.
- `pyautogui.FAILSAFE = True` and `pyautogui.PAUSE = 0.02` are set at controller initialization.
- The global Esc listener is started **before** the stdio MCP loop. It blocks subsequent actions once observed. PyAutoGUI/Windows calls already in progress cannot be guaranteed to abort in the middle; movement durations are bounded and drag is intentionally not exposed.
- A click is sent once and is never automatically retried. The caller must capture a new screen and verify the result before deciding what to do next.
- Coordinates must be within the current desktop bounds and derived from the latest `capture_screen` result. A new capture invalidates the prior screen ID. Screen IDs expire after 10 seconds.
- OpenCV templates must be placed under `templates/`. The tool accepts only a filename, not a path. Use a close crop of a stable UI element; avoid text, animated areas, and overlapping controls.
- MCP stdio uses stdout as the protocol stream. Logs go to stderr. Do not add `print()` calls to startup code.
- Screen captures and template images may contain private data. They remain local unless the MCP host sends tool results to a remote service.
## Documentation
- [Русский: быстрый старт](docs/ru/QUICKSTART.md)
- [Русский: протокол работы агента и инструменты](docs/ru/AGENT-PROTOCOL.md)
- [Русский: безопасность и устранение ошибок](docs/ru/SAFETY-TROUBLESHOOTING.md)
- [English: Quick start](docs/en/QUICKSTART.md)
- [English: Agent protocol and tool reference](docs/en/AGENT-PROTOCOL.md)
- [English: Safety and troubleshooting](docs/en/SAFETY-TROUBLESHOOTING.md)
- [Instructions for a consuming agent](AGENTS.md)
## Requirements and limits
- Windows 10/11 desktop session, Python 3.11+ (64-bit), visible interactive desktop, and a local MCP host that supports stdio.
- The screen must not be locked. UAC secure-desktop prompts, elevated-vs-non-elevated process isolation, remote sessions, and multi-monitor DPI scaling can prevent input or shift coordinates. Keep the host and target app at the same privilege level and verify the reported screen dimensions.
- This project is an execution bridge, not a guarantee that a click caused the intended application state. The agent must inspect a fresh screenshot or app-specific state after each mutation.
- There is no bundled HUD/GUI. The agent calls MCP tools; this repository is the controller service.
## Development
```powershell
py -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .
.\.venv\Scripts\python.exe -m pult_agent.server
```
The final command waits for an MCP host on stdin/stdout. It appears idle when launched by itself; that is normal for stdio transport. Do not run the controller against a live desktop unless the intended app is focused and the window-title guard is configured.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues