LorAI MCP
The LorAI MCP server lets an AI agent fully control and automate gameplay in Library of Ruina via game state monitoring, battle automation, UI navigation, static data queries, and debug tools.
Game State & Diagnostics
health_check— Verify the in-game mod HTTP bridge is onlineget_game_state— Retrieve the full current game state (navigation, progression, floors, inventory, battle info)get_state_layer— Fetch a specific layer of game state (e.g.battle,floors,navigation)get_battle_units— Get detailed HP, speed dice, hand cards, and emotion level for all battle unitsget_emotion_candidates— List available emotion card choices duringRoundEndPhaseget_stage_info— Get controller state for a specific stageget_action_status— Check status of async/deferred actions
Static Data Queries
get_static_data_list— List all available static game data files (cards, books, enemies, passives, etc.)get_game_data_item/get_game_data_items— Retrieve one or multiple items from a static collection by ID
UI Navigation
navigate— Navigate to a specific UI phase (e.g. Sephirah, Invitation, BattleSetting)start_game— Click Continue/New Game on the title screenskip_story— Skip the current story or event scene
Battle Automation
start_battle— Full flow: navigate to stage, auto-select books, prepare and start the battlebattle_loop— Auto-play an entire battle end-to-end (handles dice, card placement, emotion cards, phase stuck detection, story skips)play_round— Play a single battle round (stop dice → auto-play cards → confirm)select_emotion_card— Manually select an emotion card by indexclick_battle_result— Click the battle result button after a battle endsclose_battle_scene— Close the battle scene and return to the main UI
Low-Level / Debug
act— Execute any raw game action by namelist_methods/call_method— List or call public methods on game objects via reflectionkill_all_enemy— Instantly kill all enemy units (debug/cheat)
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LorAI MCP start a battle in Urban Nightmare"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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) |
游戏内 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配置
环境变量 | 默认值 | 说明 |
|
| 游戏 bridge 地址 |
|
| Python 代理回退地址 |
|
| 工具集( |
| (Steam 默认路径) | 代理服务器的游戏数据目录 |
许可证
Available Tools
23 toolsactA
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
Scored across 23 tools
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 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.
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.
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
Related MCP Connectors
Make games with AI: one MCP server that connects your agent to Unity, Unreal and Godot editors.
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Official MCP server for Agentwork — delegate tasks to AI agents with human-in-the-loop
MCP server for AI dialogue using various LLM models via AceDataCloud
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Python MCP server that helps AI interact with Gacha games through screenshot capture and click automation, enabling game analysis and automated actions.-
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI agents to play Pokémon games by providing a functional interface for game interaction. It allows for seamless integration with AI clients to execute gameplay tasks and manage game states.3-
- AlicenseNot gradedqualityCmaintenanceAn 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
- FlicenseNot gradedqualityAmaintenanceEnables 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-