Metadata-Version: 2.5
Name: simrig-mcp
Version: 0.1.1
Summary: MCP servers for sim racing on Windows: Assetto Corsa / CSP / Content Manager config and Pimax VR headsets.
Project-URL: Homepage, https://github.com/luangrezende/simrig-mcp
Project-URL: Issues, https://github.com/luangrezende/simrig-mcp/issues
Project-URL: Guide, https://github.com/luangrezende/simrig-mcp/blob/main/docs/assetto-corsa-csp-openxr-eye-tracked-vrs.md
License-Expression: MIT
License-File: LICENSE
Keywords: assetto-corsa,content-manager,csp,mcp,openxr,pimax,sim-racing,vr
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Games/Entertainment :: Simulation
Requires-Python: >=3.10
Requires-Dist: mcp>=1.2
Description-Content-Type: text/markdown

# simrig-mcp

[![CI](https://github.com/luangrezende/simrig-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/luangrezende/simrig-mcp/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Two [MCP](https://modelcontextprotocol.io) servers that let an AI assistant (Claude Code, Claude Desktop, Cursor, ...)
work on a Windows sim racing rig the way a careful engineer would: read the real configuration, change one thing,
keep a backup, measure, and roll back if it got worse.

| Server | What it does |
|---|---|
| **`ac-config-mcp`** | Reads and edits **Assetto Corsa**, **Custom Shaders Patch** and **Content Manager** configuration: `video.ini`, CSP overrides, Pure config, CM video/CSP presets, post-processing filters, Python/Lua apps, mod install from a zip. Every write is backed up and undoable. |
| **`pimax-mcp`** | Reads and adjusts a **Pimax** headset through the official Pimax Play CLI, and parses the Pimax runtime logs for what the CLI does not show: the render settings actually in effect per game, and per-session app/compositor FPS with missed, stale and discarded frames. |

## Why I built this

I'm a huge sim racing fan. My rig is a Fanatec direct drive wheel, a Pimax Crystal in VR and a SimHub setup with
bass shakers, vibration motors, wind and an active belt tensioner, mostly driving Assetto Corsa with CSP.

Anyone with a rig like that knows the pain: hundreds of settings spread across `video.ini`, CSP overrides, Content
Manager presets, Pimax Play and the runtime, and every forum thread swears by a different combination. I wanted an
AI assistant to help me tune it like an engineer would: look at the real config, change one thing at a time,
measure, and roll back if it got worse. So I built these servers to give it exactly that, safely.

The first thing it helped me find was something I couldn't find written anywhere: a guide to
[running AC in CSP's native OpenXR mode with eye-tracked foveated rendering on a Pimax](docs/assetto-corsa-csp-openxr-eye-tracked-vrs.md).
I'm sharing it all in case it saves other sim racers some evenings of trial and error.

## Why not just edit the files?

You can. The point is letting an assistant do it **safely**:

- **Backup before every write**, one folder per change with a manifest, plus a JSON-lines `changes.log`.
- **`ac_undo`** restores any backup (and backs up the current state first, so undo is undoable).
  Files a change created are removed on undo.
- **Edits are surgical**: comments, BOM and CRLF line endings survive; only the key you set changes.
- **Paths are fenced** to known roots and text extensions. No `..`, no executables, no arbitrary files.
- **Mod install is dry-run by default**, refuses zip-slip paths, never copies `.exe/.dll/.bat/.ps1/...`,
  and refuses to run while the game is open.
- **Pimax changes need `confirm=True`**, which the tool description tells the model to pass only after you approve.
  Values are validated against a closed list.
- **Read-only mode**: set `AC_CONFIG_MCP_READ_ONLY=1` / `PIMAX_MCP_READ_ONLY=1` and the write tools are not even registered.

## Requirements

- Windows, Python 3.10+
- `ac-config-mcp`: Assetto Corsa (Steam). CSP and Content Manager are optional but most tools assume them.
- `pimax-mcp`: Pimax Play running (tested with Pimax Play 2.0.4 and a Crystal OG). The CLI ships with Pimax Play.

## Install

Published on [PyPI](https://pypi.org/project/simrig-mcp/) and in the official
[MCP Registry](https://registry.modelcontextprotocol.io) as `io.github.luangrezende/ac-config-mcp` and
`io.github.luangrezende/pimax-mcp`. With [uv](https://docs.astral.sh/uv/) there is nothing to install by hand:
the client runs `uvx simrig-mcp acconfig` / `uvx simrig-mcp pimax`.

### Claude Code

```powershell
claude mcp add acconfig -- uvx simrig-mcp acconfig
claude mcp add pimax -- uvx simrig-mcp pimax
```

### Any MCP client (JSON)

```json
{
  "mcpServers": {
    "acconfig": { "command": "uvx", "args": ["simrig-mcp", "acconfig"] },
    "pimax":    { "command": "uvx", "args": ["simrig-mcp", "pimax"] }
  }
}
```

Without uv: `pip install simrig-mcp` puts `ac-config-mcp` and `pimax-mcp` on your PATH.
From source: `git clone https://github.com/luangrezende/simrig-mcp`, then `uv sync` (servers end up in `.venv\Scripts\`).

<!-- mcp-name: io.github.luangrezende/ac-config-mcp -->
<!-- mcp-name: io.github.luangrezende/pimax-mcp -->

## Configuration

Everything is auto-detected; override only if needed.

| Variable | Default |
|---|---|
| `AC_ROOT` | Steam library containing `steamapps\common\assettocorsa` (reads `libraryfolders.vdf`) |
| `AC_DOCUMENTS` | `<Documents>\Assetto Corsa` (follows OneDrive folder redirection) |
| `CM_PRESETS` | `%LOCALAPPDATA%\AcTools Content Manager\Presets` |
| `AC_CONFIG_MCP_HOME` | `%LOCALAPPDATA%\ac-config-mcp` (backups and `changes.log`) |
| `AC_CONFIG_MCP_READ_ONLY` | off |
| `PIMAX_CLI` | `%ProgramFiles%\Pimax\PimaxClient\pimaxui\resources\pimaxcli\pimax.exe` |
| `PIMAX_MCP_HOME` | `%LOCALAPPDATA%\pimax-mcp` (`changes.log`) |
| `PIMAX_MCP_READ_ONLY` | off |

## Tools

### ac-config-mcp

Files are addressed as `<root>/<relative path>`:
`cfg/` (Documents\Assetto Corsa\cfg), `ext/` (CSP overrides), `pure/`, `sys/` (game `system\cfg`),
`apps/`, `extcfg/` (`extension\config-ext`), `acroot/` (only `opencomposite.ini`).

| Read | Write (backup + log + undo) |
|---|---|
| `ac_status` - AC/CM running, roots, last changes | `ac_set`, `ac_set_many` - set ini keys |
| `ac_list_files`, `ac_read` - ini files as values | `ac_apply_video_preset`, `ac_save_video_preset` |
| `ac_csp_doc` - CSP default + inline docs + your override | `ac_apply_csp_preset`, `ac_save_csp_preset` |
| `ac_list_presets`, `ac_read_video_preset` | `ac_set_pp_filter`, `ac_set_python_app` |
| `ac_list_pp_filters`, `ac_list_apps` | `ac_write_text`, `ac_replace_text` - Lua/Python/config text |
| `ac_read_text`, `ac_list_backups` | `ac_install_mod` (dry run by default), `ac_undo` |

Notes: Content Manager does not watch these files, so an open CM may show old values until it reloads.
With AC running, most changes apply on the next session.

### pimax-mcp

| Tool | Source |
|---|---|
| `pimax_status`, `pimax_doctor` | Pimax CLI |
| `pimax_settings` | Pimax CLI: quality, brightness, local dimming, overlay scale, eye tracking |
| `pimax_runtime_state` | PiService log: per-app render scale, FOV, foveated/quad views, smart smoothing, upscaling actually read by the runtime |
| `pimax_runtime_stats` | Compositor log: app vs compositor FPS, % missed frames, stale/discarded, GPU%/CPU% per session (`exe="acs"` for AC) |
| `pimax_set` | Pimax CLI, closed list of settings, `confirm=True` required |

Refresh rate, FOV, foveated rendering and Smart Smoothing are not exposed by the Pimax CLI; change them in Pimax Play.
The PimaxClient `config.json` (login token) is never read.

## Example session

> "AC in VR feels choppy on the straight after turn 1. Check what the Pimax runtime is doing and suggest one change."

The assistant reads `pimax_runtime_stats(exe="acs")` (missed frames, GPU%), `pimax_runtime_state` and
`ac_read("ext/vr_tweaks.ini")`, proposes a single change, applies it with `ac_set` after you agree, and after
your next stint compares the stats again. If it got worse: `ac_undo`.

## Development

```powershell
uv sync
uv run pytest
uv run ruff check .
```

Tests run against temporary folders and fake processes; they never touch a real game or headset.

## License

MIT. Not affiliated with Kunos Simulazioni, Ilja Jusupov (CSP / Content Manager) or Pimax.
