Skip to main content
Glama
brotato-controller

brotato-controller

by dzhen1515

auto-brotato-agent-kit

把原版《土豆兄弟(Brotato)》變成 AI Agent 可直接操作的結構化 MCP 服務。

跨機器、跨 Harness(Claude Code / Cursor / Antigravity / Codex)可復用的自動通關 MCP 套件,支援原版 v1.0–v1.2.0.4(Steam 版)。 不需要任何第三方工作坊 Mod——只需部署本套件自帶的 LocalAI-AgentBridge v0.5.5 通訊橋接器。

項目

值

GitHub 倉庫

auto-brotato-agent-kit

Python 套件名

brotato-agent-kit

CLI 指令

brotato-kit

橋接器版本

LocalAI-AgentBridge v0.5.5(AgentBridge Protocol v1)

Python

>= 3.11(.python-version 指定 3.12)

唯一第三方依賴

mcp>=2.3,<3(僅 MCP stdio 伺服器使用)


目錄


Related MCP server: battle-arena-mcp

這是什麼

本專案讓 AI Agent 能自動遊玩並通關《土豆兄弟》。做法是:不讓 AI 看遊戲畫面,而是把遊戲內部狀態暴露成結構化資料。

  • 遊戲內部署 LocalAI-AgentBridge 橋接器,將玩家屬性、敵人位置、商店、升級選項、陣亡原因等以 JSON 即時輸出。

  • 由兩套 MCP Server 包裝成 Agent 可直接呼叫的工具:brotato-controller(控制)與 brotato-rag(知識檢索)。

  • 高頻走位(60Hz)交給橋接器內建的威脅度熱力圖演算法,LLM 只負責慢決策:買什麼、選什麼、策略哪裡出錯。

  • AI 可在執行期透過 manage_extensions 自我發現並聲明式拓展策略與行為邏輯。

結果:LLM 不需要看圖、不需要 GPU,每秒數十次的微操完全由本機處理。


架構總覽

┌──────────────────────────────────────────────────────────────┐
│   Agent Harness(Claude Code / Cursor / Antigravity / Codex)  │
└───────────────────────────────┬──────────────────────────────┘
                                │ MCP stdio
                                │ brotato-kit mcp controller / brotato-kit mcp rag
          ┌─────────────────────┴─────────────────────┐
          ▼                                           ▼
┌──────────────────────────┐              ┌──────────────────────────┐
│   brotato-controller     │              │       brotato-rag        │
│   16 工具 · Detached Job  │              │  2 唯讀工具               │
│   50 角色內建策略          │              │  search_wiki / get_page  │
│   manage_extensions 拓展  │              └────────────┬─────────────┘
│   plugins.py entry_points│                           │ SQLite FTS5
└────────────┬─────────────┘                           │ + 中英雙語詞典
             │ AgentBridge Protocol v1                  ▼
             │ (本機 TCP NDJSON · Token · 控制租約)  ┌──────────────────────────┐
             ▼                                    │  隨包離線 Wiki 語料        │
┌──────────────────────────┐                      │  595 篇 .md(純文本)      │
│ LocalAI-AgentBridge      │                      │  零圖片/零向量化/零 GPU   │
│ v0.5.5(Godot ModLoader)│                      └──────────────────────────┘
│ + 60Hz 威脅度熱力圖走位    │
└────────────┬─────────────┘
             ▼
   《土豆兄弟》原版 v1.0–v1.2.0.4(Steam)

分工:controller 負責「動」遊戲,rag 負責「查」知識;兩者互不依賴。


四大核心能力

1. LocalAI-AgentBridge v0.5.5(遊戲內橋接器)

  • AgentBridge Protocol v1:本機 TCP NDJSON 通訊、Token 認證、控制租約、client_id 跨重連冪等、env_capabilities 能力偵測(max_weapons、dlc_ids、loaded_mods)。

  • 60Hz 威脅度熱力圖自動走位,參數可透過 set_threat_config 動態調整(如 prefer_stationary、greed、kite_radius、prefer_perimeter)。

  • 透過 brotato-kit deploy-mod 部署至遊戲內建的 Godot ModLoader 6.0.0,無需任何第三方工作坊 Mod。

2. brotato-controller MCP(遊戲控制層)

  • 16 個結構化工具,非同步防阻塞設計。

  • Detached Job:start_session 以獨立子程序背景執行長跑,立即回傳 job_id,不會觸發 MCP 逾時。

  • 50 個全角色內建策略,支援 dry_run 預覽 diff、expect_base 樂觀鎖套用與回滾。

  • 結構化死因遙測(get_recent_deaths)。

類別

工具

狀態查詢

ping_game、get_game_state、inspect_game、get_runner_status、get_recent_deaths、get_strategy

單局控制

run_control、wait_for_phase、decide_wave_reward、shop_action、set_threat_config

長跑調度

start_session、stop_session

策略拓展

update_strategy、rollback_strategy、manage_extensions

3. brotato-rag MCP(離線知識層)

  • 2 個純文本唯讀工具:search_wiki、get_page。

  • 以 Python 標準庫 SQLite FTS5 + 中英雙語詞典檢索隨包附帶的 595 篇官方 Wiki .md。

  • 零圖片、零向量化、零 GPU,不需任何機器學習套件或語料更新爬蟲;若 Python 未編譯 FTS5,自動退回純 Python BM25。

4. AI 運行期高拓展性

任何 AI 接入後先呼叫 manage_extensions(action="schema") 自我發現:取得所有 kind、behavior hooks(含範本)、條件語言合法變數/函式(ALLOWED_VARS / ALLOWED_FUNCS)、威脅設定鍵範圍與 macro ops。

kind

用途

strategy / patch / profile

角色策略、局部補丁、設定檔

behavior

決策掛鉤:combat_policy、shop_item_bonus、upgrade_bonus、item_box_override、shop_reroll_rule、shop_lock_rule、death_diagnosis

macro

聲明式多步驟安全巨集(≤ 20 步、無迴圈、無遞迴、白名單 op,預設 execute=False 僅規劃不寫入)

標準工作流程:schema → validate(迭代至合法)→ upsert(dry_run=True) 取得 base_version → upsert(dry_run=False, expect_base=...) → 必要時 rollback(steps=1)。

所有 when 條件由白名單 AST 直譯器評估(禁止屬性存取、下標、lambda、import)。此外亦支援透過 plugins.py 的 entry_points 外掛機制擴充。完整規格見 docs/EXTENSIBILITY.md。


5 分鐘快速上手

前置條件

  1. 已透過 Steam 安裝原版《土豆兄弟》(v1.0–v1.2.0.4),且至少啟動過一次遊戲(建立 user:// 目錄)。

  2. 首次安裝需使用具備網路權限的終端機(Codex 沙盒請允許連網)。

步驟

# 1. 取得專案(勿從舊機器複製 .venv/)
git clone https://github.com/dzhen1515/auto-brotato-agent-kit.git
cd auto-brotato-agent-kit

# 2. 安裝 uv(若尚未安裝);安裝後請重啟 Harness 讓 PATH 生效
#    Windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
#    macOS / Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh

# 3. 安裝依賴並初始化
uv sync
uv run brotato-kit setup --check --json   # 檢查尚缺項目(依 steps[].next_action 處理)
uv run brotato-kit setup --yes            # 逐項套用(含部署 LocalAI-AgentBridge)
uv run brotato-kit doctor                 # 環境健檢
uv run brotato-kit launch                 # 啟動遊戲

若需單獨部署橋接器,可執行 uv run brotato-kit deploy-mod。

更省事的做法

在 Claude Code / Cursor / Antigravity / Codex 中開啟本專案資料夾,直接對 Agent 說 「初始化」,它會依 AGENTS.md 的首次啟動協議自動完成:

  1. uv --version(找不到則停止並提供官方安裝指令,Agent 嚴禁自行執行網路安裝腳本)

  2. uv sync

  3. uv run brotato-kit setup --check --json;needs_user=true 的步驟先取得使用者同意再帶 --yes 重跑

  4. needs_restart="harness" → 重新載入 MCP/重啟 Harness;needs_restart="game" → uv run brotato-kit launch

  5. 直到 ready=true 才開始呼叫遊戲控制工具


兩種操作模式

模式

適用情境

主要流程

A — Detached Runner 無人值守 + 總教練復盤(推薦)

自動刷完整局、陣亡後復盤修正

get_game_state(include=["progress"]) → search_wiki(...) → start_session(character_id, max_waves=20, danger=5) → get_runner_status(job_id)(必要時 stop_session)→ 陣亡後 get_recent_deaths(n=3) → update_strategy(..., dry_run=True) 或 manage_extensions(action="upsert", ...) 熱修正(可用 rollback_strategy 回退)

B — 逐波手動 MCP 控制

逐步觀察、精細微操

run_control(action="start", ...) → 迴圈 wait_for_phase(timeout_sec=25) → 依 phase 呼叫 decide_wave_reward(item_box / upgrade)或 shop_action + set_threat_config(shop);異常以 inspect_game 診斷

wait_for_phase 逾時回傳 reached: false 不算錯誤,可繼續等待。 詳細波次營運與走位原則見 skills/auto-brotato/SKILL.md(此技能僅在使用者明確點名 /auto-brotato 時啟用)。


文件導覽

文件

主要讀者

一句話說明

README.md(本文件)

所有人

專案定位、架構、快速上手與文件索引

AGENTS.md

Agent 必讀

首次啟動協議、禁止事項、兩種核心操作模式

CLAUDE.md

Claude Code 使用者

引用 @AGENTS.md;.mcp.json 核准載入、技能檔位置

docs/DEPENDENCIES.md

安裝與除錯者

依賴清單、版本需求、原版遊戲與橋接器說明

docs/HARNESS_GUIDE.md

跨 Harness 使用者

各家自動發現檔、設定匯出、逾時與診斷指令

docs/EXTENSIBILITY.md

拓展開發者/AI

manage_extensions 規格:kind、behavior hooks、macro

skills/auto-brotato/SKILL.md

Agent

通關策略技能:啟動檢查、調度模式、W1–20 營運原則

src/brotato_kit/_assets/wiki/NOTICE.md

所有人

隨包 Wiki 語料來源與 CC BY-SA 授權說明

Agent 禁止事項(摘自 AGENTS.md):禁止修改 repo 以外、setup 未列出的任何檔案;禁止在 repo 內寫入本機絕對路徑(路徑一律由 brotato-kit config show --resolved 解析)。


Harness 支援

所有 Harness 共用同一組 MCP stdio 入口(brotato-kit mcp controller、brotato-kit mcp rag)與 AGENTS.md 首次啟動協議。

重要:Harness 工具執行逾時上限請設為 ≥ 60 秒。長時間對局一律透過 Detached Job(start_session)背景執行,不會阻塞 MCP 連線。

Harness

狀態

專案內建自動發現檔

生效範圍

注意事項

Claude Code

✅

.mcp.json、CLAUDE.md、.claude/skills/auto-brotato/SKILL.md

專案級

首次開啟資料夾時請核准專案 MCP Server

Cursor

✅

.cursor/mcp.json、.cursor/rules/brotato.mdc、AGENTS.md

專案級

使用 ${workspaceFolder} 展開路徑;安裝 uv 後重啟 Cursor

Antigravity

✅

.agents/skills/auto-brotato/SKILL.md(專案級)+ ~/.gemini/config/mcp_config.json(使用者級)

混合

uv run brotato-kit setup --harness antigravity --yes 安全合併 brotato-* 項目,寫入前自動備份 .bak,絕不更動其他 MCP Server

Codex CLI

✅

.codex/config.toml(受信任專案)/~/.codex/config.toml、AGENTS.md

專案/使用者級

已內建 startup_timeout_sec = 60、tool_timeout_sec = 90;首次 uv sync 請允許沙盒連網

# 手動匯出各家 MCP 設定
uv run brotato-kit export-config --harness claude-code
uv run brotato-kit export-config --harness cursor
uv run brotato-kit export-config --harness antigravity
uv run brotato-kit export-config --harness codex

執行環境與依賴

組件

最低需求

說明

Python

>= 3.11(.python-version 指定 3.12)

uv 會自動下載對應版本;標準庫 tomllib 需 ≥ 3.11

套件管理

uv(推薦)或 pip >= 24

uv sync 安裝核心依賴,總體積 < 15 MB

Python 依賴

mcp>=2.3,<3

僅 MCP stdio 伺服器需要;brotato_kit.runner 與離線 FTS5 檢索為 100% 純標準庫

SQLite FTS5

內建於標準 sqlite3

brotato-kit doctor 自動檢測;不支援時自動退回純 Python BM25

遊戲本體

原版《土豆兄弟》v1.0–v1.2.0.4(Steam)

內建 Godot ModLoader 6.0.0;僅需以 brotato-kit deploy-mod 部署自帶的 LocalAI-AgentBridge.zip


設計原則

  1. 不打包任何二進位:無 Python 虛擬環境、無圖片素材、無外部執行檔、無向量資料庫或模型權重。

  2. 標準庫優先:Runner、FTS5 檢索、AST 條件求值均使用 Python 標準庫;唯一第三方依賴 mcp 僅用於 stdio 伺服器。

  3. 安全邊界明確:策略與拓展條件經白名單 AST 直譯器評估;寫入操作支援 dry_run、expect_base 與回滾;macro 預設僅規劃不寫入。

  4. 零第三方 Mod:只依賴原版遊戲內建 ModLoader 與本套件自帶橋接器。

  5. Harness 無關:同一組 MCP 入口與 AGENTS.md 協議,四家 Harness 共用。


疑難排解

症狀

處理方式

工具回傳 SETUP_REQUIRED

執行 uv run brotato-kit setup --check --json,依 steps[].next_action 處理後以 --yes 套用

工具回傳 GAME_NOT_RUNNING

執行 uv run brotato-kit launch

找不到 uv 指令

依官方指令安裝後重啟 Harness(Cursor 需重啟以套用 PATH)

工具呼叫逾時

確認 Harness 工具逾時 ≥ 60 秒;長跑改用 start_session

Codex 中 uv sync 失敗

允許沙盒連網後重試

新機器遊戲無法連線

確認已啟動過一次遊戲以建立 user://,再執行 uv run brotato-kit deploy-mod

精簡版 Python 缺 FTS5

自動退回純 Python BM25,功能不受影響

設定路徑或 Runner 異常

uv run brotato-kit config show --resolved、uv run brotato-kit doctor --runner-survival


聲明與授權

  • 本專案為非官方工具,與《土豆兄弟》開發團隊無任何關聯。

  • 僅支援原版 Steam 版 v1.0–v1.2.0.4;遊戲更新若變更相關 API,可能需等待套件跟進。

  • LocalAI-AgentBridge 透過本機 TCP 通訊(含 Token 認證與控制租約),請勿將該埠暴露至外部網路。

  • src/brotato_kit/_assets/wiki/ 內 595 篇 .md 為離線固定純文本語料(不含遊戲圖片素材與第三方工作坊 Mod 文件),整理自社群 Brotato Wiki(https://brotato.wiki.spellsandguns.com/),採 CC BY-SA(姓名標示—相同方式分享) 授權,原始貢獻者保留著作權。詳見 NOTICE.md。

  • 本專案原始碼授權見 LICENSE。

Available Tools

16 tools
decide_wave_rewardC
Destructive

Handle item_box (take|recycle) or upgrade (choose with index 0..3 | reroll).

Inputs: action (required), index.

get_game_stateA
Read-only

Get current Brotato state (compact summary by default; verbose=True or include=[progress|threats|inventory|shop]).

Inputs: include, verbose.

get_recent_deathsB
Read-only

Retrieve the N most recent structured death telemetry reports from state_dir.

Inputs: n.

get_runner_statusA
Read-only

Get status of a specific runner job_id, or summaries of the 5 most recent jobs if omitted.

Inputs: job_id.

get_strategyB
Read-only

Read the effective merged strategy (base ⊕ capability patches ⊕ overrides) and version hash.

Inputs: character_id (required).

inspect_gameB
Read-only

Inspect scene tree or singletons (bounded: max_depth<=6, max_nodes<=500, <=64KB).

Inputs: path, target, max_depth, max_nodes.

manage_extensionsA
    Discover, inspect, create, hot-update, delete, rollback, or run AI extensions under state_dir/extensions/.
    START HERE: action="schema" (kind optional) returns every kind, hook, condition variable/function,
    limit and a ready-to-edit template, so you never need to guess formats.
    - action: schema | validate | list | get | upsert | delete | rollback | run
    - kind: strategy | patch | profile | behavior (combat/shop/upgrade/item_box/reroll/lock/death hooks) | macro
    - run (kind=macro): payload={"state"?: snapshot, "character_id"?: str, "execute"?: bool}; execute=False
      (default) only plans writes; execute=True drives the live game and requires no active runner.
    All writes are schema + whitelist-AST validated, atomic, versioned, and allowed while runner is active.
    

Inputs: action (required), kind, name, steps, +3 more.

ping_gameA
Read-only

Check connection to LocalAI-AgentBridge, protocol version, phase, and env_capabilities.

Inputs: no named parameters.

rollback_strategyB

Rollback character strategy overrides by N steps (up to 10 archived versions).

Inputs: character_id (required), steps.

run_controlC
Destructive

Run lifecycle control: action in {start, menu, autopilot_on, autopilot_off}.

Inputs: action (required), danger, zone_id, weapon_id, +1 more.

set_threat_configB

Update (or read when called with no args) 60Hz autopilot and 2D spatial threat-map parameters.

Inputs: greed, aggression, kite_radius, tree_priority, +5 more.

shop_actionC
Destructive

Execute shop action (buy|lock|unlock|reroll|combine|recycle|next_wave) and return post-action shop summary.

Inputs: action (required), slot, weapon_index.

start_sessionC

Launch a detached autonomous runner job immediately returning {job_id}.

Inputs: danger, zone_id, max_waves, weapon_id, +1 more.

stop_sessionA

Gracefully stop an active autonomous runner job (force-kills after 10s).

Inputs: job_id (required).

update_strategyA

Dry-run or apply (with expect_base optimistic lock) a validated strategy override under state_dir.

Inputs: patch (required), character_id (required), dry_run, expect_base.

wait_for_phaseA
Read-only

Wait until game reaches one of target phases (timeout 1..50s; timeout returns reached=False, not an error).

Inputs: phases, timeout_sec.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 16 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes across the game-control domain (state read, strategy CRUD, shop, reward, runner lifecycle). There is a notable ambiguity between start_session and run_control with action='start', and mild overlap between get_game_state's progress/inventory view and shop_action's summary, but descriptions mostly disambiguate.

    Naming Consistency4/5

    Predominantly consistent verb_noun pattern (ping_game, get_game_state, update_strategy, start_session, decide_wave_reward, manage_extensions). The lone deviation is shop_action, which is noun-first rather than verb-first, but it remains readable and predictable.

    Tool Count4/5

    16 tools is at the higher edge but well-scoped for a complex game controller covering state, strategy, runner, shop, rewards, and extensions. Each tool maps to a genuine distinct capability, with only minor consolidation possible (start_session vs run_control).

    Completeness4/5

    The surface covers the full lifecycle: connection check, state inspection, strategy read/update/rollback, runner start/stop/status, phase waiting, shop, reward decisions, and extensions. Gaps are minor, such as no explicit combat-input tool beyond autopilot toggles, but core workflows are well covered.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to play Slay the Spire 2 by exposing game state and actions through an MCP server, supporting combat, rewards, and run management.
      366
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI assistants to interact with running games in real time — introspecting game state, simulating keyboard and mouse input to actually play, capturing screenshots, executing Lua code, hot-reloading files, and receiving push notifications when state changes.
      8
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Windows-local MCP for Steam Balatro: tool-calling AI reads player-visible state, chooses and executes native actions, confirms results, and saves local experience. Glama's Linux sandbox can introspect MCP and run game-independent tools such as calculate, but cannot connect to Balatro on the user's Windows machine. Without the local game, health reports disconnected.
      12
      5
      MIT