MCP bridge mod for Slay the Spire 2, used by SpireLens for live-game agentic validation. Vendored from kunology/STS2MCP under MIT.
  • C# 70.7%
  • Python 28.8%
  • PowerShell 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nelson 4ff253fd58
All checks were successful
Suite docs / release (push) Has been skipped
Suite docs / scope (push) Successful in 43s
Suite docs / check-validate (push) Has been skipped
Suite docs / reused-checks (push) Has been skipped
Hyphenated file names and lint-clean Markdown for the shared CI checks (#31)
2026-11-30 15:15:58 -08:00
.forgejo/workflows CI from the docs and python suites; the C# whitespace check stays (#29) 2026-11-16 16:16:26 -08:00
.github/ISSUE_TEMPLATE FORGEJO-3: retire bridge GitHub CI after verified release (#22) 2026-11-02 23:50:09 -08:00
docs Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
mcp Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
.gitignore Vendor kunology/STS2MCP v0.3.4 as SpireLens MCP 2026-04-24 20:09:31 -07:00
AGENTS.md Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
AUTHORS.md chore: repoint nelsong6 -> romaine-life org references 2026-06-03 04:11:25 +00:00
build.ps1 Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
LICENSE Vendor kunology/STS2MCP v0.3.4 as SpireLens MCP 2026-04-24 20:09:31 -07:00
McpMod.Actions.cs Run the bridge on the STS2 v0.113 beta and stable (#27) 2026-11-13 20:31:23 -08:00
McpMod.Catalog.cs Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
McpMod.cs Replace polling with game-state events, a startup ready file and process-handle waits (#20) 2026-10-18 22:05:11 -07:00
McpMod.DevActions.cs Run the bridge on the STS2 v0.113 beta and stable (#27) 2026-11-13 20:31:23 -08:00
McpMod.Formatting.cs Vendor kunology/STS2MCP v0.3.4 as SpireLens MCP 2026-04-24 20:09:31 -07:00
McpMod.GameCompat.cs Run the bridge on the STS2 v0.113 beta and stable (#27) 2026-11-13 20:31:23 -08:00
McpMod.Helpers.cs Fix game-API drift: v0.104.0 removed IsPlayPhase, ICombatState 2026-04-24 20:16:32 -07:00
McpMod.MultiplayerActions.cs Fix game-API drift: v0.104.0 removed IsPlayPhase, ICombatState 2026-04-24 20:16:32 -07:00
McpMod.MultiplayerState.cs Fix game-API drift: v0.104.0 removed IsPlayPhase, ICombatState 2026-04-24 20:16:32 -07:00
McpMod.Screenshot.cs Capture screenshots from the game viewport 2026-04-26 16:59:19 -07:00
McpMod.SettingsUI.cs Run the bridge on the STS2 v0.113 beta and stable (#27) 2026-11-13 20:31:23 -08:00
McpMod.StateBuilder.cs Run the bridge on the STS2 v0.113 beta and stable (#27) 2026-11-13 20:31:23 -08:00
McpMod.StateSignal.cs Replace polling with game-state events, a startup ready file and process-handle waits (#20) 2026-10-18 22:05:11 -07:00
mod-manifest.json Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
README.md Hyphenated file names and lint-clean Markdown for the shared CI checks (#31) 2026-11-30 15:15:58 -08:00
SpireLensMcpBridge.csproj Complete bridge rename: csproj/sln/build/README/docs (#9) 2026-04-30 15:02:14 +00:00
SpireLensMcpBridge.sln Complete bridge rename: csproj/sln/build/README/docs (#9) 2026-04-30 15:02:14 +00:00

SpireLens MCP

Source, pull requests, CI, and releases live on Forgejo. GitHub is a push mirror. Releases contain source archives; compiling the mod still requires a local copy of the game as described below.

HTTP bridge mod for Slay the Spire 2 used by SpireLens for live-game agentic validation. Exposes game state and actions on localhost:15526 for the bundled Python MCP server, which Claude Code and other MCP clients can use to drive runs.

Vendored from Gennadiyev/STS2MCP v0.3.4 under MIT — see AUTHORS.md for attribution and the rationale for forking.

Components

  • C# mod (McpMod.*.cs, SpireLensMcpBridge.csproj) — built into SpireLensMcpBridge.dll, copied to <game_install>/mods/. Opens an HttpListener on localhost:15526 and dispatches to handlers for game-state queries and action commands.
  • Python MCP server (mcp/server.py) — MCP server that connects to the in-game listener and exposes ~50 tools (combat_play_card, relic_select, get_game_state, etc.). Used by Claude Code via the consuming repo's .mcp.json. Speaks stdio by default; pass --transport http to serve remote clients (see Remote clients).

Build

Requires .NET 9 SDK and the base game.

.\build.ps1 -GameDir "D:\SteamLibrary\steamapps\common\Slay the Spire 2"
# or
$env:STS2_GAME_DIR = "D:\SteamLibrary\steamapps\common\Slay the Spire 2"
.\build.ps1

Outputs out/SpireLensMcpBridge/SpireLensMcpBridge.dll. Install:

out/SpireLensMcpBridge/SpireLensMcpBridge.dll  ->  <game_install>/mods/SpireLensMcpBridge/SpireLensMcpBridge.dll
mod-manifest.json                              ->  <game_install>/mods/SpireLensMcpBridge/SpireLensMcpBridge.json

(The mod loader expects a folder named after the mod ID with the manifest renamed to <id>.json. The mod ID is SpireLensMcpBridge per mod-manifest.json.)

Build breaking after an STS2 update? The game ships roughly every two weeks and routinely renames or removes the C# game symbols this bridge compiles and reflects against. Before re-diagnosing from scratch, read Surviving STS2 updates in the SpireLens repo — it catalogs the recurring failure modes (build drift, BaseLib desync / frozen HUD, debug-load HUD desync) with concrete symptom → cause → fix.

Verify

With the game running:

curl -s http://localhost:15526/

Expected:

{"message": "Hello from SpireLensMcpBridge v0.3.4", "status": "ok", "ready": true, "pid": 12345, "state_version": 812, "ready_file": "..."}

Connection refused means the mod isn't loaded — check that mods are enabled in the game's settings.

When driving STS2 through the MCP server, use bridge_health or get_host_status first. These tools run on the host-side MCP server and return structured JSON for the common startup states: host MCP reachable, STS2 not running, STS2 running without the in-game bridge, bridge still starting, or bridge ready. On hosts with a configured launcher, call start_sts2 to launch the game and wait for it.

Nothing in the bridge or the MCP server waits by polling:

  • Startup. "status": "ok" means the listener is up. "ready": true means NGame.GameStartupComplete has finished (logo, main menu, startup error checks), so loading a run can no longer cancel startup. At that point the bridge writes bridge-ready.json (pid, port, version) under the game's user data directory (%APPDATA%\SlayTheSpire2\SpireLensMcpBridge\), and start_sts2 blocks on a directory change notification for it.
  • Shutdown. stop_sts2 blocks on the game's process handles.
  • Game state. Every state response carries state_version and settled. POST {"action": "wait_for_change", "since_version": N, "timeout_ms": M} parks the request until the version passes N and the game has settled (no game action running or queued, no turn hand-off, no screen transition), then returns the state. The version is bumped by run, room, combat, action-queue, overlay, map and hand events, plus the scene tree's node signals. The MCP tool is wait_for_game_state_change.

MCP server

Requires Python 3.11+ and uv. First run installs the locked dependencies from mcp/uv.lock:

uv run --directory /path/to/spirelens-mcp/mcp python server.py --help

Add to a consumer's .mcp.json (e.g. SpireLens's) — pointing at the local checkout:

{
  "mcpServers": {
    "sts2-modding": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "D:\\repos\\spirelens-mcp\\mcp", "python", "server.py"],
      "env": {
        "STS2_GAME_DIR": "D:\\SteamLibrary\\steamapps\\common\\Slay the Spire 2"
      }
    }
  }
}

Remote clients (HTTP transport)

stdio requires the MCP client to live on the same machine as the server, because the server talks to the in-game bridge over localhost:15526. When the client runs elsewhere — a Glimmung/tank session pod on the tailnet driving a run on the game host — start the server in HTTP mode on the game host instead and point the remote client at it. No port-forward needed.

On the game host, bind to its Tailscale IP:

uv run --directory D:\repos\spirelens-mcp\mcp python server.py `
  --transport http --bind-host <host-tailscale-ip> --bind-port 15527

The server still reaches the game over the local --host/--port bridge, so it survives game restarts and reconnects on its own. --bind-host defaults to loopback so --transport http is never accidentally world-reachable; set it to the Tailscale IP to accept remote clients. Keep --bind-port (MCP, default 15527) distinct from --port (the in-game bridge, 15526).

Point the remote client's .mcp.json at it:

{
  "mcpServers": {
    "sts2-modding": {
      "type": "http",
      "url": "http://<host-tailscale-ip>:15527/mcp"
    }
  }
}

Access control is layered. Pick a mode with --auth-mode (default: token when --auth-token / $SPIRELENS_MCP_TOKEN is set, otherwise none):

  • none — rely on the network layer alone: bind to the Tailscale interface and let tailnet ACLs against tag:spirelens-host gate access.
  • token — shared-secret gate. Set --auth-token <token> (or $SPIRELENS_MCP_TOKEN); clients send Authorization: Bearer <token> — add "headers": {"Authorization": "Bearer <token>"} to the .mcp.json entry.
  • jwt — validate an auth.romaine.life RS256 service token against its JWKS. This is the mode the SpireLens deployment uses: a tank/glimmung session pod presents its projected auth.romaine.life token, so no shared secret is distributed. The token is checked for signature (via JWKS), issuer, expiry, and role (default service); an optional --auth-allowed-actor-emails CSV restricts which human owners may drive the host. Defaults (each also reads a SPIRELENS_MCP_AUTH_* env var): --auth-jwks-url https://auth.romaine.life/api/auth/jwks, --auth-issuer https://auth.romaine.life, --auth-required-role service. Clients do not put the token in .mcp.json; the in-cluster MCP auth proxy injects the Authorization header on the pod's behalf (see the SpireLens / tank-operator tailnet-host-access docs).

License

MIT — see LICENSE.

The original copyright notice (Yikun Ji / Kunologist, 2026) is preserved in LICENSE per the MIT terms. Modifications by nelsong6 are documented in AUTHORS.md and the git history of this repo.