Skip to main content
Glama

torch-mcp

License: MIT MCP Protocol HarbourMasters/Torch Distro: Arch & Ubuntu

torch-mcp is a production Model Context Protocol (MCP) server for HarbourMasters/Torch, the Nintendo 64 asset extractor, archive packer, and modding suite used in modern reverse-engineering PC ports (Ship of Harkinian, Star Fox 64, Paper Mario, etc.).

Audited against upstream commit 72960ca16f4723f96aaf4037b76072c230af8c11.


We strongly recommend copying CLAUDE.md into your project root or your global agent configuration (~/.claude/CLAUDE.md).

Key rules enforced in CLAUDE.md:

  • Targeted Mid-Run Order Handling (No Collateral Process Killing): If the user asks for code changes during an active run, only kill the exact conflicting process. Never kill background builds, daemons, watchers, or servers without asking first!

  • No Unauthorized Dependencies or Hand-Rolling: Prohibits agents from adding surprise packages or writing ad-hoc throwaway scripts when dedicated project CLI tools exist.

  • Multi-Distro Compatibility: Guaranteed compatibility across Arch Linux (pacman) and Ubuntu/Debian (apt).

  • Game Dev & Asset Pipeline Standards: Prevents recursive packing loops, verifies disk artifacts, and enforces direct argv array execution without shell quoting bugs.


Related MCP server: local-code-intel-mcp

Features

  • Strict Stdio Isolation: Zero non-protocol data leaked to stdout. All diagnostics, progress bars, and subprocess outputs are safely routed to stderr or encapsulated inside JSON-RPC tool responses.

  • Direct Argv Execution: Spawns torch using native argument arrays rather than /bin/sh -c strings, preventing shell injection and escaping issues with complex paths.

  • Post-Run Artifact Verification: Because Torch can return exit code 0 on certain errors (e.g. missing config.yml or unmatched ROM hash), torch-mcp inspects disk artifacts and file sizes to guarantee actual success.

  • Pre-Flight Validation: Computes ROM lowercase SHA-1 checksums, parses config.yml, checks game registration, and validates directory permissions before launching long extraction jobs.

  • Upstream Caveat Protection:

    • Guards against the broken torch binary upstream command by offering safe alternatives (torch_export_archive with O2R or torch_export_modding).

    • Enforces 3-component uint16 version parsing (X.Y.Z, 0–65535).

    • Safeguards torch pack to prevent recursive packing if the output target is inside the input directory.


Installation

Prerequisites

  • Node.js (>= 18)

  • tmux (for persistent background worker execution)

  • Linux (tested on Arch Linux and Ubuntu/Debian) or macOS

Automated Multi-Distro Installer

git clone https://github.com/CodeMasterCody3D/torch-mcp.git
cd torch-mcp
./install.sh

The installer will:

  1. Detect your package manager (pacman on Arch, apt on Ubuntu/Debian, dnf on Fedora, brew on macOS).

  2. Verify or automatically install tmux.

  3. Symlink torch-mcp to ~/.local/bin/torch-mcp.

  4. Run the automated test suite.

Optional: Compile Torch from Source

If Torch is not already installed on your system, install.sh can automatically clone, configure, and build it with Ninja and StormLib:

./install.sh --build-torch

Claude Desktop & Claude Code Setup

Claude Desktop

Add to your ~/.claude/claude_desktop_config.json:

{
  "mcpServers": {
    "torch": {
      "command": "torch-mcp",
      "env": {
        "TORCH_PATH": "/home/cody/.local/bin/torch"
      }
    }
  }
}

Claude Code CLI

claude mcp add torch torch-mcp

MCP Tools Catalog

Tool

Purpose

Key Parameters

torch_capabilities

Inspect Torch binary, registered CLI subcommands, compiled modules, and known caveats

subcommand, torch_path

torch_validate_project

Pre-flight check: ROM SHA1 checksum, config.yml match, output write permissions

rom_path, srcdir, destdir, single_yaml

torch_export_archive

Extract ROM assets into .o2r (ZIP archive) or .otr (StormLib)

rom_path, format, srcdir, destdir, version, single, additional_files

torch_export_code

Export decompiled C source code representation of assets

rom_path, srcdir, destdir, verbose, single

torch_export_headers

Generate C asset headers (--otr for OTR/O2R style)

rom_path, srcdir, destdir, otr

torch_export_modding

Export editable assets and modding.yml (raw or --xml)

rom_path, srcdir, destdir, xml

torch_import_modding

Import edited assets back into code, otr, o2r, or header

mode, rom_path, srcdir, destdir, verbose

torch_pack_archive

Pack existing directory into .o2r or .otr archive (no ROM needed)

folder, target, format, version

torch_bk64_hashes

Generate Banjo-Kazooie asset table hashes from ROM offset 0x5E90

rom_path, output_path

torch_diagnose_binary

Explains upstream torch binary bug and provides working alternatives

rom_path

torch_render_sequences

Headless audio rendering: outputs 32kHz 16-bit PCM WAV sequence driver previews

rom_path, wav_outdir, filter

torch_parse_config

Parse and inspect config.yml games, GBI settings, output paths, and segments

config_path


Game Porting & Reverse Engineering Workflows

1. Tribes 2 & Torque Asset Porting Pipeline

When porting older games like Tribes 2 (Torque Game Engine) to modern engines or cross-compiling assets:

  • Legacy Torque assets typically consist of:

    • 3D Shapes: .dts (DTS mesh hierarchy)

    • Interiors: .dif (CSG interior structures)

    • Terrain: .ter (heightmaps)

    • Missions: .mis & Scripts: .cs

    • Textures: .dds / .png

  • Use torch_pack_archive to bundle converted game resources directly into .o2r or .otr virtual filesystems for modern ports.

  • Use torch_validate_project to ensure all asset paths and manifests resolve cleanly before starting bulk conversions.

2. Standard N64 Extraction Walkthrough

  1. Validate Pre-Flight:

    {
      "name": "torch_validate_project",
      "arguments": {
        "rom_path": "/path/to/baserom.z64",
        "srcdir": "/path/to/project",
        "destdir": "/path/to/output"
      }
    }
  2. Export O2R Resource Archive:

    {
      "name": "torch_export_archive",
      "arguments": {
        "rom_path": "/path/to/baserom.z64",
        "format": "o2r",
        "srcdir": "/path/to/project",
        "destdir": "/path/to/output",
        "version": "1.0.0"
      }
    }
  3. Modding Round-Trip:

    • Run torch_export_modding to dump editable assets into output/modding/.

    • Modify the textures or models in output/modding/.

    • Run torch_import_modding with mode o2r to re-inject modified assets into a fresh game archive.


Technical Audit Findings (Commit 72960ca)

  1. torch binary Subcommand: Registered in CLI11, but its callback assigns ArchiveType::None. The Binary exporter switch rejects None, causing execution to fail. Use torch_export_archive with format o2r (which is a standard ZIP archive containing raw assets) or torch_export_modding instead.

  2. Exit Code 0 on Missing Config: If config.yml is missing or the ROM SHA-1 does not match, Torch prints a warning to console and exits with code 0. torch-mcp performs pre-flight checks and verifies disk artifacts to prevent silent failures.

  3. Target Isolation: In torch pack FOLDER TARGET ARCHIVE_TYPE, TARGET must never be inside FOLDER. The tool slices entry paths relative to the folder name length; placing the target inside the folder causes recursive self-packing corruption.

  4. Log Levels: Torch uses CRITICAL log severity for normal extraction progress indicators. torch-mcp does not treat CRITICAL in logs as an automatic fatal error.


Testing

Run the test suite:

npm test
# or
node test/index.js

All 4 test suites cover:

  • Path normalization, directory containment, and uint16 version checks.

  • SHA-1 calculation and config.yml parser.

  • Tool registry schemas, error guards, and capabilities probing.

  • Full end-to-end JSON-RPC protocol over stdio.


License

MIT License. Copyright (c) 2026 Cody (CodeMasterCody3D). HarbourMasters/Torch is developed by the Harbour Masters team.

Available Tools

12 tools
torch_bk64_hashesB

Generate Banjo-Kazooie (BK64) baseline asset table hashes from a ROM at offset 0x5E90.

Inputs: rom_path (required), timeout_ms, torch_path, output_path.

torch_capabilitiesB

Probe Torch executable, inspect registered CLI subcommands, detect compiled features, and review registered asset types and upstream caveats.

Inputs: subcommand, torch_path.

torch_diagnose_binaryA

Diagnose the upstream "torch binary" subcommand bug and get recommended workarounds for extracting raw binary assets.

Inputs: rom_path.

torch_export_archiveB

Extract assets from an N64 ROM into an O2R (ZIP resource archive) or OTR (StormLib archive) file using Torch.

Inputs: rom_path (required), format, single, srcdir, +6 more.

torch_export_codeB

Export decompiled C source code representation of N64 assets from a ROM using Torch.

Inputs: rom_path (required), single, srcdir, destdir, +3 more.

torch_export_headersC

Generate C headers for assets from an N64 ROM using Torch.

Inputs: rom_path (required), otr, srcdir, destdir, +2 more.

torch_export_moddingA

Export editable asset files from an N64 ROM using Torch modding export. Produces modding.yml manifest and editable raw or XML assets.

Inputs: rom_path (required), xml, srcdir, destdir, +2 more.

torch_import_moddingB

Import edited modding assets from destdir/modding/modding.yml back into code, otr, o2r, or header targets.

Inputs: mode (required), rom_path (required), srcdir, destdir, +3 more.

torch_pack_archiveB

Pack a directory of prepared resource files into an O2R or OTR archive without requiring a ROM or config.yml.

Inputs: folder (required), format (required), target (required), version, +2 more.

torch_parse_configA

Parse, inspect, and summarize a Torch config.yml file, displaying registered ROM SHA1s, game titles, asset paths, GBI microcodes, output maps, and segment definitions.

Inputs: config_path (required).

torch_render_sequencesA

Headless audio extraction: renders sequence-driver audio assets and writes 16-bit PCM stereo 32kHz WAV files via Torch UI test harness without opening a display window.

Inputs: rom_path (required), wav_outdir (required), filter, srcdir, +2 more.

torch_validate_projectB

Pre-flight validation for a Torch project: calculates ROM SHA1, parses config.yml, checks hash matches, verifies destination permissions, and validates asset paths.

Inputs: rom_path (required), srcdir, destdir, single_yaml.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 12 tools

    Disambiguation5/5

    Each tool targets a distinct operation or output type. The four export tools differ by output format (archive, code, headers, modding), and import_modding is the clear inverse of export_modding. No two tools appear to serve the same purpose.

    Naming Consistency4/5

    Most tools follow the verb_noun pattern (e.g., validate_project, parse_config, export_archive). However, torch_capabilities and torch_bk64_hashes are noun-only, breaking the otherwise consistent pattern.

    Tool Count5/5

    With 12 tools, the server is well-scoped for the N64 ROM modding domain. Each tool covers a specific capability without redundancy, fitting comfortably in the ideal range.

    Completeness5/5

    The tool surface covers the full lifecycle: probing, validation, parsing, rendering, exporting/importing in multiple formats, packing, hashing, and even diagnosing a known bug. There are no obvious missing operations that would block common workflows.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides code intelligence by indexing source code into SQLite and offering MCP tools for symbol search, flow tracing, and context retrieval to assist with code navigation and understanding.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables developers to build and deploy MCP servers with multiple modular tools bundled into a single executable file.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP toolkit that gives coding agents bounded, provenance-backed evidence about Minecraft projects, including declared project facts, version-aware mapping and source references, and classified build or runtime diagnostics. It also exposes opt-in tools for permitted Gradle tasks, bounded client launches, and configured external providers, with modular skills for Java, client, server, Mixin debugging, and anti-cheat compatibility work.
      11
      MIT