Skip to main content
Glama

LorAI MCP

让 AI 智能体玩《废墟图书馆》。

通过 MCP 协议将游戏状态、战斗操作、UI 导航全部暴露给 LLM——AI 读血量、看手牌、选情绪卡、出牌打怪,全自动。

AI Agent  ←MCP→  Python Server  ←HTTP→  C# Mod (in-game)

安装

面向人类用户

复制以下提示并粘贴到你的 LLM 智能体(kimi-code、Claude Code、Cursor 等):

按照以下安装指南安装和配置 LorAI MCP,游戏安装路径是:<填你的游戏路径,例如 D:\steam\steamapps\common\Library Of Ruina> https://raw.githubusercontent.com/hongyue0721/lorAI-mcp/refs/heads/master/docs/guide/installation.md

安装完成后,用 health_check 工具验证 MCP 连通。

面向 LLM 智能体

获取安装指南并按照说明操作。第一步:向用户询问 Library of Ruina 的游戏安装路径。

curl -s https://raw.githubusercontent.com/hongyue0721/lorAI-mcp/refs/heads/master/docs/guide/installation.md

拿到路径后,安装指南中的 <游戏路径> 占位符全部替换为用户提供的路径。

卸载

要移除 LorAI MCP:

按照 https://raw.githubusercontent.com/hongyue0721/lorAI-mcp/refs/heads/master/docs/guide/installation.md 中的「卸载」章节执行卸载步骤。


Related MCP server: Pokemon MCP Server

前置条件

依赖

说明

Steam

安装 Library of Ruina (1.1.0.6a13)

Python 3.10+

MCP Server 运行环境

.NET Framework 4.7.2

C# Mod 编译(需 Developer Pack 或 VS Build Tools)

BaseMod

游戏内 Mod 加载器


它能做什么

  • 读取游戏状态 — 关卡列表、角色血量、手牌、骰子、buff、敌人信息

  • 自动战斗 — AI 决策出牌、推进回合、处理情绪卡选择

  • UI 导航 — 选楼层、进邀请、开战、结算、跳剧情

  • 静态数据查询 — 卡牌、书籍、敌人、被动能力的完整数据

  • 反射调试 — 列出/调用任意游戏方法,深度控制


项目结构

lorAI-mcp/
├── lor_mcp/                   # Python MCP Server
│   ├── server.py              # FastMCP 入口 + 基础 tools
│   ├── tools.py               # Guided tools(战斗自动化)
│   ├── setup.py               # MCP 一键注册脚本
│   ├── proxy_server.py        # HTTP 代理回退
│   └── config.py              # 环境变量配置
├── LorAIHost/                 # C# Mod(HTTP bridge + 状态导出 + 战斗自动化)
│   ├── LorAIHostMod.cs        # ModInitializer 入口
│   ├── HttpServer.cs          # HTTP 服务(端口 17127)
│   ├── StateExporter.cs       # 游戏状态导出
│   ├── ActionHandler.cs       # Action 分发
│   ├── AdvancedActions.cs     # 选书/情绪卡/phase 推进
│   ├── BattleActions.cs       # 出牌/确认/结束战斗
│   └── ...
├── docs/guide/installation.md # 安装指南(给智能体读的)
└── pyproject.toml

配置

环境变量

默认值

说明

LOR_API_BASE_URL

http://localhost:17127

游戏 bridge 地址

LOR_PROXY_FALLBACK_URL

http://localhost:17128

Python 代理回退地址

LOR_MCP_TOOL_PROFILE

guided

工具集(guided 加载战斗自动化)

LOR_GAME_DATA_DIR

(Steam 默认路径)

代理服务器的游戏数据目录


许可证

MIT

Available Tools

23 tools
actA

Execute a game action through the Mod HTTP bridge.

Available actions: navigate - navigate UI phase (params: phase=) selectSephirah - select a sephirah floor (params: sephirah=) getFloor - get floor data (params: sephirah=) startStage - set stage on invitation panel (params: stageId=) runStage - run a stage end-to-end (params: stageId=) startBattle - start the battle from BattleSetting panel startGame - click Continue/New Game on title screen prepareBattle - auto-select books and prepare battle (params: stageId=) autoPlay - game's built-in auto card placement confirmCards - confirm card placement (ApplyLibrarianCardPhase only) playBattleRound - atomic autoPlay + confirmCards endBattle - force-end current battle closeBattleScene - close the battle scene clickBattleResult - click battle result button gameOver - trigger game over killAllEnemy - kill all enemy units (debug) getStageInfo - get stage controller info (params: stageId=) getBattleUnits - export all battle unit data getEmotionCandidates - get emotion card candidates selectEmotionCard - select emotion card by index (params: index=) forceAdvancePhase - force-advance a stuck phase (params: phase=) skipStory - skip current story endStory - end current story advanceStory - advance current story listMethods - list methods on a type (params: type=) callMethod - call method via reflection (params: type=, method=) getGameState - diagnostic singleton dump

When LOR_MCP_TOOL_PROFILE == 'guided', prefer the specific tools from tools.py. params: comma-separated key=value pairs, e.g. "stageId=3,sephirah=Malkuth" Commas inside [...] or {...} are preserved (not split on).

Inputs: action (required), params. Returns: object

battle_loopA

Auto-play through an entire battle until it ends.

Handles: round-start dice, auto card placement, emotion card selection, phase stuck detection, and story skips (including BattleStoryPhase in suppression battles).

Emotion card strategy: calls get_emotion_candidates, picks the Positive card with highest emotionLevel. For smarter selection, the LLM can interrupt and call select_emotion_card manually.

Returns {"result": "victory"|"timeout"|"not_in_battle", "rounds": N}.

Inputs: max_rounds. Returns: object

call_methodA

Call an arbitrary method on a game object via reflection.

For advanced debugging. args is a JSON array of typed arguments, e.g. '[{"type":"string","value":"6"}]'.

Common targets:

  • StageController: SkipRoundStartUI, StopSpeedDiceRoll, CompleteApplyingLibrarianCardPhase, KillAllEnemy

  • UIController: OnClickGameStart, PrepareBattle

Inputs: object_type (required), method_name (required), args. Returns: object

click_battle_resultA

Click the battle result button after a battle ends.

Inputs: no named parameters. Returns: object

close_battle_sceneA

Close the battle scene and return to the main UI.

Inputs: no named parameters. Returns: object

get_action_statusA

Check the status of deferred (async) actions.

Note: The /action-status endpoint may not be available in all mod versions. Returns completed action results and pending action IDs if supported.

Inputs: no named parameters. Returns: object

get_battle_unitsA

Get detailed data for all current battle units (players + enemies).

Returns HP, break, speed dice, hand cards, emotion level for each unit. Only works during an active battle.

Inputs: no named parameters. Returns: object

get_emotion_candidatesA

Get current emotion card candidates during RoundEndPhase.

Returns list of candidate cards with: index, id, name, state (Positive/Negative), emotionLevel, targetType. Returns {active: false} if emotion card UI is not currently shown.

The LLM should call this when battle.phase is RoundEndPhase and the phase seems stuck, then decide which card to pick.

Inputs: no named parameters. Returns: object

get_game_data_itemA

Return a single item from a static game data collection.

First calls /static/{collection} to get the full collection, then finds the item by id. For efficiency, prefer get_game_data_items when you need multiple items.

Collections: cards, books, enemies, passives, decks, stages, drop_books, card_drop_tables, gifts, emotion_cards, emotion_ego, formations, quests, floor_levels, final_rewards, tooltips, titles, credits

Inputs: collection (required), item_id (required). Returns: object

get_game_data_itemsA

Return items from a static game data collection by comma-separated ids.

More efficient than calling get_game_data_item multiple times.

Example: get_game_data_items(collection='cards', item_ids='1,2,3')

Inputs: collection (required), item_ids (required). Returns: object

get_game_stateA

Get the full current game state from the bridge.

Returns: navigation, progression, floors, inventory, availableStages, battle. Key fields for decision-making:

  • navigation.activeScene: Title | Main | Battle | Story

  • navigation.currentUIPhase: Sephiroth | Invitation | BattleSetting | BattleResult | ...

  • battle.phase: RoundStartPhase_UI | ApplyLibrarianCardPhase | RoundEndPhase | EndBattle | ...

  • battle.inBattle, battle.roundTurn

  • availableStages.stages[]: id, chapter, floorNum, stageType

Inputs: no named parameters. Returns: object

get_stage_infoA

Get info about a specific stage by ID.

Returns stage controller state: wave, round, isEndContents.

Inputs: stage_id (required). Returns: object

get_state_layerA

Return a specific layer of the game state.

Valid layers: navigation, progression, floors, inventory, availablestages, battle

Inputs: layer (required). Returns: object

get_static_data_listA

List all available static game data files exported by StaticDataExport mod.

Returns file names and sizes for: cards, books, enemies, passives, decks, stages, etc.

Inputs: no named parameters. Returns: object

health_checkA

Check whether the Library of Ruina game Mod HTTP bridge is online and reachable.

Inputs: no named parameters. Returns: object

kill_all_enemyA

Kill all enemy units (debug cheat). For testing only.

Inputs: no named parameters. Returns: object

list_methodsA

List available public methods on a game object type via reflection.

Inputs: object_type (required). Returns: object

play_roundA

Play one battle round: stop dice -> auto-play cards -> confirm.

Waits for ApplyLibrarianCardPhase before acting. Use this for fine-grained control instead of battle_loop.

Inputs: no named parameters. Returns: object

select_emotion_cardA

Select an emotion card by candidate index.

Call get_emotion_candidates first to see the options, then call this with the chosen index (0-based).

Handles SelectOne cards by auto-targeting the first alive player.

Inputs: index (required). Returns: object

skip_storyB

Skip the current story/event scene.

Inputs: no named parameters. Returns: object

start_battleA

Start a battle for the given stage with automatic book selection.

Flow: navigate Invitation -> prepareBattle (auto-selects best books by composite score: HP + breakLife + resistances) -> wait for BattleSetting -> startBattle -> wait for Battle.

For high-difficulty stages where auto-selection picks bad books, pass explicit book_ids to override auto-selection.

Inputs: stage_id (required), wait_seconds, book_ids. Returns: object

start_gameA

Click Continue on the title screen and wait for the main UI.

The HTTP bridge may go down during scene transition; this tool retries until the scene is no longer Title.

Inputs: wait_seconds. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 23 tools

    Disambiguation2/5

    There is significant overlap between the generic 'act' tool and many specific tools (e.g., navigate, start_battle, battle_loop). Both 'act' and separate tools provide similar actions, causing confusion. Also, 'get_game_data_item' and 'get_game_data_items' are nearly identical.

    Naming Consistency2/5

    Naming is inconsistent: top-level tools use snake_case (e.g., battle_loop), but sub-actions within 'act' use camelCase (e.g., startBattle). Some tools are verbs (navigate), others are phrases (click_battle_result). No uniform verb_noun pattern.

    Tool Count3/5

    With 23 tools, the set is on the higher end but can be justified for complex game automation. However, redundancy (e.g., multiple battle control tools) suggests it could be streamlined without loss.

    Completeness3/5

    The tool set covers navigation, battle, game data querying, and debugging reasonably well. However, there is no direct tool for inventory management or configuration, and some critical actions like saving/loading are missing.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A Python MCP server that helps AI interact with Gacha games through screenshot capture and click automation, enabling game analysis and automated actions.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server for the Genius Invokation TCG simulator that allows AI models to interact with the game through a structured interface. It provides comprehensive tools for querying game states, accessing indexed card data, and executing gameplay actions like elemental tuning and character selection.
      AGPL 3.0
    • 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.
      357
      -