c64bridge

chrisgleissner/c64bridge

3.4

If you are the rightful owner of c64bridge and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

C64 Bridge is a Model Context Protocol (MCP) server designed to interface with the Commodore 64 using AI.

Tools
3
Resources
0
Prompts
0

Logo

C64 Bridge

Your AI Command Bridge for the Commodore 64.

npm Build codecov License: GPL v2

Overview

C64 Bridge is a Model Context Protocol (MCP) server that drives a real Commodore 64 Ultimate or Ultimate 64 over their REST APIs.

It is based on the official TypeScript @modelcontextprotocol/sdk and supports both stdio (for local AI integration) and HTTP (for remote access by other applications).

Features

  • Program runners for BASIC, 6510 assembly, and PRG/CRT
  • Full memory access — read/write operations and text monitoring
  • System integration covering drives, files, and printers
  • SID audio tools for composition, playback, and analysis
  • Built-in knowledge base for smarter AI prompting using local examples and docs
  • Multiple backends: hardware C64 Ultimate (primary) and experimental VICE runner

Quick Start

  1. Install Node.js 24+ and npm
  • Linux (Ubuntu/Debian)

    • Recommended:
      sudo apt update
      sudo apt install -y curl ca-certificates
      curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
      sudo apt install -y nodejs
      
    • Fallback (may be older): sudo apt install -y nodejs npm
  • macOS

    brew install node@24
    brew link --overwrite node@24
    
  • Windows

    # winget
    winget install OpenJS.NodeJS.LTS
    # or Chocolatey
    choco install nodejs-lts -y
    

Verify: node --version → v24.x

  1. Run the server (choose one)
  • npx (zero setup)

    npx -y c64bridge@latest
    
  • npm (project‑local)

    mkdir -p ~/c64bridge && cd ~/c64bridge
    npm init -y
    npm install c64bridge
    node ./node_modules/c64bridge/dist/index.js
    
  • From source (contributing/testing)

    git clone https://github.com/chrisgleissner/c64bridge.git
    cd c64bridge
    npm install
    npm start
    

On start, the server probes your target (REST + zero‑page read) and prints diagnostics before announcing that it is running on stdio.

Configure

Configuration is a JSON file resolved in this order (first match wins):

  1. C64BRIDGE_CONFIG → absolute path
  2. ~/.c64bridge.json
  3. ./c64bridge.json

No file? Defaults to host=c64u, port=80.

Hardware (C64U) example:

{
  "c64u": { "host": "<hostname or IP>", "port": 80 }
}

Experimental VICE runner:

{
  "vice": { "exe": "/usr/bin/x64sc" }
}

Backend selection:

  • C64_MODE=c64u|vice forces a choice
  • Otherwise: if only one is configured, it’s used; with both, prefer c64u; with none, probe http://c64u then fall back to VICE

Logging: set LOG_LEVEL=debug (logs go to stderr; stdout is reserved for MCP).

GitHub Copilot Chat (VS Code)

VS Code (1.102+) and Copilot Chat (1.214+) support MCP. Either let VS Code auto‑discover, or add the server explicitly under Settings → GitHub Copilot → Experimental → MCP Servers (see AGENTS.md).

Example explicit entry:

{
  "github.copilot.chat.experimental.mcp": {
    "servers": [
      {
        "name": "c64bridge",
        "command": "node",
        "args": ["./node_modules/c64bridge/dist/index.js"],
        "type": "stdio"
      }
    ]
  }
}

Tips:

  • If you’re in this repo, open .vscode/mcp.json and click Start to launch the server.
  • In Chat, pick the “C64” chat mode and try: “Print a greeting on the screen”.

Screenshots:

VS Code MCP start VS Code C64 chat mode VS Code C64 Hello World

Example

Compose a children’s song with ChatGPT + VS Code:

duck song

Then render PETSCII art for it:

duck petscii

HTTP Invocation

  • Preferred transport is stdio. The HTTP bridge is disabled by default; enable it only for manual testing
  • These curl commands are illustrative to show what happens under the hood when tools run.
# Upload and run BASIC
curl -s -X POST -H 'Content-Type: application/json' \
  -d '{"op":"upload_run_basic","program":"10 PRINT \"HELLO\"\n20 GOTO 10"}' \
  http://localhost:8000/tools/c64_program | jq

# Read current screen (PETSCII→ASCII)
curl -s -X POST -H 'Content-Type: application/json' \
  -d '{"op":"read_screen"}' \
  http://localhost:8000/tools/c64_memory | jq

# Reset the machine
curl -s -X POST -H 'Content-Type: application/json' \
  -d '{"op":"reset"}' \
  http://localhost:8000/tools/c64_system

Build & Test

  • npm install (or bun install) — install deps
  • npm start — dev server (ts-node)
  • npm run build — type‑check and build
  • npm test — integration tests (mock)
  • npm test -- --real — target real hardware (reuses your config)
  • npm run coverage — coverage via Bun harness

Documentation

  • — development workflow and RAG details
  • — primer injected ahead of prompts
  • — REST surface (OpenAPI 3.1)
  • — LLM-facing quick setup, usage, and personas

MCP API Reference

This MCP server exposes 12 tools, 25 resources, and 7 prompts for controlling your Commodore 64.

Tools

c64_config

Grouped entry point for configuration reads/writes, diagnostics, and snapshots.

OperationDescriptionRequired InputsNotes
batch_updateApply multiple configuration updates in a single request.
diffCompare the current configuration with a snapshot.path
getRead a configuration category or specific item.category
infoRetrieve Ultimate hardware information and status.
listList configuration categories reported by the firmware.
load_flashLoad configuration from flash storage.
read_debugregRead the Ultimate debug register ($D7FF).
reset_defaultsReset firmware configuration to factory defaults.
restoreRestore configuration from a snapshot file.path
save_flashPersist the current configuration to flash storage.
setWrite a configuration value in the selected category.category, item, value
shuffleDiscover PRG/CRT files and run each with optional screen capture.
snapshotSnapshot configuration to disk for later restore or diff.path
versionFetch firmware version details.
write_debugregWrite a hex value to the Ultimate debug register ($D7FF).value
c64_disk

Grouped entry point for disk mounts, listings, image creation, and program discovery.

OperationDescriptionRequired InputsNotes
create_imageCreate a blank disk image of the specified format.format, path
file_infoInspect metadata for a file on the Ultimate filesystem.path
find_and_runSearch for a PRG/CRT by name substring and run the first match.nameContains
list_drivesList Ultimate drive slots and their mounted images.
mountMount a disk image with optional verification and retries.drive, imagesupports verify
unmountRemove the mounted image from an Ultimate drive slot.drive
c64_drive

Grouped entry point for drive power, mode, reset, and ROM operations.

OperationDescriptionRequired InputsNotes
load_romTemporarily load a custom ROM into an Ultimate drive slot.drive, path
power_offPower off a specific Ultimate drive slot.drive
power_onPower on a specific Ultimate drive slot.drive
resetIssue an IEC reset for the selected drive slot.drive
set_modeSet the emulation mode for a drive slot (1541/1571/1581).drive, mode
c64_extract

Grouped entry point for sprite/charset extraction, memory dumps, filesystem stats, and firmware health checks.

OperationDescriptionRequired InputsNotes
charsetLocate and extract 2KB character sets from RAM.
firmware_healthRun firmware readiness checks and report status metrics.
fs_statsWalk the filesystem and aggregate counts/bytes by extension.
memory_dumpDump a RAM range to hex or binary files with manifest metadata.address, length, outputPath
spritesScan RAM for sprites and optionally export .spr files.address, length
c64_graphics

Grouped entry point for PETSCII art, sprite previews, and future bitmap generation.

OperationDescriptionRequired InputsNotes
create_petsciiGenerate PETSCII art from prompts, text, or explicit bitmap data.
generate_bitmapReserved high-resolution bitmap generator (coming soon).
generate_spriteBuild and run a sprite PRG from raw 63-byte sprite data.sprite
render_petsciiRender PETSCII text with optional border/background colours.text
c64_memory

Grouped entry point for memory I/O, screen reads, and screen polling.

OperationDescriptionRequired InputsNotes
readRead a range of bytes and return a hex dump with address metadata.address
read_screenReturn the current 40x25 text screen converted to ASCII.
wait_for_textPoll the screen until a substring or regex appears, or timeout elapses.pattern
writeWrite a hexadecimal byte sequence into RAM.address, bytessupports verify
c64_printer

Grouped entry point for Commodore and Epson printing helpers.

OperationDescriptionRequired InputsNotes
define_charsDefine custom printer characters (Commodore DLL mode).firstChar, chars
print_bitmapPrint a bitmap row via Commodore (BIM) or Epson ESC/P workflows.printer, columns
print_textGenerate BASIC that prints text to device 4.text
c64_program

Grouped entry point for program upload, execution, and batch workflows.

OperationDescriptionRequired InputsNotes
batch_runRun multiple PRG/CRT programs with post-run assertions.programs
bundle_runCapture screen, memory, and debug registers into an artifact bundle.runId, outputPath
load_prgLoad a PRG from Ultimate storage without executing it.path
run_crtMount and run a CRT cartridge image.path
run_prgLoad and execute a PRG located on the Ultimate filesystem.path
upload_run_asmAssemble 6502/6510 source, upload the PRG, and execute it.programsupports verify
upload_run_basicUpload Commodore BASIC v2 source and execute it immediately.programsupports verify
c64_rag

Grouped entry point for BASIC and assembly RAG lookups.

OperationDescriptionRequired InputsNotes
asmRetrieve 6502/6510 assembly references from the local knowledge base.q
basicRetrieve BASIC references and snippets from the local knowledge base.q
c64_sound

Grouped entry point for SID control, playback, composition, and analysis workflows.

OperationDescriptionRequired InputsNotes
analyzeAutomatically analyze SID playback when verification is requested.request
compile_playCompile SIDWAVE or CPG source and optionally play it immediately.
generateGenerate a lightweight SID arpeggio playback sequence.
note_offRelease a SID voice by clearing its gate bit.voice
note_onTrigger a SID voice with configurable waveform, ADSR, and pitch.
pipelineCompile a SIDWAVE score, play it, and analyze the recording.supports verify
play_mod_filePlay a MOD tracker module via the Ultimate SID player.path
play_sid_filePlay a SID file stored on the Ultimate filesystem.path
record_analyzeRecord audio for a fixed duration and return SID analysis metrics.durationSeconds
resetSoft or hard reset of SID registers to clear glitches.
set_volumeSet the SID master volume register at $D418 (0-15).volume
silence_allSilence all SID voices with optional audio verification.supports verify
c64_stream

Grouped entry point for starting and stopping Ultimate streaming sessions.

OperationDescriptionRequired InputsNotes
startStart an Ultimate streaming session toward a host:port target.stream, target
stopStop an active Ultimate streaming session.stream
c64_system

Grouped entry point for power, reset, menu, and background task control.

OperationDescriptionRequired InputsNotes
list_tasksList known background tasks with status metadata.
menuToggle the Ultimate menu button for navigation.
pausePause the machine using DMA halt until resumed.
poweroffRequest a controlled shutdown via the Ultimate firmware.
rebootTrigger a firmware reboot to recover from faults.
resetIssue a soft reset without cutting power.
resumeResume CPU execution after a DMA pause.
start_taskStart a named background task that runs on an interval.name, operation
stop_all_tasksStop every running background task and persist state.
stop_taskStop a specific background task and clear its timer.name

Resources

NameSummary
c64://docs/indexExplains how to approach each knowledge bundle and when to consult it.
c64://context/bootstrapStep-by-step rules for safe automation, verification, and rollback on the C64.
c64://specs/basicToken definitions, syntax rules, and device I/O guidance for BASIC v2.
c64://docs/basic/pitfallsQuickref covering quotation handling, line length, tokenization, variable names, and other BASIC traps.
c64://specs/assemblyOfficial opcode matrix, addressing modes, and zero-page strategy for the 6510 CPU.
c64://specs/sidRegister map, waveform behaviour, and ADSR envelopes for expressive SID playback.
c64://specs/sidwaveDefines the SIDWAVE interchange format used by the SID composer workflow.
c64://docs/sid/file-structureExplains PSID/RSID headers, metadata blocks, and compatibility notes for imported music.
c64://docs/sid/best-practicesCaptures proven waveforms, ADSR presets, phrasing, and verification workflow for pleasant SID music.
c64://specs/vicCovers raster timing, sprite control, colour RAM, and bitmap modes on the VIC-II.
c64://specs/charsetCharacter code table mapping PETSCII codes to screen codes, glyphs, and keyboard input.
c64://docs/petscii-styleDocuments colour palette, readability presets, dithering patterns, and best practices for creating artistic and readable PETSCII displays.
c64://docs/sprite-charset-workflowsDocuments sprite and charset workflows, memory layout, VIC-II configuration, common pitfalls, and proven techniques for hardware-accelerated graphics.
c64://specs/memory-mapPage-by-page breakdown of the 64 KB address space with hardware, ROM, and RAM regions.
c64://specs/memory-lowDocuments zero-page variables, BASIC pointers, and KERNAL workspace addresses.
c64://specs/memory-kernalLists KERNAL ROM vectors and service routines for OS-level functionality.
c64://specs/ioCovers VIC-II, SID, CIA, and system control registers with address ranges and usage notes.
c64://specs/ciaDetails CIA 1/2 registers, timers, interrupts, and keyboard matrix layout.
c64://specs/printerCovers device setup, control codes, and Ultimate 64 integration for printers.
c64://docs/printer/guideQuick-look workflow covering setup, troubleshooting, and sample jobs for both printer families.
c64://docs/printer/commodore-textCharacter sets, control codes, and formatting for Commodore MPS text output.
c64://docs/printer/commodore-bitmapDetails bitmap modes, graphics commands, and data layout for MPS bitmap printing.
c64://docs/printer/epson-textLists ESC/P control codes and formatting advice for Epson FX text output.
c64://docs/printer/epson-bitmapExplains bit-image modes, density options, and data packing for Epson bitmap jobs.
c64://docs/printer/promptsReusable prompt templates that drive complex printer jobs through the MCP server.

Prompts

NameDescription
assembly-programAuthor 6502/6510 assembly routines with precise hardware guidance.
basic-programPlan, implement, and verify Commodore BASIC v2 programs safely.
drive-managerMount, create, or power drives while preserving running workloads.
graphics-demoCreate VIC-II graphics demos with safe setup and validation steps.
memory-debugInspect or patch memory ranges with reversible steps and logging.
printer-jobSend formatted output to Commodore or Epson printers with safe teardown steps.
sid-musicCompose SID music with expressive phrasing and iterative audio verification.