Skip to main content
Glama
Captain of Industry MCP

Captain of Industry MCP

by DongFengYan
README.md
# Captain of Industry MCP

[简体中文](README.zh-CN.md)

A local [Model Context Protocol](https://modelcontextprotocol.io/) server for [Captain of Industry](https://coigame.com/). It reads live production, consumption and inventory from the game's official Web API, ranks likely shortages, and calculates machine counts and upstream demand from recipe rates.

这是《Captain of Industry》的本地 MCP。可以查库存和产销并计算配比。启用配套 MOD 后,也可以向开局码头生成可由卡车提取的零件。

## Requirements

- Captain of Industry **Update 4.3 (v0.8.8)** or later, with an island loaded. See the [official Web API release notes](https://coigame.com/Changelog/0.8.8).
- Node.js **22 or later** and a local MCP client that supports **stdio**.
- Run the MCP process on the same Windows machine as the game. Its game requests go to `127.0.0.1`.

## Install from GitHub

```sh
git clone https://github.com/DongFengYan/captain-of-industry-mcp.git
cd captain-of-industry-mcp
npm ci
```

Load your island. Open the in-game console with the backtick/tilde key, then enter:

```text
web_api_start
```

The default API port is **3073**. You can check the available routes at [localhost:3073/routes](http://127.0.0.1:3073/routes). For a custom port, use e.g. `web_api_start 3080` and set `COI_PORT=3080` in the MCP client's server environment. The default browser-origin settings are sufficient. To stop the API, enter `web_api_stop` in the game console.

### Configure an MCP client

Use the absolute path to `src/index.js` in your clone. If the client cannot find Node, use the absolute path to `node.exe` as the command.

**Codex** ([MCP configuration](https://developers.openai.com/codex/mcp)):

```toml
[mcp_servers.captain_of_industry]
command = "node"
args = ["C:/projects/captain-of-industry-mcp/src/index.js"]

[mcp_servers.captain_of_industry.env]
COI_PORT = "3073"
```

**Claude Desktop or another client using an `mcpServers` object**:

```json
{
  "mcpServers": {
    "captain_of_industry": {
      "command": "node",
      "args": ["C:/projects/captain-of-industry-mcp/src/index.js"],
      "env": { "COI_PORT": "3073" }
    }
  }
}
```

Reload the client configuration, then ask it to call `coi_game_info` to check the connection.

## Tools

| Tool | What it returns |
| --- | --- |
| `coi_game_info` | Game date, tick, speed and pause status. |
| `coi_list_products` | Game-localized product names and their IDs, with optional name or ID search. |
| `coi_product_stats` | Current amounts and the game's production and consumption totals. |
| `coi_product_history` | Monthly production, consumption or stock levels for selected products. |
| `coi_product_sources` | Measured flows attributed to recipes, machine types or other sources and sinks when available. |
| `coi_find_shortages` | Products consuming more than they produced over completed months, ranked by estimated stock runway. |
| `coi_size_recipe` | Whole-machine count and input demand given a monthly target, per-machine rates and an assumed utilization. Works offline. |
| `coi_shipyard_stock` | Read how many units of a product are in the original starting shipyard. Requires the companion mod. |
| `coi_add_shipyard_stock` | Add physical units of a product to that shipyard and report the resulting cargo quantity. Requires the companion mod. |

## Shipyard supplies

1. Extract the `CoiMcpShipyard` folder from the [release ZIP](https://github.com/DongFengYan/captain-of-industry-mcp/releases) into `%APPDATA%\Captain of Industry\Mods`. It must contain the manifest and DLL.
2. Enable **Captain of Industry MCP Shipyard** in the game's mod list for the island, then load the island and run `web_api_start`. Keep the default browser-origin settings.
3. Ask the MCP client to add a specific amount to the starting shipyard. For example, “Add 40 Vehicle Parts I to the starting shipyard.” The tool returns the entity ID and the before and after quantities.

The tool supports storable, countable goods such as vehicle and construction parts. It uses the shipyard's truck logistics cargo buffer. Set up a destination that requests the product to have trucks move it from the shipyard. The target is the unique original starting shipyard. If it has been removed, the request fails. One call adds the requested amount on top of existing cargo. After an interrupted write, check the shipyard quantity before repeating the request.

## Example prompts

- 看过去三个完整游戏月的柴油、土豆和小麦。哪个会先耗尽?列出库存、月缺口和主要消耗来源。
- Compare diesel production and consumption over the last three completed months. Where did last month's diesel go?
- I need 45 more diesel per game month. Each machine makes 20 and uses 30 crude oil per game month at full speed. How many machines do I need at 75% utilization?

## Interpreting results

Shortage estimates use current aggregate stock divided by the measured average monthly deficit, excluding the month in progress. They can differ from local stock available to a machine. A supply interruption can also depress recorded consumption, so a small measured deficit can coexist with unmet demand. New islands need completed months before the shortage report can estimate a trend.

Use the rates from your current recipe panel for machine sizing. The Web API reports historical flows and source summaries. The calculator accepts recipe rates as inputs. The calculated input demand assumes those rates scale linearly with utilization.

The service uses the game's localhost API. The original analysis tools work with the base game. Live tools need a running island. Recipe sizing works without a game connection.

## Development

```sh
npm ci
npm test
```

The integration tests exercise the server over MCP stdio with a simulated game API.

To build the companion mod on Windows, set `COI_ROOT` to the game installation directory and run `dotnet build mod/CoiMcpShipyard -c Release` with the .NET SDK and .NET Framework 4.8 targeting pack. The output folder contains `CoiMcpShipyard.dll` and `manifest.json`.

Developed by OpenAI Codex. Published by [DongFengYan](https://github.com/DongFengYan).

Community project, independent of MaFi Games.

TDQS

A3.6/5.0

Scored across 9 tools

Disambiguation4/5

Most tools target clearly different facets: discovery (list_products), scalar aggregates (product_stats), temporal series (product_history), attribution (product_sources), ranking (find_shortages), and calculation (size_recipe). The three product-read tools (stats/history/sources) all read product flow data, so an agent could occasionally misselect between them, but the descriptions do differentiate them (current totals vs. monthly arrays vs. per-recipe breakdown). The shipyard read/write pair is cleanly distinguished.

Naming Consistency4/5

All names share a consistent coi_ prefix and snake_case, which is highly predictable. The only deviation is the verb/noun mix: some are verb-first (list_products, find_shortages, size_recipe, add_shipyard_stock) while others are noun-first (game_info, product_stats, shipyard_stock). Readable and consistent enough, but not a uniform verb_noun pattern.

Tool Count5/5

With 9 tools, the surface is well-scoped for a game analytics/inspection purpose. Every tool earns its place: one discovery tool, several analysis facets, an offline calculator, and a mod-gated shipyard read/write pair. No redundant or filler tools.

Completeness4/5

The product-analysis lifecycle is well covered: lookup IDs, current stats, monthly history, source attribution, shortage ranking, and recipe sizing, plus game connection info. Minor gaps remain: the single write tool (coi_add_shipyard_stock) has no matching remove/clear operation and there is no recipe/machine ID discovery tool (agents must recover IDs from coi_product_sources). Those are workable but noticeable gaps.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues