Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
FAL_KEYNoRequired if SPRITE_PROVIDER is 'fal'
GBS_ROM_OUTNoOutput directory for build_rom (default: <root>/build)
GBS_CLI_PATHNoAbsolute path to gb-studio-cli.js (optional, probes common install locations)
GBS_LOG_PATHNoCaptured compile log path (default: <root>/build/compile.log)
GEMINI_API_KEYNoRequired if SPRITE_PROVIDER is 'gemini'
OPENAI_API_KEYNoRequired if SPRITE_PROVIDER is 'openai'
GBS_MGBA_RUNNERNoPath to a libmgba-linked runner binary for run_emulator (optional)
SPRITE_PROVIDERNoProvider for sprite generation: openai, gemini, replicate, or fal (optional)openai
GBS_PROJECT_ROOTYesDirectory containing <name>.gbsproj (required)
GBS_SCREENSHOT_DIRNoWhere run_emulator drops PNGs (default: <root>/build/screenshots)
REPLICATE_API_TOKENNoRequired if SPRITE_PROVIDER is 'replicate'

Capabilities

Features and capabilities supported by this server

CapabilityDetails
tools
{
  "listChanged": true
}

Tools

Functions exposed to the LLM to take actions

NameDescription
list_scenesA

List every scene in the active project. Returns id, name, type, width/height (in tiles), backgroundId, and actor/trigger counts. Use this for orientation before reading a specific scene.

read_sceneA

Return the full structured representation of one scene: metadata, actors[], triggers[], and scene-level scripts (script, playerHit1Script, playerHit2Script, playerHit3Script). Does NOT include backgrounds, palettes, or sprites — fetch those separately if needed.

list_actorsA

List all actors in a scene with id, name, position, sprite sheet, and per-actor script presence flags (hasInteractScript / hasStartScript / hasUpdateScript / hasHit1Script / …). Use read_script to fetch event bodies.

read_scriptB

Return the ScriptEvent[] for a given owner and key. Each event has shape { id, command, args?, children? } where children is a Record<branchName, ScriptEvent[]> for composite events (if/switch/group). See the gbvm-scripting skill for command semantics.

patch_scriptA

Apply an ordered list of structured operations (insert / replace / delete) to a ScriptEvent[] array. Full-array replacement is intentionally unsupported — use delete + insert. Operations apply sequentially: each op's index refers to the array state AFTER all prior ops in this call. Persists the edited scene/customEvent to disk atomically. Before writing, the resulting tree is checked against the dialogue width budget (default 18 chars/line for EVENT_TEXT/EVENT_MENU/EVENT_CHOICE strings); violations refuse the write unless force: true.

set_variableA

Ensure a variable is initialised to value at game start by inserting/updating a VARIABLE_SET_TO_VALUE event at the top of the START SCENE's onInit script (GB Studio 4.x has no default-value field on Variable). Value must fit signed 16-bit (-32768..32767). The variable must already exist — to add a new variable, call create_variable first. For in-game variable changes during play, use patch_script instead.

build_romA

Invoke upstream gb-studio-cli (make:rom) to compile the project. Captures stdout+stderr to the configured compile log (read via read_compile_log). Returns { success, exitCode, romPath?, elapsedMs, stderrTail }. ALWAYS call this after structural edits before declaring work done. Requires GBS_CLI_PATH env var OR an installed GB Studio app in a standard location.

run_emulatorA

Launch the ROM via the bundled libmgba-linked gbs-mgba-runner with a scripted input timeline. Captures a PNG at the end (and optionally mid-run). Returns { success, screenshotPath, midScreenshotPath?, exitCode, elapsedMs, stderrTail }. Retrieve the image via the screenshot tool. Build the runner once with mcp-server/native/build.sh (needs a local mGBA checkout); or set GBS_MGBA_RUNNER to an absolute path.

screenshotA

Return an emulator screenshot as an image content block (base64 PNG). Call AFTER run_emulator. Defaults to the latest.png from run_emulator's final frame; pass filename to read a different file in the screenshot dir.

read_compile_logA

Read the full stdout+stderr captured from the last build_rom invocation. Use this INSTEAD of guessing when a build fails. Optionally returns only the last N lines via tailLines.

create_sceneA

Create a new scene folder + scene.gbsres under project/scenes/. Name is slugified for the on-disk folder; collisions get _2/_3 suffixes. Scene type must be uppercase (TOPDOWN, PLATFORM, ADVENTURE, POINTNCLICK, SHMUP, LOGO) — changing type later resets engine configuration, so pick deliberately. Size defaults to 20×18 tiles (one screen); scenes >20×18 scroll. Does not create a background — pass backgroundId of an existing background, or set it empty and add one later.

create_actorA

Append a new actor file under project/scenes//actors/. Enforces GB Studio hardware caps: up to MAX_ACTORS=20 per normal scene, MAX_ACTORS_SMALL=10 when scene width*height <= 160 tiles. Coordinates default to tiles. Pass spriteSheetId of an existing sprite, or leave empty (actor will not render until set).

create_triggerA

Append a new trigger file under project/scenes//triggers/. Triggers are rectangular zones that fire script on player enter and leaveScript on exit. Enforces MAX_TRIGGERS=30 per scene. Coordinates and size are in tiles.

create_variableA

Append a new Variable entry to project/variables.gbsres. Id is auto-assigned as the next numeric string. Symbol is auto-derived from name (camelCase → snake_case, e.g. 'curQ' → 'cur_q'). GB Studio variables are 16-bit signed (-32768..32767); set initial value via set_variable.

create_custom_eventA

Create a new script resource file under project/scripts/. Custom events are reusable scripts that can be called from scenes/actors/triggers. The script body starts empty — use patch_script with an ownerType: 'customEvent' locator to populate it.

set_start_sceneA

Patch startSceneId in project/settings.gbsres so the game boots into the given scene. Preserves every other setting field. The sceneId must resolve to an existing scene on disk, or build_rom will fail.

delete_sceneA

Recursively delete a scene folder (scene.gbsres + actors/ + triggers/). Refuses if the scene is the start scene, or if any other script references this sceneId (e.g. EVENT_SWITCH_SCENE) — pass force: true to override the reference check (the start-scene guard is unconditional). Use list_scenes to find target ids. There is no undo; commit your work first.

delete_actorA

Delete one actor file from a scene's actors/ directory. Refuses if any script references this actorId (including via property paths like <actorId>:x_pos); pass force: true to override. The actor's own scripts are not counted as external references — they are deleted with the file.

delete_triggerA

Delete one trigger file from a scene's triggers/ directory. Triggers are rarely referenced by other scripts (they only run on enter/leave), but the cross-reference check still runs for safety. Pass force: true to override. The trigger's own onEnter / onLeave scripts go away with the file.

delete_custom_eventA

Delete one custom-event (script resource) file under project/scripts/. Refuses if any script references this customEventId (typically via EVENT_CALL_CUSTOM_EVENT). Pass force: true to override. The custom event's own body is deleted with the file.

delete_variableA

Remove a Variable entry from project/variables.gbsres. Refuses if any script references the variable (e.g. VARIABLE_SET_TO_VALUE / IF_VARIABLE_VALUE; ScriptValue {type:"variable", value:<id>}). Pass force: true to override — but expect compile errors on the next build_rom unless every reference is repaired.

generate_spriteA

Generate a GB Studio sprite from a text prompt. Calls the configured image-generation provider (SPRITE_PROVIDER env var ∈ {openai, gemini, replicate, fal}; default openai), runs the result through a 4-colour DMG quantiser, and writes (sprite.png + sprite.png.gbsres) under assets/sprites/. Returns a spriteSheetId you can pass to create_actor immediately. Frames are 16×16; for multi the provider is called 3× (one per direction), for multi_movement 6× (idle + walk per direction). After quantisation a heuristic quality check runs; degenerate outputs refuse to save unless force: true.

convert_image_to_spriteA

Read a local PNG/JPG and convert it to a 4-colour DMG-quantised GB Studio sprite. For animationType=fixed the image is treated as one frame. For animationType=multi/multi_movement the input MUST already be a sprite sheet (3 frames wide for multi, 6 frames wide for multi_movement) — single-frame inputs cannot be expanded to multiple directions. After quantisation a heuristic quality check runs: degenerate outputs (near-empty, single-shade, low-detail) refuse to write unless force: true. No API key required.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gbs-toolkit/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server