Skip to main content
Glama

sc-bwapi-mcp

Enable AI assistants (e.g., Trae/Claude) to control StarCraft 1 through the BWAPI bridge via MCP (Model Context Protocol).

Architecture

星际1 (1.16.1) ← BWAPI 4.4.0 注入 (Chaoslauncher)
      ↕ 共享内存 + 命名管道
bwapi_bridge.exe (C++, TCP 12345)
      ↕ JSON over TCP
sc-bwapi-mcp (Python MCP server)
      ↕ MCP stdio
Trae / Claude / 任意 MCP 客户端

Related MCP server: zandronum-mcp

Prerequisites

Component

Version

Description

StarCraft

1.16.1

Standard edition (not Remastered); free download of Anthology from the Battle.net client

BWAPI

4.4.0

https://github.com/bwapi/bwapi/releases/tag/v4.4.0

Visual Studio

2022 Community

Check "Desktop development with C++" during installation

uv

0.12+

Python package manager https://astral.sh/uv

Chaoslauncher

(bundled with BWAPI)

Injects BWAPI.dll into the StarCraft process

Installation

1. Install StarCraft 1 + BWAPI

  1. Download StarCraft Anthology (free) from the Battle.net client and install it to a path without spaces, e.g., C:\Games\Starcraft

  2. Download BWAPI 4.4.0 and install it to a path without spaces, e.g., C:\libraries\BWAPI_440

  3. Set the environment variable BWAPI_DIR = C:\libraries\BWAPI_440

  4. Copy the contents of StarCraft\ and Windows\ from the BWAPI installation directory into the StarCraft directory

2. Build the BWAPI library (required on first run)

The .lib files for BWAPI 4.4.0 need to be built with VS2022:

$msbuild = "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
$env:BWAPI_DIR = "C:\libraries\BWAPI_440"

# 编译 BWAPILIB + BWAPIClient (Release x86)
& $msbuild "$env:BWAPI_DIR\BWAPILIB\BWAPILIB.vcxproj" /p:Configuration=Release /p:Platform=Win32 /m
& $msbuild "$env:BWAPI_DIR\BWAPIClient\BWAPIClient.vcxproj" /p:Configuration=Release /p:Platform=Win32 /m

# 编译 ExampleAIModule.dll (BWAPI 4.4.0 需要一个 AI 模块才能触发 onStart)
& $msbuild "$env:BWAPI_DIR\ExampleAIModule\ExampleAIModule.vcxproj" /p:Configuration=Release /p:Platform=Win32 /p:OutDir="<星际目录>\bwapi-data\AI\" /m

3. Build the bridge

cd <项目目录>
scripts\build_bridge.bat

Output: cpp\build\Release\bwapi_bridge.exe

4. Configure bwapi.ini

In the StarCraft directory, ensure bwapi-data\bwapi.ini has:

[ai]
ai = bwapi-data/AI/ExampleAIModule.dll
[auto_menu]
auto_menu = OFF

Usage

Startup order (important!)

  1. Run Chaoslauncher as administrator → Check "BWAPI Injector 4.4.0 [RELEASE]" → Don't click Start yet

  2. Start the bridge: scripts\run_bridge.bat (it waits for the BWAPI server)

  3. Click Start in Chaoslauncher → Enter StarCraft → Single Player → Expansion → Play Custom → Choose a map → Start

  4. After entering the game screen, the bridge automatically connects and pushes status

Configure MCP client

Add the following to Trae's MCP configuration:

{
  "mcpServers": {
    "sc-bwapi": {
      "command": "C:\\Users\\<你>\\.local\\bin\\uv.exe",
      "args": ["run", "--directory", "<项目路径>", "sc-bwapi-mcp"]
    }
  }
}

Restart Trae, and you can call the tools.

MCP tools

Tool

Parameters

Description

get_game_state

None

Reads game state (minerals/gas/supply/all units)

train

unit_type

Train a unit (e.g., Zerg_Drone)

build

worker_id, building_type, tile_x, tile_y

Build a building (automatically finds a buildable location)

move

unit_id, x, y

Move a unit to pixel coordinates

attack

unit_id, target_id

Attack a target unit

gather

worker_id, resource_id

Gather minerals/gas

stop

unit_id

Stop the current action

hold

unit_id

Hold position

chat

text

Send a message in game

Troubleshooting

  • Bridge stuck at "Game table mapping not found": StarCraft is not launched; it is waiting normally.

  • Bridge cannot connect to the pipe: Exit the game and re-enter (the previous bridge was force-killed, and BWAPI's connected flag is stuck).

  • build failed: The bridge uses getBuildLocation to find a location automatically; make sure there is empty space within the creep range.

  • 0 FPS: The computer configuration is insufficient; switch to 1v1 and press F5 in game to reduce speed.

Available Tools

9 tools
attackB

让指定单位攻击指定目标单位。

Inputs: unit_id (required), target_id (required).

buildB

让指定 worker 在 (tile_x, tile_y) 建造建筑。

坐标是格子(TilePosition),不是像素。例如:
    build(1, "Terran_Supply_Depot", 50, 100)

Inputs: tile_x (required), tile_y (required), worker_id (required), building_type (required).

chatA

在游戏内发送一条聊天/文字。

Inputs: text (required).

gatherB

让 worker 采集指定资源点(矿物/气矿)。

Inputs: worker_id (required), resource_id (required).

get_game_stateA

获取当前游戏状态 (最近一帧)。

返回 self(己方: 矿/气/供给/单位列表)、enemies(可见敌方单位)。
单位字段: id/type/x/y/hp/sh/player/owner。

Inputs: no named parameters.

holdC

让单位原地驻守(hold position)。

Inputs: unit_id (required).

moveB

让指定单位移动到像素坐标 (x, y)。

Inputs: x (required), y (required), unit_id (required).

stopB

让单位停止当前指令。

Inputs: unit_id (required).

trainA

训练单位。例如: train("Terran_SCV")、train("Protoss_Zealot")。

bridge 会找一个能训练该单位的己方建筑下达指令。

Inputs: unit_type (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 9 tools

    Disambiguation5/5

    每个工具都对应明确且不同的操作:查询状态、训练、建造、移动、攻击、采集、停止、驻守和聊天。即使 stop 与 hold 语义相近,但描述中一个表示停止指令、一个表示原地驻守,不会造成实质混淆。

    Naming Consistency4/5

    大多数工具采用简洁的单个动词命名,如 train、build、move、attack、gather,风格统一;但 get_game_state 是唯一的动词+名词 snake_case 形式,与其余工具命名模式略有偏差。整体仍易读可预测。

    Tool Count5/5

    9 个工具覆盖了 StarCraft 基础控制所需的常见操作,数量适中,没有冗余或明显臃肿。每个工具都有独立用途,规模与服务器定位匹配。

    Completeness3/5

    基础的状态查询、建造、训练和单位指令已具备,但缺少一些常见 RTS 操作如巡逻、攻击移动、修理、研究和升级,也没有取消或队列相关指令。这些缺口会限制复杂策略的实现,但核心流程仍可运行。

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      B
      maintenance
      Enables AI assistants to interact with the Zandronum game engine for development, including running commands, spawning actors, and loading maps.
      55
      28 npm
      3
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients like Claude Code, Claude Desktop and Cursor to search a StarCraft II knowledge base, upload replays, and get AI Coach reports on games. Users can also ask follow-up questions about a coached replay, with mineral costs gated behind explicit confirmation.
      10
      MIT