--- title: "Tools: MCP, CLI, and GRASS" description: "Every interface for playing Structs compared: Desktop MCP, the structsd CLI, GRASS streaming, and the Guild Stack. Run preflight to detect yours." --- # Tools: MCP, CLI, and GRASS **Static reference for the interfaces available to play Structs** (Desktop MCP, `structsd` CLI, GRASS streaming, Guild Stack). Read this to understand what each tool does. > Your connection details (RPC, chain ID, key name, MCP URL) and preferences now live in > **`config/operator.md`** (copy from > [`config/operator.example.md`](https://github.com/playstructs/structs-ai/blob/main/config/operator.example.md)). To detect what's actually > available in your environment, run **`scripts/preflight.sh`** — it writes a capability > profile to `config/environment.json`. This page is the catalog; that profile is the truth > for your machine. --- ## Prerequisites The `structsd` binary must be installed before you can play. If `structsd version` fails, use the **[`structsd-install`](/skills/structsd-install/SKILL.html)** skill to either download a prebuilt release binary or build from source via the Makefile (Go 1.27.3+). --- ## Secrets **Never commit mnemonics, private keys, or secrets to the repository.** Storage options (in order of preference): 1. **Environment variable**: `export STRUCTS_MNEMONIC="word1 word2 ..."` — set per session, no file on disk. 2. **`.env` file**: Store in the workspace root as `STRUCTS_MNEMONIC=...`. The `.env` file must be in `.gitignore`. 3. **Keyring**: `structsd keys add [name]` stores the key in the system keyring. Retrieve the address with `structsd keys show [name] -a`. The mnemonic is still needed for guild signup (Path B in onboarding). 4. **Commander-provided**: The user provides the mnemonic or key name at session start. The guild signup script reads the mnemonic from its `--mnemonic` argument. Pass it from the environment: `--mnemonic "$STRUCTS_MNEMONIC"`. **Warning**: `structsd keys add --output json` outputs the mnemonic **in plaintext** to stdout. Avoid `--output json` unless redirecting to a secure file. The default text output shows the mnemonic only once during creation. --- ## Deployment Structs can run in several configurations: - **Structs Desktop** — The [`structs-desktop`](https://github.com/playstructs/structs-desktop) app gives a human the game interface and embeds an MCP server their agent connects to (see [MCP Tools](#mcp-tools)). This is the standard setup for a human playing alongside their agent — nothing else to deploy. - **Local Docker Compose** — Full stack (chain, DB, webapp) running locally. Default ports below. - **Remote Testnet** — Connect to a shared testnet via RPC endpoint. - **Hosted** — Managed deployment with provided endpoints. Check which deployment you're connected to and update the URLs below accordingly. ### Guild Stack (Advanced) For sub-second game state queries, real-time threat detection, and combat automation, deploy the **Guild Stack** locally via Docker Compose. It provides PostgreSQL-indexed game state (via `structs-sync-state`), a local GRASS/NATS server, webapp, and optional transaction signing agent. **Repository**: `https://github.com/playstructs/docker-structs-guild` Setup: `git clone` the repo, configure `.env`, run `docker compose up -d`, wait for chain sync (hours on first run). See the [`structs-guild-stack`](/skills/structs-guild-stack/SKILL.html) skill for the full procedure. The guild stack is optional -- CLI commands via a remote node work for basic gameplay. PG access becomes essential for combat automation and galaxy-wide intelligence. --- ## Reference Node `public.testnet.structs.network` is a public Structs testnet node served over SSL. Use it for queries when no local node is available — the SSL endpoint avoids mixed-content and CORS issues that plagued the older HTTP testnet hosts. - **Consensus API**: `https://public.testnet.structs.network` - **Tendermint RPC**: `https://public.testnet.structs.network:26657` - **Tendermint WebSocket**: `wss://public.testnet.structs.network:26657/websocket` - **Guild list**: `https://public.testnet.structs.network/structs/guild` This node runs only `structsd` (chain). Guild API and GRASS NATS WebSocket services are hosted by individual guilds — see the guild config you fetch from `/structs/guild`. --- ## Node Configuration By default, `structsd` commands connect to `localhost:26657`. If you are not running a local node, you **must** configure a remote node or every command will fail. **Option 1: Set the default node permanently** by editing `~/.structs/config/client.toml`: ``` broadcast-mode = "sync" chain-id = "structstestnet-111" keyring-backend = "test" node = "https://public.testnet.structs.network:26657" output = "text" ``` `keyring-backend = "test"` keeps keys unencrypted on disk; it is the testnet choice so unattended `*-compute` jobs can sign without a passphrase prompt. Use it only on a machine you control. **Option 2: Per-command flag** for one-off queries: ``` structsd query structs player 1-11 --node https://public.testnet.structs.network:26657 ``` If you see connection errors like "connection refused" on port 26657, you need to configure this. --- ## Servers | Service | URL | Status | |---------|-----|--------| | Consensus API | `http://localhost:1317` | *(fill in: running/offline)* | | Webapp API | `http://localhost:8080` | *(fill in: running/offline)* | | NATS Streaming | `nats://localhost:4222` | *(fill in: running/offline)* | | GRASS WebSocket | `ws://localhost:1443` | *(fill in — or use guild config's `grass_nats_websocket`)* | --- ## Account **Address:** *(fill in during first session — your cosmos address)* **Player ID:** *(discover via `structsd query structs address [your-address]`)* **Fleet ID:** *(matches player index: player `1-18` has fleet `9-18`)* To find your player ID from your address: `structsd query structs address [your-address]`. If the result shows player ID `1-0`, no player exists for that address yet. *Never store private keys here. Use environment variables or a secure keystore.* --- ## Guild **Guild ID:** *(fill in after joining a guild — or set as preferred guild for signup)* **Guild Name:** **Guild API:** *(from the guild config's `services.guild_api` field — needed for programmatic signup)* **Role:** **Central Bank Status:** To discover available guilds and their configs, see the onboarding skill's guild signup section or query: `curl https://public.testnet.structs.network/structs/guild` --- ## Known Players | Player ID | Name/Alias | Guild | Relationship | Notes | |-----------|-----------|-------|-------------|-------| | | | | | | --- ## Territory | Planet ID | Name | Status | Primary Use | Notes | |-----------|------|--------|------------|-------| | | | | | | --- ## The Codex toolbox (read-only docs tools) Six tools that answer questions from these docs instead of pointing at pages. They read this repository only: no network, no keys, and they never sign or act on the game. Every answer carries its source. | Tool | Answers | |------|---------| | `search` | Facts, rules, error strings and pages matching a question | | `get` | One page as plain Markdown with facts and rules filled in, optionally one section | | `verify` | One stored fact or rule (`F.mine.d3`, or plain words) with its pinned source | | `explain_error` | An error string or numeric code: meaning and fix | | `power_budget` | Headroom from your player numbers (mW or the player JSON) and whether planned builds fit | | `preview_move` | Checks a `structsd tx structs` command (arguments, `--gas auto`, `--`, `-y`, tier, charge) and drafts its Approval Block | Command line: `python3 scripts/codex.py ...` (for example `python3 scripts/codex.py verify F.refine.d3`). Python 3 standard library only. Agents that play through Structs Desktop already have its MCP server; the same data these tools read is published for it and any client: [`/facts.json`](/facts.json), [`/rules.json`](/rules.json), [`/errors.json`](/errors.json). Golden checks: `python3 scripts/ci/test-codex.py`. **How to use them, from testing.** In two rounds of the twelve-task exam, Sonnet with the toolbox read about half as many words as Sonnet reading pages (about 12,000 against 20,000–23,000), and scored 30/36 against 32–33/36. The points it lost were nuances it never opened: a cliff in the `-D` table, "a raid takes all stored ore", how a substation splits power. So use the tools to find and check, then read the canonical page they point to (`canonical_page`, `related_rules`) before a decision you cannot undo. These are documentation tools. To act on the game, use the Structs Desktop MCP tools below or the `structsd` CLI, under [SAFETY](SAFETY.md). ## MCP Tools Agents play Structs through the MCP server embedded in **[`structs-desktop`](https://github.com/playstructs/structs-desktop)**. The human runs the desktop app for the game interface, and their agent connects to that same app over MCP — one program gives both the human's screen and the agent's tools, with no separate infrastructure to deploy. This is the standard way for a human and their agent to play together. ### Connecting The embedded server runs on `http://127.0.0.1:8420/mcp` with bearer-token authentication. The exact URL and token are shown in the app's **Debug menu panel** (and the browser console); the Debug panel can copy a ready-made `.mcp.json` for you: ```json { "mcpServers": { "structs-game": { "type": "http", "url": "http://127.0.0.1:8420/mcp", "headers": { "Authorization": "Bearer YOUR_TOKEN_HERE" } } } } ``` The bearer token is generated on first launch and stored with the app's config. Every request must carry it — requests without the token are rejected (`400 Bad Request`), which keeps other local processes and websites from driving the game. Treat the token like a key. ### Tools (13) | Tool | Purpose | |------|---------| | `structs_dashboard` | Full player overview: power, charge (with per-action readiness), resources, structs + HP, hash tasks, recent events. `player_id` defaults to the logged-in player | | `structs_hash` | Proof-of-work tasks — `list` / `start` (`task_type` `MINE`, `REFINE`, `BUILD`, `RAID`) / `progress` / `stop` / `config`. Omitted MINE/REFINE `block_start` resolves from the planet ore clock; BUILD/RAID require the real anchor | | `structs_action` | Execute one game action with preflight checks: `explore`, `build`, `mine`, `refine`, `attack`, `defend`, `activate`, `deactivate`, `move_fleet`, `transfer`, `deploy`, `raid`, `update_primary_reactor`, `resync`. Guild founding, rank sales, bank convert, vault transfers, and `reactor-restart` are CLI-only | | `structs_intel` | Strategic intelligence + perception. Queries include `raid_readiness` (per-player/per-ambit fleet coverage) and `battle_log` (`category:"all"` supported), plus `whoami`, `intents`, `ruleset`, `simulate`, `strike_options`, planning/economy/trend/scout and raw entity reads | | `structs_policy` | Standing orders — `list` / `set` / `remove` / `log` over `auto_refine`, `power_alert`, `combat_alert`, `agent_ui`, `auto_counterattack`, `auto_retreat_if_cmd_below`, `auto_rebuild_losses`, `rules_of_engagement`, `primary_home_guard`, `board_auto_open`, `watchdog_remediate` | | `structs_events` | Long-poll event feed (`wait_secs`) with `mine_only`, `team` (whole roster), `threats_only` (server-side threat classifier — a ready-made under-attack detector), `category`, `since`/`next_cursor`. `tx_settled` is an MCP action-bridge receipt, not guaranteed for PoW auto-completions | | `structs_sequence` | Guarded autonomous action chains, paced to the charge cooldown, with `abort_if` predicates; `as` runs the chain as a virtual player | | `structs_players` | Virtual players, behaviour profiles/variance, and native loops: `list`, `roster`, `create`, `state`, `act`, `capacity`, `role`, `economy`, `profile`, `variance`, `infra`, `harvest`, `autobuild`, `autodefend`, `autoresponse`, `autoraid`, `infuse` | | `structs_board` | Team Ops board + human UI (`component` elicitation) and `web` dashboard toggle. MCP board path never signs; `web:"on"` serves a separate human dashboard that **can** sign — see below | | `structs_system` | Health, logs, self-tuning — `status`, `logs`, `loops`, `tx`, `pow`, `watchdog`, `feed`, `config`, `perception`. Config controls remediation, sign mode/gate, and verify/GRASS/snapshot sources | | `structs_map` | Render a planet map to PNG/GIF using the game's renderer | | `structs_doctrine` | Standing rules of engagement, per-tick executor, and the persistent combat lists (`set` / `show` / `tick` / `lists`, autonomy advise/auto, presets `turtle` / `economy` / `balanced` / `warfighter`) | | `structs_strike` | Coordinated team attack + kill-chain (strip blockers → kill → raid window). Reach planning is advisory; on an apparent false-negative, refresh raw attacker/target/fleet state and use chain preflight | Full descriptions, parameters, and subsystems: **[knowledge/infrastructure/structs-desktop.md](knowledge/infrastructure/structs-desktop.md)**. `tools/list` returns exactly the 13 above. Component UI is part of `structs_board`; `structs_ui` is not advertised or active (a hardcoded legacy call only returns a migration pointer). The current Team Ops IA is **Command / Armada / Industry / War / Explore / System**, with Terminal and Matrix-backed Comms surfaces. It uses internal Tauri/`web_board` handlers, not extra MCP tools. Industry's Infusions preview/action handlers are likewise Tauri-only—not a new MCP tool. ### Prompts (7) | Prompt | Purpose | |--------|---------| | `getting_started` | Guided first session for a brand-new player: explore → build → mine → refine, with the agent as the tutorial | | `structs_first_session` | Orientation for new agents — check dashboard, identify priorities | | `structs_game_loop` | One tick: dashboard → assess → plan → execute → verify | | `structs_state_assessment` | Deep analysis with risk ratings: power, threats, economy, operations | | `structs_combat_planning` | Scout, simulate, recommend attack/wait/abort | | `structs_threat_check` | Assess hostile activity using planet history + valid targets | | `structs_market_check` | Survey the power-rental market | ### Resources This `structs-ai` compendium is bundled as MCP resources, so an agent can read the docs on demand by URI (e.g. `structs://START.md`, `structs://play/index.md`, `structs://knowledge/mechanics/combat.md`, `structs://reference/index.md`). URIs are derived from the file tree — see the [resource map](knowledge/infrastructure/structs-desktop.md) and [`develop/structs-resources.md`](develop/structs-resources.md). The sync is a **build step**, so a given build may ship none. A live server checked on 2026-07-24 returned an empty `resources/list` and 404'd every URI above. Call `resources/list` once before relying on it, and fall back to [structs.ai](https://structs.ai) or a local checkout if it is empty. ### Signing, automation, and co-op MCP responses never expose keys, but Desktop may custody the mnemonic: the signed-in webview hands it to Rust once, Rust verifies HD index 0, stores it in the OS keychain, and native sign modes derive virtual-player keys per transaction. `structs_system config` selects `sign_mode:"sync"|"async"|"native"|"native_async"`; native modes fall back to the webview bridge until ready. Economic loops auto-sign once enabled. `autoresponse` and `autoraid` remain off and advising by default; arming either is a standing combat grant. Evaluate them in `advise` mode before arming. Profiles bundle loadout/capabilities/temperament and can be assigned through `structs_players profile`; `variance` adds bounded non-determinism without weakening hard gates. Team Ops also has profile-weighted auto-replication, but replication is not a `structs_players` MCP command. ### Sharing the board with a remote human `structs_board {web:"on"}` serves Team Ops at `http://127.0.0.1:8420/board?token=…` (off by default). The web router exposes a deliberate subset of Tauri operations: many reads and Matrix conversation actions, plus selected game/config/finance writes that sign; interactive Matrix login, native-window actions, and Matrix work commitments are omitted. The token authorizes every routed operation, so treat it like a password and turn the board off when done. *Desktop catalog verified against `3f04437d5606d6736df41301bb980893129a7912` (2026-09-30), including `handler.rs`, current tool implementations, and tests.* ### CLI Fallback When the desktop app isn't running, fall back to direct CLI commands: `structsd tx structs [command]` and `structsd query structs [command]`. See `reference/api-quick-reference.md` for endpoint details. --- ## CLI Gotchas Common pitfalls when using `structsd` directly: | Gotcha | Problem | Fix | |--------|---------|-----| | **`--` separator** | Entity IDs like `3-1` or `4-5` are parsed as flags by the Cobra CLI parser | Place `--` after all flags and before positional args: `structsd tx structs command --from key --gas auto -- 4-5 6-10` | | **reactor-infuse address** | Takes the **validator address** (`structsvaloper1...`), not the reactor ID (`3-1`) | Look up the reactor's `validator` field first: `structsd query structs reactor [id]` | | **Where the Alpha comes from** | Infusion, generator fuel, agreements, Central Bank and rank purchases pay from your **vault**, not the signing key's balance | Fund the vault (`player-send` to `structsd query structs vault [player-id]`); `playerInventory.rocks` is the spendable balance | | **Amount denomination** | Amounts must include the denomination suffix | Use `60000000ualpha` not `60000000`. Same for guild tokens: `100uguild.0-1` | | **provider-withdraw-balance** | Takes two positional args: provider ID (contains a dash) and the destination address for the earnings | Use: `structsd tx structs provider-withdraw-balance --from key --gas auto -- [provider-id] [destination-address]` | | **substation-create** | Takes two positional args: owner player ID and allocation ID | Use: `structsd tx structs substation-create --from key --gas auto -- [owner-id] [allocation-id]` | | **Sequence mismatch** | Two transactions from the same account at the same time | Wait ~6 seconds between transactions from the same key | | **TX fees** | Players don't need Alpha tokens to pay gas fees | Pure Structs gameplay messages are free (dedicated free-gas meter, no `ualpha` fee) — see [transactions](knowledge/mechanics/transactions.md). Still pass `--gas auto`. Being online/powered gates *acting*; it is not a per-tx fee | | **Concurrent PoW** | Two `*-compute` jobs sharing the same signing key submit conflicting sequence numbers | Use one signing key per player; never run concurrent compute jobs on the same key | --- *Update this file when your environment changes.*