52 lines
2.2 KiB
Markdown
52 lines
2.2 KiB
Markdown
# VM302 — pyautogui-server persistent als user mcp (2026-07-19)
|
|
|
|
## Ziel
|
|
`pyautogui-server` (Screen-Automation via HTTP) muss auf VM302 IMMER laufen — nach Reboot, Crash, Session-Ende. Läuft als user **mcp** in interaktiver Session (nicht matthias, nicht Session 0).
|
|
|
|
## Drei Bausteine
|
|
|
|
### 1. Scheduled Task `pyautogui-mcp` (der Server selbst)
|
|
```cmd
|
|
schtasks /Create /TN "pyautogui-mcp" ^
|
|
/TR "D:\Python311\python.exe C:\Users\mcp\pyautogui-server-v2.py" ^
|
|
/SC ONLOGON /RU mcp /RP "<pw>" /RL HIGHEST /IT /F
|
|
```
|
|
- **`/IT` ist essentiell** — sonst läuft der Prozess in Session 0 (services) und Screenshots kommen leer (21 Bytes) zurück
|
|
- ONLOGON feuert jedes Mal wenn mcp sich anmeldet
|
|
|
|
### 2. AutoLogon für mcp (damit mcp nach Reboot automatisch angemeldet ist)
|
|
Registry `HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon`:
|
|
- `AutoAdminLogon` = `"1"`
|
|
- `DefaultUserName` = `"mcp"`
|
|
- `DefaultPassword` = `"<pw>"` (String, Klartext)
|
|
- `DefaultDomainName` = Hostname
|
|
- `AutoLogonCount` = `0` (DWord, unbegrenzt)
|
|
|
|
**Sicherheits-Note:** Passwort Klartext in Registry. Mit Sysinternals `autologon.exe` als LSA-Secret ablegbar (später härten).
|
|
|
|
### 3. Watchdog `pyautogui-mcp-watchdog`
|
|
```cmd
|
|
schtasks /Create /TN "pyautogui-mcp-watchdog" ^
|
|
/TR "powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\Users\mcp\pyautogui-watchdog.ps1" ^
|
|
/SC MINUTE /MO 5 /RU SYSTEM /RL HIGHEST /F
|
|
```
|
|
Watchdog-Script prüft alle 5 Min `http://localhost:3336/health` (mit Bearer-Token), restartet die Task bei Fehler. Log: `C:\Users\mcp\pyautogui-watchdog.log`.
|
|
|
|
## Endpoint
|
|
- Base URL lokal: `http://localhost:3336`
|
|
- Via Tailscale: `http://100.104.5.57:3336`
|
|
- Auth-Header: `Authorization: Bearer sk-pyautogui-vm302-e7f9a3b1c4d8e5f2a9b6c1d4e7f0a3b6`
|
|
- Health-Response MUSS `"user":"mcp"` enthalten — sonst läuft's in falscher Session
|
|
|
|
## Endpoints
|
|
- `GET /screenshot` — PNG raw
|
|
- `POST /click` — {x, y}
|
|
- `POST /type` — {text}
|
|
- `POST /hotkey` — {keys: [...]}
|
|
- `POST /goto` — {url}
|
|
- `POST /batch` — [actions]
|
|
- `GET /health`
|
|
|
|
## RDP Wrapper Kompatibilität
|
|
Parallel-Sessions gehen: mcp (Console/AutoLogon Session 1) + matthias (RDP Session 2/3) gleichzeitig. RDP Wrapper ist installiert und funktioniert.
|