Inactivity policy (2026-10-01): disable the BIOS ten-minute idle request by clearing
User_Answer/HW_USR_ANSWER(0x6F86) bit 6; keep reserved bit 5 clear (HW_USR_ANSWER &= (u8)0x9F;). Continue handling every nonzeroHW_USR_SHUTDOWN(0x6F85), including battery and POWER requests. This is a precaution pending investigation, not a confirmed hardware-defect diagnosis.
Model Context Protocol server for NgpCraft — gives any MCP-compatible LLM the hardware-validated knowledge, API, examples, build and validation tooling to write working NGPC homebrew.
Install once, and every Claude Code / Cursor / Claude Desktop session gains the ability to look up real NGPC hardware facts, retrieve canonical ASM patterns, search a proven game's source by feature, scaffold and build a project, and run the result on a hardware-timed emulator — instead of hallucinating half-correct code that crashes on silicon.
Using this from an AI agent? Read AGENT_GUIDE.md first. It maps symptom → tool, explains the save-state workflow for reproducing a user's bug, and covers the BIOS requirement — without a real
bios.binthe emulator renders a plausible but wrong picture. It is also served as the MCP resourcengpc://doc/agent_guide.
Writing NGPC code with an LLM today without context = hallucinated C99 constructs the compiler rejects, toolchain mis-encodes (a D0 prefix wrongly emitted for a register op) and broken silicon opcodes (add A,C = CB 81 C-source ALU), wrong ABI, forgotten NGP_FAR on ROM data, etc. The user ends up debugging on real hardware what should have been caught before code was written.
cd /path/to/NgpCraft_MCP
npm installAdd to ~/.claude/mcp.json (or equivalent for your client):
{
"mcpServers": {
"ngpcraft": {
"command": "node",
"args": ["/absolute/path/to/NgpCraft_MCP/src/server.js"]
}
}
}Restart your MCP client. Tools will appear prefixed with mcp__ngpcraft__*.
Any of these prompts should now work:
- "Use the NGPC bug checker to look up D0 prefix."
- "Search NGPC docs for DMA VBlank restrictions."
- "Show me StarGunner's state machine implementation."
- "Give me the canonical ASM for enabling VBlank interrupts."
- "Create a new NGPC project with ngpc_build and build it."
Restart the server after any corpus change: ngpc_doc_search indexes the corpus at start-up.
| Tool | Status | Purpose |
|---|---|---|
ngpc_bug_check |
working | Query silicon + toolchain bug DB by opcode/keyword |
ngpc_asm_pattern |
working | Retrieve hardware-safe ASM patterns (prologue, LDIRW, DMA load, etc.) |
ngpc_doc_search |
working | Full-text search across the NGPC dev wiki corpus (wiki/ + DENSE_INDEX + StarGunner docs) |
ngpc_api_lookup |
working | Look up template function signatures from vendor/templates/base/src/**/*.h |
ngpc_example |
working | Grep StarGunner + Windcup RE by feature keyword |
ngpc_new_project |
working | Scaffold from base / cavegen / platformer / racer template |
ngpc_lint |
working | Hardware-fidelity lint via NGPC_Interp.compile (HW-1/HW-2/HW-3b) |
ngpc_quickrun |
working | Transpile + run main() generator N vsync ticks, return state digest |
ngpc_screenshot |
working | PNG of framebuffer at frame N (fake canvas + pngjs) |
ngpc_png_to_sprite |
working | PNG → sprite C/H via NGPC_AssetTools.exportSprite |
ngpc_png_to_tilemap |
working | PNG → tilemap C/H via NGPC_AssetTools.exportTilemap |
ngpc_font_bake |
stub | PNG → NGPC 2bpp font data — bake pipeline lives outside the live editor |
ngpc_disasm |
working | Disassemble ROM/byte range via ngpc_disasm.py bridge |
ngpc_emu_rom_info |
working | Parse ROM header + bootstrap reset state via NgpCraft emulator |
ngpc_emu_native_run |
working | Runs the game on the native C++ core: load a player save state (.s0), hold buttons, advance frames, return registers + a beam-accurate screenshot. Needs a real bios.bin. |
ngpc_emu_peek |
working | Read bytes from emulated memory bus |
ngpc_emu_decode |
working | Decode one TLCS-900 instruction at address |
ngpc_emu_step_trace |
working | Run N instructions from boot/address, return trace + CPU state |
ngpc_emu_trace_exec |
working | Per-record execution trace — CPU before/after, flag changes, memory writes per instruction (vs step_trace's condensed result) |
ngpc_emu_breakpoint |
working | Per-ROM PC-address breakpoint registry + event-log match |
ngpc_emu_eventlog_profile |
working | Bucket an event-log v1 JSON file by owning symbol via a t900ld .map |
ngpc_emu_map_lookup |
working | Resolve symbols from a t900ld .map file |
ngpc_emu_memory_dump |
working | Hexdump-style multi-row memory inspector |
ngpc_emu_oam_info |
working | Decode the K2GE OAM (0x8800..0x88FF, 64 sprites × 4 bytes) and the CP.C palette-code strip (0x8C00..0x8C3F) |
ngpc_emu_opcode_coverage |
working | Linear-walk a ROM from its entry point and report which leading-byte opcodes the current TLCS-900/H decoder does NOT yet handle |
ngpc_emu_palette_info |
working | Decode the K2GE palette RAM (0x8200..0x83FF) into a human view: 16 palettes × 4 entries (12-bit 0BGR) for each plane (sprite / SCR1 / SCR2 /… |
ngpc_emu_registers |
working | Rich CPU register view: 8 R32 with their R16/R8 decomposition (XWA → WA → W/A …), PC, SR, IFF level, RFP bank pointer, and the six modeled flags… |
ngpc_emu_run_until |
working | Run the emulator forward until PC reaches target_pc, an honest stop is hit, or max_steps is exhausted |
ngpc_emu_screenshot |
working | Compose a K2GE framebuffer (160×152) from memory and return PNG base64. Static state only — for a scrolling game or a raster split use ngpc_emu_native_run, which draws as the beam passes |
ngpc_emu_tick_frame |
working | Advance the K2GE frame/scanline state model (M3 Phase 0+) |
ngpc_emu_tile_view |
working | Render one 8×8 tile from CHAR_RAM as 4-level grayscale ASCII art ( ░▒█) |
ngpc_emu_tilemap_info |
working | Decode one K2GE scroll-plane tilemap (SCR1 @ 0x9000 or SCR2 @ 0x9800, 32×32 tiles × 2 bytes/cell) |
ngpc_emu_tiles_view |
working | Render a grid of CHAR_RAM tiles as a binary PPM atlas, returned as PNG base64 |
ngpc_emu_watchpoint |
working | Per-ROM memory watchpoint registry + event-log match (v3 format) |
ngpc_psg_trace |
working | Run code N frames + return PSG event log (tone/attn/noise writes by frame) |
ngpc_visual_diff |
working | Render two C snippets at frame N + return per-pixel diff PNG (magenta on dimmed grey) |
ngpc_validate_project |
working | Lint every .c file under a directory, aggregated report (per file, per rule) |
ngpc_compile_official |
working (local toolchain) | Build a project via the LOCAL Toshiba toolchain (cc900 + asm900 + tulink + tuconv + s242ngp). Returns produced ROM. The .exe stay on the user's PC — never bundled or redistributed. |
ngpc_build |
working (alpha) | Create (new) or build (build) a project with the bundled NgpCraft toolchain (open-source C compiler + assembler + linker for the TLCS-900/H, vendor/ngpcraft_toolchain/): makefile projects (old templates included) or every .c/.asm of src/; debug writes the .ngdbg for the emulator's Source tab. No Toshiba program needed. ngpc_compile_official for a ROM that must ship. |
ngpc_compile_homemade |
legacy | Old v1 pipeline (t900cc), kept for reference — use ngpc_build instead |
ngpc_studio_event |
working | NgpCraft Studio (GB Studio projects for the NGPC): the exact JSON of any of the 156 GB Studio events — fields, defaults, a valid example, NGPC status (identical / adapted / refused). Use before writing an event by hand |
ngpc_studio_check |
working | NgpCraft Studio: one call = coherence (start scene / background / image that match nothing, variable past 511 — file, cause, fix), lint (GB Studio habits that misbehave on the NGPC, with fix), per-scene budget (tiles of 512, palettes), V3 compile with grouped warnings located by file / scene / event (error_at, warnings_at), ROM build, save slots that fit; optional official_loader check with GB Studio 4.3.2's own loader |
ngpc_studio_run |
working | NgpCraft Studio: play the game from any scene on the native core, scripted buttons / teleport / variable writes / power cycle, returns variables BY NAME and screenshots as images. Clean-room HLE BIOS included |
ngpc_studio_save |
working | NgpCraft Studio: read the cartridge's save journal (slots, signature of this build or not, variables by name) |
The ngpc_studio_* tools serve NgpCraft Studio: GB Studio 4.3.2 projects compiled for the NGPC by the
NgpCraft V3 compiler. They run src/tools/studio/ngpc_studio.py with the V3 found like the editor finds it
(v3_root argument, NGPCRAFT_V3_HOME, or the copy bundled with an installed NgpCraft Studio, whose Python
is used too), the Toshiba toolchain to link a ROM (toolchain_path, NGPC_TOSHIBA_HOME, default C:\t900),
and this repository's emulator core with its clean-room HLE BIOS (vendor/emulator/hle_bios/), the BIOS the
editor's own player uses for these games. The event catalogue src/data/studio_events.json is built from the
editor's event definitions by scripts/build_studio_events.mjs; the rules an agent needs are in
corpus/studio/NGPCRAFT_STUDIO_RULES.md (found by ngpc_doc_search). Smoke test:
node scripts/smoke_studio_tools.mjs <project> <work dir> [<v3 root>].
ngpc_build spawns python vendor/ngpcraft_toolchain/ngpcraft.py new|build. The vendored toolchain is
synchronised from the NgpCraft_Toolchain repository by scripts/sync_vendor_toolchain.sh <checkout>. The
first build of a project is slow (the compiler is written in Python); compiled modules are cached afterwards.
The transpiler-backed tools (ngpc_lint / ngpc_quickrun / ngpc_screenshot / ngpc_visual_diff / ngpc_psg_trace / ngpc_png_to_*) load the Live Editor JS modules into a Node vm context via src/tools/_transpiler_loader.js — no browser, no DOM. Audio (PSG) is intentionally not initialised: voice register state is preserved but no WebAudio context is created.
For ngpc_screenshot, a fake CanvasRenderingContext2D captures the framebuffer; PNG encoding goes through pngjs.
For ngpc_png_to_sprite / ngpc_png_to_tilemap, PNG decoding goes through pngjs (replaces the browser-only URL.createObjectURL + Image path used inside asset_tools.decodePng).
The ngpc_emu_* tools spawn python vendor/emulator/ngpc_emu.py <cmd> --json (Python 3 required on the host). They cover ROM parsing, memory bus reads, decode/execute and the K2GE inspectors, and they read static state — a ROM at reset or a save state.
ngpc_emu_native_run is the exception: it spawns python vendor/emulator/ngpc_native.py run --json and executes the machine on the native C++ core (VDP, PSG, IRQ and the timing model), drawing the frame line by line as the beam passes. It needs the compiled core in vendor/emulator/cpp/build/ and, for most commercial games, a real bios.bin.
⏱️ It is timed like hardware. The raw core defaults to free instruction fetch for backward compatibility, which runs ~2.9× too fast; this bridge applies the silicon-calibrated set (
cart_wait=3,cart_data_wait=0,ldir_cost=14) and reports which model ran in the answer'stimingfield.timing: "free"opts back out, for reproducing a pre-wait-state measurement and nothing else.🩺 Every run returns
hw_safety— a starved watchdog (a real console resets itself) or a stack that crossed into the BIOS page. Counted, not fatal, exactly as on hardware;hw_guard: truemakes the first one stop the run. See AGENT_GUIDE.md for how to report them.
| For | You need |
|---|---|
| the server | Node 20+ |
every ngpc_emu_* tool, ngpc_disasm |
Python 3 on PATH |
ngpc_build |
Python 3.11+ on PATH |
ngpc_emu_native_run, ngpc_studio_run |
the compiled native core in vendor/emulator/cpp/build/ |
ngpc_compile_official, ngpc_studio_check (ROM link) |
your own local Toshiba toolchain (toolchain_path, NGPC_TOSHIBA_HOME, default C:\t900) — never bundled |
| running or rendering a commercial game | a real bios.bin, supplied by you — never shipped here |
vendor/emulator/hle_bios/.
Exposed via ngpc:// URIs — clients that support MCP resources can read them directly without a tool call.
ngpc://doc/agent_guide— symptom → tool map, save-state workflow, BIOS requirementngpc://doc/quickstart— orientation for AI agentsngpc://doc/hw_registers— hardware register mapngpc://doc/palettes— RGB444, 16 palettes, transparencyngpc://doc/sprites— 64 sprites, OAM, metaspritesngpc://doc/tilemaps— SCR1/SCR2, scroll, mapstreamngpc://doc/dma— DMA channels and restrictionsngpc://doc/audio— T6W28 PSG, BGM formatngpc://doc/input— joypad register, edge detectngpc://doc/bios— BIOS calls, SYSFONT, power buttonngpc://doc/asm— TLCS-900/H ASM guidengpc://doc/t900_dense_ref— opcode referencengpc://doc/collision— AABB, tilemap collisionngpc://doc/math— Q8.8, LUT, sin_tablengpc://doc/game_loop— VBlank sync, frame budgetngpc://doc/asset_pipeline— PNG → NGPC asset conventionsngpc://doc/storage— flash save, RTCngpc://doc/language— cc900/t900cc C subset + gotchasngpc://doc/build_toolchain— Makefile + linkerngpc://doc/debug_tools— emulator + hw test workflowngpc://doc/measuring_performance— frame budget, cycle counts, stack measurementngpc://doc/gameplay_patterns— reusable gameplay structuresngpc://example/stargunner/shmup_doc— full shmup architecturengpc://example/stargunner/retex— porting post-mortem
NgpCraft_MCP/
├── package.json
├── README.md ← you are here
├── AGENT_GUIDE.md ← symptom → tool map for AI agents
├── CHANGELOG.md
├── src/
│ ├── server.js ← MCP stdio entrypoint
│ ├── tools/ ← one file per tool + index.js (registry)
│ │ ├── _emu_bridge.js ← Python spawn helper (static inspectors)
│ │ ├── _native_bridge.js ← Python spawn helper (native core)
│ │ ├── _studio_bridge.js ← NgpCraft Studio bridge
│ │ ├── _transpiler_loader.js ← shared vm loader for live-editor JS
│ │ ├── _png_decode.js ← pngjs wrapper
│ │ ├── _ppm_to_png.js ← PPM atlas → PNG
│ │ └── studio/ ← ngpc_studio.py (Studio check / run / save)
│ ├── resources/
│ │ └── index.js ← URI → corpus file mapping
│ └── data/
│ ├── bugs_silicon.json ← curated from hw-validation sessions
│ ├── asm_patterns.json ← canonical hw-safe ASM
│ └── studio_events.json ← the 156 GB Studio events (generated)
├── corpus/ ← markdown corpus (doc_search source)
│ ├── DENSE_INDEX.md ← high-density entry point (map + cheat-sheet)
│ ├── wiki/ ← the NGPC dev wiki (hardware, CPU/toolchain, graphics, audio, systems, pipeline & patterns)
│ ├── stargunner/ ← SHMUP + TEMPLATE_RETEX (reference game architecture)
│ └── studio/ ← NgpCraft Studio rules sheet
├── scripts/ ← vendor sync, Studio event catalogue, smoke tests
└── vendor/ ← bundled NgpCraft sub-projects (all MIT — see vendor/*/LICENSE)
├── ngpcraft_toolchain/ ← NgpCraft toolchain v2: ngpcraft.py (C compiler, asm900-syntax assembler, linker)
├── toolchain/ ← legacy v1 pipeline: t900cc / t900as / t900ld / ngpc_romtool
├── emulator/ ← ngpc_emu.py (static inspectors) + ngpc_native.py + cpp/ (native core) + hle_bios/
├── disasm/ ← ngpc_disasm.py + MANUAL
├── transpiler/ ← live-editor JS core (interpreter, runtime, vdp, psg, asset tools)
├── templates/ ← base + cavegen + platformer + racer
└── examples/
├── stargunner/ ← full game src + docs (NgpCraft template + APIs)
└── windcup_re/ ← a game on the legacy 2000s template (reference for that older API)
- The NGPC dev wiki (
corpus/wiki/) + a high-densityDENSE_INDEX.md— the core knowledge, cleaned and engine-agnostic. - Structured knowledge —
bugs_silicon.json+asm_patterns.json, hand-curated from hardware-validation sessions. - The NgpCraft toolchain (
vendor/ngpcraft_toolchain/, synchronised from the NgpCraft_Toolchain repository byscripts/sync_vendor_toolchain.sh) — drivesngpc_build: C compiler, assembler (asm900 syntax) and linker (also reads the vendor.rel/.lib), cartridge header and ROM file. Alpha: assembler and linker mature, C compiler experimental. - The legacy v1 toolchain (
vendor/toolchain/: t900cc / t900as / t900ld / ngpc_romtool) — drivesngpc_compile_homemade, kept for reference.⚠️ A teaching pipeline, not a compiler to build with: expect mis-compiles and unimplemented constructs. Usengpc_build(orngpc_compile_official) instead. - The emulator (
vendor/emulator/) — the staticngpc_emu_*inspectors (ROM parsing, memory bus, decode/execute, bounded run-steps, K2GE inspectors), the hardware-timed native C++ core behindngpc_emu_native_run/ngpc_studio_run, and a clean-room HLE BIOS. - The disassembler + the live-editor transpiler (lint / quickrun / screenshot / asset converters).
- Templates (base + 3 genre variants) and reference games (StarGunner on the NgpCraft template; Windcup on the legacy 2000s template).
- Proprietary Toshiba binaries (
cc900/asm900/tulink/tuconv/s242ngp,system.lib).ngpc_compile_officialinvokes the user's local install — nothing is bundled or redistributed. - The SNK BIOS (
bios.bin) — supplied by the user for commercial games. - ROM binaries — no value for code generation.
Every entry in src/data/bugs_silicon.json cites the validation reference (jalon / bisect / date). These are not speculative — they were reproduced on a real NGPC flash cart during NgpCraft development. The curated set captures findings that would otherwise only live in long-form dev logs.
Timing is calibrated too. Cartridge-flash wait-states were measured on silicon by hw_calibration/cpu_calib_v1.ngc (instruction fetch = 3 cycles/byte, cart data reads = 0) and ngpc_emu_native_run applies them, so a cycle figure from it is comparable to hardware. The one unsettled value, LDIR at 14 cycles/byte, is strongly evidenced but not yet pinned by a calibration ROM — the emulator's hw_calibration/README.md tracks what is proven and what is not.
MIT. Vendored snapshots retain their original licenses (see vendor/*/LICENSE).
| Project | Role |
|---|---|
| NgpCraft Live Editor | Browser playground, transpiler, lint |
| NgpCraft Toolchain | Open-source C compiler + assembler + linker for the TLCS-900/H (alpha) — exposed here as ngpc_build |
| NgpCraft Studio | GB Studio projects compiled for the NGPC by the V3 — exposed here as ngpc_studio_* |
| NgpCraft Emulator | NGPC emulator — Python inspectors (ngpc_emu_*) plus the native C++ core that runs games (ngpc_emu_native_run) |
| NgpCraft Base Template | Starter project + 3 genre variants (cavegen, platformer, racer) |
| NgpCraft Disasm | TLCS-900/H disassembler |
| NgpCraft Learn | Bilingual FR/EN course site |
| NgpCraft MCP | ← this project — LLM knowledge + validation layer |