- C# 70.7%
- Python 28.8%
- PowerShell 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| .github/ISSUE_TEMPLATE | ||
| docs | ||
| mcp | ||
| .gitignore | ||
| AGENTS.md | ||
| AUTHORS.md | ||
| build.ps1 | ||
| LICENSE | ||
| McpMod.Actions.cs | ||
| McpMod.Catalog.cs | ||
| McpMod.cs | ||
| McpMod.DevActions.cs | ||
| McpMod.Formatting.cs | ||
| McpMod.GameCompat.cs | ||
| McpMod.Helpers.cs | ||
| McpMod.MultiplayerActions.cs | ||
| McpMod.MultiplayerState.cs | ||
| McpMod.Screenshot.cs | ||
| McpMod.SettingsUI.cs | ||
| McpMod.StateBuilder.cs | ||
| McpMod.StateSignal.cs | ||
| mod-manifest.json | ||
| README.md | ||
| SpireLensMcpBridge.csproj | ||
| SpireLensMcpBridge.sln | ||
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 intoSpireLensMcpBridge.dll, copied to<game_install>/mods/. Opens anHttpListeneronlocalhost:15526and 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. Speaksstdioby default; pass--transport httpto 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": truemeansNGame.GameStartupCompletehas finished (logo, main menu, startup error checks), so loading a run can no longer cancel startup. At that point the bridge writesbridge-ready.json(pid, port, version) under the game's user data directory (%APPDATA%\SlayTheSpire2\SpireLensMcpBridge\), andstart_sts2blocks on a directory change notification for it. - Shutdown.
stop_sts2blocks on the game's process handles. - Game state. Every state response carries
state_versionandsettled.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 iswait_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 againsttag:spirelens-hostgate access.token— shared-secret gate. Set--auth-token <token>(or$SPIRELENS_MCP_TOKEN); clients sendAuthorization: Bearer <token>— add"headers": {"Authorization": "Bearer <token>"}to the.mcp.jsonentry.jwt— validate anauth.romaine.lifeRS256 service token against its JWKS. This is the mode the SpireLens deployment uses: a tank/glimmung session pod presents its projectedauth.romaine.lifetoken, so no shared secret is distributed. The token is checked for signature (via JWKS), issuer, expiry, androle(defaultservice); an optional--auth-allowed-actor-emailsCSV restricts which human owners may drive the host. Defaults (each also reads aSPIRELENS_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 theAuthorizationheader 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.