中文 README: README.zh-CN.md
Balatro MCP is a Steamodded Balatro mod plus MCP server inspired by the architecture of STS2-Agent.
The in-game mod exposes Balatro state and actions through a local HTTP API on http://127.0.0.1:8080. The Python package in mcp_server/ wraps that API as MCP tools for AI clients.
GET /healthGET /stateGET /actions/availablePOST /action
MCP tools:
health_checkget_game_stateget_raw_game_stateget_available_actionslist_legal_actionsactwait_until_actionablecontinue_runchoose_optionchoose_blindskip_choiceselect_carddeselect_cardplay_handdiscard_selectedend_turnbuy_itemreroll_shopsell_jokeruse_consumableget_action_historyget_run_summary
The validation scripts default to:
D:\SteamLibrary\steamapps\common\BalatroInstall Lovely and Steamodded first. Then run:
powershell -ExecutionPolicy Bypass -File scripts\install-local.ps1 -BalatroPath "D:\SteamLibrary\steamapps\common\Balatro"powershell -ExecutionPolicy Bypass -File scripts\start-mcp-stdio.ps1For network MCP:
powershell -ExecutionPolicy Bypass -File scripts\start-mcp-network.ps1The generic MCP act tool accepts the action name plus optional arguments:
{"action": "start_run", "stake": 1}
{"action": "select_blind"}
{"action": "play_hand", "card_indices": [1, 2, 3, 4, 5]}
{"action": "discard", "card_indices": [6, 7]}
{"action": "buy", "area": "shop_jokers", "index": 1}
{"action": "use", "area": "consumeables", "index": 1, "card_indices": [1]}For MCP clients that prefer task-shaped tools, the explicit tools wrap the same action layer:
{"tool": "continue_run", "stake": 1}
{"tool": "choose_blind", "option_id": "small"}
{"tool": "select_card", "index": 2}
{"tool": "play_hand", "card_indices": [1, 2, 3, 4, 5]}
{"tool": "buy_item", "area": "shop_jokers", "index": 1}
{"tool": "use_consumable", "index": 1, "card_indices": [1]}Card, joker, shop, and consumable indexes are 1-based and come from get_game_state.
Static and MCP tests:
pytest tests/test_lua_static.py -q
cd mcp_server
uv run pytest -qLocal structure validation:
powershell -ExecutionPolicy Bypass -File scripts\validate-local.ps1 -SkipGameLaunchIn-game smoke test:
powershell -ExecutionPolicy Bypass -File scripts\validate-local.ps1 -LaunchGameBalatro MCP is directly inspired by CharTyr/STS2-Agent. Thanks to CharTyr and the STS2-Agent project for demonstrating the practical mod-plus-MCP architecture this project adapts for Balatro.
This project also depends on the Balatro modding ecosystem built by Steamodded/smods and Lovely Injector. Thanks to those projects for making Lua-side Balatro mod loading and extension possible.
This project is licensed under the MIT License. See LICENSE.