war-thunder-cdk
# wt-cdk-mcp
An [MCP](https://modelcontextprotocol.io) server and [Claude](https://claude.com/claude-code) skill for creating, editing and validating **War Thunder CDK mission files** (`.blk`).
Ask Claude for "a Bulge mission where I fly a P-39 through three waypoints, then kill four fighters" and it builds a valid mission file, checking every trigger against the real Mission Editor definitions.
> **Unofficial.** Not affiliated with or endorsed by Gaijin Entertainment. War Thunder is a trademark of Gaijin Entertainment. This repo contains **no game files**; it reads the CDK you have installed.
## Requirements
- War Thunder + the **WarThunderCDK** installed inside the game folder
- Python 3.10+
### Platforms and non-default installs
The default game folder is the Windows Steam path `C:\Program Files (x86)\Steam\steamapps\common\War Thunder`. For anything else set the **`WT_DIR`** environment variable (in your MCP config `env`) to the game folder, i.e. the one that contains `UserMissions` and `WarThunderCDK`:
| Install | Typical `WT_DIR` |
|---|---|
| Windows, Steam (other drive) | `D:\SteamLibrary\steamapps\common\War Thunder` |
| Windows, standalone launcher | `C:\Program Files (x86)\WarThunder` (or wherever you installed it) |
| Linux, native Steam | `~/.local/share/Steam/steamapps/common/War Thunder` |
| Linux, Proton / Flatpak Steam | `~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/War Thunder` |
Notes: the server only reads and writes plain files, so it runs anywhere Python does; the mission *editor* itself (`missioned.cmd`) is Windows-only (use Proton/Wine to run it). The element definitions are read from the CDK's `windows-x86_64` folder, so the CDK must be present in the game folder. On Linux/macOS use `python3` as the MCP `command` if `python` does not exist. Missions are written to `<WT_DIR>/UserMissions`; pass an absolute path to any tool to save elsewhere.
## Quick install (let your agent do it)
Paste this into your coding agent (Claude Code etc.):
> Install the War Thunder CDK MCP server and skill from https://github.com/kmanb44/wt-cdk-mcp: clone the repo, then run `python -m pip install -e .` in it with the Python you will register (note its absolute path, e.g. `python -c "import sys; print(sys.executable)"`). Register the MCP server `war-thunder-cdk` in my MCP client config (Claude Code: `claude mcp add war-thunder-cdk --scope user -e WT_DIR="<my War Thunder install folder>" -- <that absolute python path> -m wt_cdk_mcp.server`; Claude Desktop: the `mcpServers` section of `claude_desktop_config.json`), and copy `.claude/skills/war-thunder-cdk` into my skills folder (Claude Code: `~/.claude/skills/`). Ask me for the War Thunder install folder if you can't find it (it contains `UserMissions` and `WarThunderCDK`). Ignore harmless git/pip progress text that shows as errors in PowerShell. Finally tell me to restart the client and check that the `wt_*` tools appear.
## Setup
```powershell
pip install -e .
```
Open this folder in Claude Code; the project-level `.mcp.json` registers the server automatically (only while working in this folder). If your game is elsewhere, set `WT_DIR` in the MCP config's `env` (a shell `$env:WT_DIR` only affects processes started from that shell, not an MCP client's server):
```powershell
$env:WT_DIR = "C:\Program Files (x86)\Steam\steamapps\common\War Thunder"
```
To use it from another project or Claude Desktop, add to your MCP config (use the absolute path of the Python you ran `pip install -e .` with if it is a venv; Claude Code skills live in `~/.claude/skills/`):
```json
{ "mcpServers": { "war-thunder-cdk": { "command": "python", "args": ["-m", "wt_cdk_mcp.server"], "env": { "WT_DIR": "C:\\path\\to\\War Thunder" } } } }
```
and copy `.claude/skills/war-thunder-cdk` into your skills folder.
## Tools
| Tool | Purpose |
|---|---|
| `wt_list_catalog`, `wt_get_scheme` | Valid actions / conditions / events / units and their parameters |
| `wt_list_missions`, `wt_list_levels` | Find missions and maps |
| `wt_summarize_mission`, `wt_read_block` | Read a mission |
| `wt_new_mission`, `wt_add_unit`, `wt_add_area`, `wt_add_trigger`, `wt_add_objective` | Build a mission |
| `wt_add_squad`, `wt_add_player_wings`, `wt_configure_multiplayer` | Spawn groups, player slots, PvP settings |
| `wt_build_custom_battle` | One-call 24/7 PvP mission with a no-weapons chill zone, infinite ammo and objectives |
| `wt_set_value`, `wt_add_block`, `wt_remove` | Generic edits |
| `wt_validate_mission` | Check settings, player, trigger types/params/enums, target names |
## How it works
- `blk.py` parses/serializes Dagor BLK text (round-trips 99.6% of the .blk files shipped with the CDK; the rest are terrain assets).
- `schemes.py` reads the editor's `*.scheme.nut` definitions so element names and parameters are never guessed.
- `missions.py` builds and validates mission structures; `server.py` exposes them as MCP tools.
## Caveats
- **Tested by hand on one map.** `wt_build_custom_battle` was tuned in a live custom battle on `levels/avg_container_port.bin`. Other maps need their own coordinates (pass `pvp_x/pvp_z` and `chill_x/chill_z`).
- The tools cannot read terrain or map bounds, so spawn heights and positions are guesses: if you see "No respawn base to start", move that spawn zone onto valid ground inside the map (editor: Ctrl+Alt+D drops an object to the ground).
- The automated tests cover the file format and the recipe producing a valid file; game behaviour itself is only verified by playing the mission.
- Writes create a `.bak` copy first; comments in the original file are not preserved and formatting is normalised.
- Zone scale encoding (sphere/cylinder/box) is unverified outside the editor.
- The tools can't launch the game; open results in the Mission Editor (`missioned.cmd`) to confirm.
## Development
```powershell
pip install -e ".[dev]"
pytest
```
## License
MIT
TDQS
Scored across 19 tools
Most tools target distinct operations (read_block vs add_block vs set_value vs remove), and the domain-specific adders (add_area, add_unit, add_trigger, add_objective) are clearly separated. Some overlap exists between the generic block tools and the specialized adders, and wt_build_custom_battle duplicates a whole chain of other tools, but descriptions make the intended usage clear.
All tools share a wt_ prefix and snake_case verb_noun pattern (wt_add_unit, wt_list_levels, wt_validate_mission), which is highly predictable. Minor deviations like wt_remove (verb only) and wt_new_mission using 'new' instead of 'add'/'create' keep it just shy of perfect.
19 tools is on the heavier side, but each maps to a genuinely distinct operation in a complex schema-driven mission editor (catalog lookup, block CRUD, entity adders, multiplayer setup, validation). Nothing feels obviously redundant except the composite wt_build_custom_battle, which is justified as a recipe.
The surface covers the full lifecycle: list levels/missions, create, read, summarize, edit blocks/values, add units/areas/squads/triggers/objectives, configure multiplayer, validate, and a one-call build recipe. Gaps are minor — no explicit mission delete/rename or targeted trigger/unit edit beyond generic block operations, which agents can work around.