# GitHub - maam00/fujikit: Unofficial, open-source Swift SDK, macOS CLI, and wire protocol spec for Fujifilm X-series cameras (USB C1-C7 slots, BLE backup, Wi-Fi import, in-camera RAW conversion). Not affiliated with FUJIFILM.

**Safe, open-source Swift SDK, macOS CLI (`fuji`), native MCP server (`fuji mcp`), and wire protocol reference for Fujifilm X-series cameras.**

> **Unofficial.** FujiKit is an independent community project. It is not made by, affiliated with, or endorsed by FUJIFILM Corporation.

Back up, diff, and write custom film simulation slots (`C1`\-`C7`) over USB, try a look on the camera's live shooting state (experimental), pull full-size photos over camera Wi-Fi without Fujifilm's XApp, inspect `.dat` settings backups, and drive your camera's own X-Processor for authentic in-camera RAW conversion.

-   **Zero third-party dependencies:** pure Swift 6 (`ImageCaptureCore`, `CoreBluetooth`, `Network`, `Foundation`)
-   **Agent-native out of the box:** built-in stdio MCP server (`fuji mcp`), `--json` output, and an installable [`SKILL.md`](https://github.com/maam00/fujikit/blob/main/skills/fujikit/SKILL.md) for Claude Code, Codex, Cursor, and Claude Desktop
-   **iOS 18+ & macOS 15+ Swift Package:** zero `.unsafeFlags`, ready for Xcode or SwiftPM by version tag
-   **Hardware-safe by architecture:** read-only PTP opcode allowlist for photo imports, mandatory fresh backups before every write, byte-diff `RestoreGuard`, and strict readback verification
-   **Canonical wire spec included:** [FUJIFILM-PROTOCOL.md](https://github.com/maam00/fujikit/blob/main/docs/FUJIFILM-PROTOCOL.md) documents USB PTP, Bluetooth LE (basic and 1.30+ secure pairing), the `FUJIFILMX-BACKUP` binary format, checksums, and Wi-Fi PTP/IP with strict evidence labels

* * *

## Quickstart (macOS CLI)

### Install via Homebrew (recommended, Apple Silicon, no Xcode required)

brew install maam00/tap/fuji

Or build from source (embeds macOS `Info.plist` for USB, Bluetooth, and Local Network permissions):

git clone https://github.com/maam00/fujikit.git
cd fujikit
make install

### Use it

Plug in your camera over USB with **MENU -> NETWORK/USB SETTING -> CONNECTION MODE -> USB RAW CONV./BACKUP RESTORE**:

# Inspect connected body, firmware, and all C1-C7 slots (read-only, supports --json)
fuji info
fuji show
fuji show --json

# Spot setting drift across C1-C7, or preview changes before writing
fuji diff
fuji diff examples/recipes/classic-chrome-day.json
fuji diff backup-before.json backup-after.json --json   # offline

# Take a timestamped backup of all 7 custom slots
fuji backup

# Load recipes into C1-C7 (backs up first, writes, reads back every property)
fuji load examples/recipes/classic-chrome-day.json

# EXPERIMENTAL: try one look on the live shooting state (live codes, not the C1-C7 slot codes).
# On the X100VI only the film simulation write has been run on real hardware, and whether the
# camera folds live changes into the selected C slot is unknown. Preview with --dry-run first.
fuji look-live examples/recipes/street-chrome.json --dry-run
fuji look-live examples/recipes/street-chrome.json --snapshot live-before.json
fuji look-restore live-before.json

# Pull recent full-size photos wirelessly over BLE wake + camera Wi-Fi
# (unplug USB first; your Mac's Wi-Fi moves to the camera's network until the import ends)
fuji import-wifi --last 10

# Render a RAF file using your camera's real film-simulation engine (never touches C1-C7)
fuji rawconv DSCF0001.RAF --recipe examples/recipes/street-chrome.json

# Inspect a FUJIFILMX-BACKUP .dat file offline (read-only)
fuji settings-probe backup.dat

Run `fuji --help` for all subcommands.

* * *

## Use with Claude Code, Codex, Cursor, or Claude Desktop

FujiKit ships a **zero-dependency stdio MCP server** inside the `fuji` binary plus a standard [`skills/fujikit/SKILL.md`](https://github.com/maam00/fujikit/blob/main/skills/fujikit/SKILL.md).

### Option A: Connect via MCP (`fuji mcp`)

Add this to your MCP config (Claude Code, Codex, Claude Desktop, or Cursor):

{
  "mcpServers": {
    "fujikit": {
      "command": "fuji",
      "args": \["mcp"\]
    }
  }
}

Exposed MCP tools (with `readOnlyHint` annotations):

-   **Read-only:** `fuji_info`, `fuji_show`, `fuji_diff`, `fuji_backup`, `fuji_settings_probe`
-   **Read-only on the camera, but changes this Mac:** `fuji_import_wifi` (moves the Mac's Wi-Fi to the camera's network for the duration and writes photo files)
-   **Guarded camera actions:** `fuji_load` (supports `dry_run: true`, mandatory fresh backup), `fuji_rawconv`
-   **Experimental:** `fuji_look_live` (see the note in the quickstart above)

### Option B: Install the Agent Skill

npx skills add maam00/fujikit

* * *

## Use `FujiKit` in Your Swift / iOS / macOS App

Add `FujiKit` via Swift Package Manager:

dependencies: \[
    .package(url: "https://github.com/maam00/fujikit.git", from: "0.2.0")
\]

Connect over USB (`ImageCaptureCore`) and load custom slots with per-slot readback verification:

import FujiKit

let link \= CameraLink.usb()
let recipes: \[Recipe\] \= \[
    Recipe(
        name: "Street Chrome",
        filmSim: .classicChrome,
        grain: .weakSmall,
        colorChrome: .weak,
        colorChromeFxBlue: .off,
        whiteBalance: .daylight,
        kelvin: 0,
        wbShiftR: 2,
        wbShiftB: \-3,
        dynamicRange: .dr200,
        highlight: \-0.5,
        shadow: 1.0,
        color: 1,
        sharpness: \-1,
        noiseReduction: \-4,
        clarity: 0
    )
\]

let report \= try await link.load(looks: recipes) { slot in
    print("C\\(slot.slot): \\(slot.verdict)")
}
await link.disconnect()

In Xcode Previews, simulators, and unit tests, swap `CameraLink.usb()` for `MockCameraLink()` (identical API, zero hardware required).

### Core Modules

| Module | What it provides |
| --- | --- |
| **USB PTP** | `FujiCamera`, `CameraLink`, `ImageCaptureTransport`, `SlotEncoder`, `LiveControl`, `SlotDiff` |
| **MCP Server** | `MCPServer` (pure Swift 6 JSON-RPC 2.0 stdio server, injectable `MCPToolExecutor`) |
| **Bluetooth LE** | `FujiBluetoothLink`, `FujiBLEFlows`, basic & 1.30+ secure pairing, settings backup & Wi-Fi wake |
| **Settings File (`.dat`)** | `FujiSettingsFile`, `SettingsLookPatch`, `RestoreGuard`: parse, probe, and narrow-patch `FUJIFILMX-BACKUP` files with incremental checksum updates |
| **Wi-Fi & USB Import** | `PhotoImporter`, `FujiPTPIPTransport`, `FujiWifiWake`, `ReadOnlyPTP`, `ExifReader` |
| **In-Camera RAW Conv** | `FujiRawConverter`, `D185Profile`: drive Fujifilm's hardware X-Processor over USB |
| **Safety & Qualification** | `CameraCompatibility`, `USBQualification`, `SlotBackup`, `CameraCheck` |

* * *

## The Fujifilm Wire Protocol Reference

If you are building Fujifilm tooling in **any language** (Swift, Rust, Python, Go, C++), start with:

👉 **[`docs/FUJIFILM-PROTOCOL.md`](https://github.com/maam00/fujikit/blob/main/docs/FUJIFILM-PROTOCOL.md)**

Every fact in the spec is tagged with its exact evidence level (`VERIFIED-HW`, `CODE`, `CITED`, or `HYPOTHESIS`):

-   USB PTP `D18C`\-`D1A4` slot registers, gating rules, monochrome skip sets, and the Grain-Off `1 -> 6/7` readback quirk
-   macOS `ptpcamerad` exclusive-claim behavior
-   Bluetooth LE GATT tables, basic (4-byte key) vs. secure (1.30+ LE bonding + `f557d96b` status echo), and chunked zlib backup/restore framing
-   `FUJIFILMX-BACKUP` binary layout (`0xF800`\-`0x11000`), volatile regions, and checksum model at `0x108`
-   Wi-Fi PTP/IP gallery session handshake, handle priming (`GetObjectInfo` before `GetPartialObject`), and EXIF date probing

* * *

## Camera Compatibility & Adding Your Body

**Read-only operations** (`info`, `show`, `diff`, `backup`, `settings-probe`, `props --read`) work safely without modifying camera state.

**Verified slot writes** are strictly allowlisted by exact model + firmware so FujiKit never guesses wire encodings on an untested body:

| Body | Firmware | USB Read / Diff / Backup | USB Slot Writes (`C1`\-`C7`) | BLE Backup / Wi-Fi Import | BLE Modified Writes |
| --- | --- | --- | --- | --- | --- |
| **X100VI** | `1.10` | Verified | **Verified** (write, readback, exact restore, restart) | Verified (basic BLE + Wi-Fi JPEG pull) | Experimental lab only |
| **X100VI** | `1.30+` | Supported | Ready to qualify (`fuji qualify-usb`) | Secure BLE + hidden-SSID Wi-Fi implemented (untested on HW) | Blocked |
| **X-T5, X-T50, X-E5, X-E4, X-M5, GFX** | Any | Read-only probe | Community PRs welcome | Untested | Blocked |

### Own an X100VI on firmware 1.30 or newer?

Help qualify your firmware in 2 minutes (safely tests `C7` only, backs up first, verifies readback, and restores your original slot):

fuji qualify-usb --qualify-unverified-firmware --out my-camera-record.json

### Own an X-T5, X-T50, X-E5, X-E4, X-M5, or GFX?

Slot writes are blocked on these bodies today, and `fuji qualify-usb` refuses before writing anything. The first step is a read-only report:

fuji info --json

See **[`docs/COMPATIBILITY.md`](https://github.com/maam00/fujikit/blob/main/docs/COMPATIBILITY.md)** and open an **[Add Camera](https://github.com/maam00/fujikit/blob/main/.github/ISSUE_TEMPLATE/add_camera.yml)** issue with the output. Check it for your serial number before posting.

* * *

## Safety Guarantees

Writing to camera settings carries real risk if done carelessly. FujiKit enforces four non-negotiable invariants in code (not just docs). See **[`docs/SAFETY.md`](https://github.com/maam00/fujikit/blob/main/docs/SAFETY.md)**:

1.  **Photos can never be modified or deleted:** All import transports are wrapped in `ReadOnlyPTP`, which throws before transmitting any destructive opcode (`DeleteObject`, `FormatStore`, `SendObject`, etc.).
2.  **Fresh backup before every write:** `load` and `qualify-usb` always snapshot all seven slots first and refuse to proceed if any slot fails to read.
3.  **Byte-level `RestoreGuard`:** Any settings-file restore verifies that _only_ the chosen slot bytes and 16-bit checksum changed relative to a fresh backup from the same serial number.
4.  **Strict readback verification:** A `0x2001 OK` response from the camera is never trusted alone. Every written property is read back and verified (accounting for documented hardware quirks like Grain Off returning `6`/`7`).

* * *

## Development

# Run the full offline test suite (440+ tests, no camera required)
make test

# Build the CLI with embedded Info.plist
make build
make verify-plist

* * *

## Credits & License

MIT Licensed. See [LICENSE](https://github.com/maam00/fujikit/blob/main/LICENSE).

Protocol discoveries build on and credit the open-source Fujifilm community: **FilmKit**, **fuji-bridge**, **libfuji**, **furble**, **fffw**, and **helios** (full upstream licenses in [`THIRD_PARTY_NOTICES.md`](https://github.com/maam00/fujikit/blob/main/THIRD_PARTY_NOTICES.md) and [`third_party/licenses/`](https://github.com/maam00/fujikit/blob/main/third_party/licenses)).

_FujiKit is an independent open-source project and is not affiliated with or endorsed by FUJIFILM Corporation. FUJIFILM, X100VI, and film simulation names are trademarks of FUJIFILM Corporation._