flipper-zero-mcp
by Cir0cuit
README.md
# flipper-zero-mcp
<p align="center"><img src="docs/images/hero.svg" alt="A request to turn off the TV, the assistant's steps through the Infrared app shown as real Flipper Zero screenshots, its question before it transmits, and a Flipper Zero showing the universal TV remote screen." width="100%"></p>
**Let an AI assistant operate your Flipper Zero.** It sees the screen, presses the buttons, types, and
manages files and apps, over USB or Bluetooth.
[](https://github.com/Cir0cuit/Flipper-Zero-MCP/actions/workflows/tests.yml)
[](pyproject.toml)
[](LICENSE)
[](#quick-start)
[](https://modelcontextprotocol.io)
[](#bluetooth-le)
[](#tool-reference)
## What it does
flipper-zero-mcp is a program that runs on your computer, between an AI assistant and your Flipper Zero.
It is an [MCP](https://modelcontextprotocol.io) server: MCP (Model Context Protocol) is the standard way
to give an AI assistant extra tools. Once it is set up, you ask the assistant in plain language and it
works the Flipper the way a person holding it would. Some things to ask, by part of the device:
**Infrared**
- *Turn off the TV with my Flipper.* The assistant asks you first, then walks Infrared > Universal
Remotes > TVs and presses POWER, which sends the firmware's TV power codes one after another. No saved
remote is needed; a TV that is already off may switch on.
- *Mute the TV using my saved Living_Room remote.* Sends one button of a saved remote by its name, after
asking.
- *I am going to press Power on my soundbar remote, aimed at the Flipper. Tell me what it sends.* The
protocol, address and command of the signal, or its raw timings when the Flipper does not know the
protocol (most air conditioners). USB only.
**NFC and 125 kHz RFID**
- *What kind of card is this? I am holding it against the back of the Flipper.* The tag type, and for
NTAG and Ultralight tags the UID and page contents. The page contents need USB.
- *Read this card and save it as Office_Badge.* The assistant goes through the NFC app's Read and Save
screens and types the name on the on-screen keyboard.
- *Emulate my saved 125 kHz gym fob so I can check the reader accepts it.* Emulates after asking, until
you say stop.
**Sub-GHz**
- *Download today's Sub-GHz autosaves and tell me which devices are really in them.* Weather sensors,
remotes and tyre sensors, each rated confirmed, unconfirmed or likely noise. Needs
[rtl_433](https://github.com/merbanan/rtl_433) on your computer.
- *Send my saved Garage.sub once.* Shows the file's frequency and protocol, asks, transmits, and stops.
USB only.
- *Set Sub-GHz Read to 868.35 MHz and tell me what it was set to before.* Changes the app's settings
file after asking, without walking the config menu.
**Files and backups**
- *Back up the remotes, cards and captures on my SD card to ~/flipper-backup.* Copies the folders; asked
again later, it copies only the new files.
- *How full is the SD card, and what is taking the space?*
- *Put the Samsung_TV.ir file from my Downloads folder on the Flipper.* Uploads it and lists the
remote's buttons.
**Apps**
- *Install the app I just built (dist/my_app.fap) and show me what it looks like on the Flipper.*
Uploads it, starts it and returns its screen.
- *Check that every app in /ext/apps/Games still starts after my firmware update.* PASS, FAIL or
INCOMPLETE for each app, with its screen; an app that crashes the Flipper is caught.
**Settings and maintenance**
- *The clock on my Flipper is wrong, set it to my computer's time.* Sets it after asking.
- *My Flipper just restarted by itself. What happened?* Whether it rebooted, and the reason from the
crash screen if that is still shown.
- *I am about to flash new firmware. Free the port, and when I say the flashing tool is done, tell me
whether the update took.* The assistant notes the firmware version, releases the port for your
flashing tool, then waits for the Flipper to come back and compares the version. The server does not
flash firmware itself.
**GPIO**
- *Is the button I wired to pin C3 working? Read it while I press it.*
- *Switch on the relay on pin A7 for a moment.* Drives the pin high and low again, after asking. 3.3 V
logic, with seconds between the steps, not milliseconds.
- *Power my module from the 5 V pin and check it is on.* Switches 5 V on header pin 1 after asking.
**Bluetooth, without the cable**
- *Pair my Flipper over Bluetooth so I can unplug the cable.* Windows and Linux. With the cable still
in, the assistant reads the pairing code from the Flipper's screen.
- *My Flipper is somewhere in this room. Make it beep.* It beeps, vibrates and flashes.
The assistant asks before anything that transmits radio or infrared, emulates a tag, deletes or
overwrites data, reboots, sets the clock or drives a pin (see the [safety model](#safety-model)). In an
app's menus it reads every screen before it presses the next button, because menus differ between the
official firmware and custom firmware. Tools that use the Flipper's command line need USB (see
[USB vs Bluetooth tools](#usb-vs-bluetooth-tools)).
<p align="center">
<img src="docs/images/screens/desktop.png" alt="Flipper Zero desktop with the status bar and the idle animation" width="192" align="middle">
<img src="docs/images/screens/main-menu.png" alt="Main menu grid: Apps, RFID, Infrared, SubGHz, NFC, GPIO" width="192" align="middle">
<img src="docs/images/screens/infrared-tv-remote.png" alt="Universal TV remote in portrait: POWER selected, MUTE, CHANNEL up and down, VOLUME plus and minus" width="96" align="middle">
<img src="docs/images/screens/nfc-reading.png" alt="NFC app: Reading, hold card next to Flipper's back" width="192" align="middle">
<img src="docs/images/screens/subghz-read.png" alt="Sub-GHz Read screen scanning on 433.92 MHz with modulation FM476" width="192" align="middle">
</p>
<p align="center"><sub>Unedited screenshots taken through the server from a Flipper Zero running Momentum
firmware: desktop, main menu, universal TV remote (shown upright, as the device is held for it), NFC
read and Sub-GHz Read.</sub></p>
To do that, the assistant can:
- **see** the 128x64 screen, as a PNG and as a pixel-exact text rendering,
- **press** the six buttons and **type** on the on-screen keyboard,
- **run** commands on the Flipper's text command line (CLI; USB only),
- read and write **files**, start and close **apps**, read and change system settings such as the clock,
unlock the lock screen and use the **GPIO** pins, through the device's remote-control interface (the
protobuf RPC API the official apps use),
- **identify** the devices in a recorded Sub-GHz capture (this needs the separate program rtl_433 on your
computer).
What you need:
- a Flipper Zero,
- a USB data cable, or Bluetooth on a Windows or Linux computer,
- Python 3.10 or newer, and git,
- an MCP client, such as [Claude Code](https://claude.com/claude-code),
- optionally [rtl_433](https://github.com/merbanan/rtl_433), a separate program, only for identifying the
devices in Sub-GHz captures (see [Configuration](#configuration)).
Nothing is installed on the Flipper. The server talks to the firmware as it is, with no extra app, over
the same USB serial port and Bluetooth service that the official apps use. The protocol handling is
based on the official desktop app [qFlipper](https://github.com/flipperdevices/qFlipper) (USB) and the
official Flipper Android app (Bluetooth).
## Disclaimer
> **Built and tested with verified access.** This project was built and tested with Claude Opus 5.5 and
> Claude Mythos 5.2 in Claude Code, on an account enrolled in Anthropic's
> [Cyber Verification Program](https://www.anthropic.com/news/cyber-verification-program) (CVP), in which
> Anthropic verifies security professionals and reduces the safeguards that block their security work.
>
> **Without CVP it might not work as described.** The server itself runs for everyone. But a Flipper Zero
> works with radio, NFC, RFID, infrared and USB-keyboard emulation, which are dual-use, so the AI model's
> safeguards (guardrails) may make it decline some requests or stop partway through a task, more often
> when the account is not in the program. Other models and other MCP clients were not tested.
>
> **You are responsible for what is sent and read.** Use this only on devices and signals you own or are
> authorized to test, and follow your local radio regulations. Operations that transmit, delete or reboot
> need a confirmation step: see the [safety model](#safety-model).
## Quick start
**1. Install and register.** Linux and macOS (on Debian / Ubuntu, install the venv module first with
`sudo apt install python3-venv`):
```bash
git clone https://github.com/Cir0cuit/Flipper-Zero-MCP.git
cd Flipper-Zero-MCP
python3 -m venv .venv
.venv/bin/pip install -e .
claude mcp add --scope user flipper-zero -- "$PWD/.venv/bin/flipper-zero-mcp"
```
Windows (PowerShell):
```powershell
git clone https://github.com/Cir0cuit/Flipper-Zero-MCP.git
cd Flipper-Zero-MCP
python -m venv .venv
.venv\Scripts\pip install -e .
claude mcp add --scope user flipper-zero "$PWD\.venv\Scripts\flipper-zero-mcp.exe"
```
The last line tells Claude Code where the server is. `--scope user` makes it available in every project;
without it the server is registered for the current folder only.
**2. Connect the Flipper.** On Linux, first give your user access to the serial port (see
[Linux](#linux)). Then plug in a USB data cable and close qFlipper: only one program can use the port at
a time.
**3. Ask.** Start `claude`; `/mcp` lists `flipper-zero` when the server is registered. Then try:
> Take a screenshot of my Flipper.
Claude Code asks for permission the first time it uses a tool; allow it. After that, try something with
more steps, such as *How full is the SD card, and what is taking the space?*, or one of the requests
under [What it does](#what-it-does).
The server does not open the serial port until the assistant uses the first Flipper tool. To use Bluetooth
instead of the cable, see [Bluetooth LE](#bluetooth-le).
### Linux
- **Permissions.** The Flipper appears as `/dev/ttyACM*`. Either add your user to the serial group, then
log out and back in. Debian / Ubuntu and Fedora:
```bash
sudo usermod -aG dialout $USER
```
Arch:
```bash
sudo usermod -aG uucp $USER
```
Or install qFlipper's udev rule, which grants access to whoever is logged in locally, with no group
membership needed:
```bash
sudo tee /etc/udev/rules.d/42-flipperzero.rules >/dev/null <<'EOF'
#Flipper Zero serial port
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ATTRS{manufacturer}=="Flipper Devices Inc.", TAG+="uaccess"
#Flipper Zero DFU
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", ATTRS{manufacturer}=="STMicroelectronics", TAG+="uaccess"
EOF
sudo udevadm control --reload-rules && sudo udevadm trigger
```
- **ModemManager.** ModemManager may probe a new CDC ACM device by sending AT commands. That garbles the
first seconds of the session and can hold the port. This rule makes it ignore the Flipper:
```bash
echo 'ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ENV{ID_MM_DEVICE_IGNORE}="1"' \
| sudo tee /etc/udev/rules.d/43-flipperzero-mm.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
```
Or, if you don't use a mobile modem: `sudo systemctl disable --now ModemManager`.
### macOS
The port is `/dev/cu.usbmodemflip_<Name>1`. Use the `cu.*` device, not `tty.*`. Auto-detection finds it,
and no driver is needed. Bluetooth is not supported on macOS (see [Bluetooth LE](#bluetooth-le)).
### Windows
The Flipper appears as a `COMx` USB serial device (the built-in `usbser` driver; Device Manager → Ports).
Auto-detection works. To pin a port, set `FLIPPER_ZERO_PORT=COM5`. Only one program can have a COM port open
at a time.
### Other ways to install
The install puts a `flipper-zero-mcp` console script into the virtual environment.
`python -m flipper_zero_mcp` does the same thing. The server speaks MCP over stdio: a client other than
Claude Code starts it with the command `flipper-zero-mcp`, with no arguments.
pip, with the test dependencies:
```bash
pip install -e '.[test]'
```
uv instead of pip:
```bash
uv venv && uv pip install -e .
```
uv, run without installing:
```bash
uv run --with-editable . flipper-zero-mcp
```
## Contents
- [Status](#status)
- [Features](#features)
- [Configuration](#configuration)
- [Bluetooth LE](#bluetooth-le)
- [Pairing (once per computer)](#pairing-once-per-computer)
- [One connection at a time](#one-connection-at-a-time)
- [USB vs Bluetooth tools](#usb-vs-bluetooth-tools)
- [Heavy apps over Bluetooth](#heavy-apps-over-bluetooth)
- [PIN lock](#pin-lock)
- [Safety model](#safety-model)
- [Troubleshooting](#troubleshooting)
- [Tool reference](#tool-reference)
- [`navigate` step grammar](#navigate-step-grammar)
- [Capturing Sub-GHz signals](#capturing-sub-ghz-signals)
- [Architecture](#architecture)
- [Development](#development)
- [Credits](#credits)
- [License](#license)
## Status
Version 0.1.0. A simulated Flipper (`flipper_zero_mcp/testing/fake_flipper.py`) and a simulated Bluetooth
peripheral (`flipper_zero_mcp/testing/fake_ble.py`) cover the whole stack in the test suite, which runs
without hardware. Bluetooth, including pairing, was verified on a real Flipper (Momentum dev firmware) on
2026-11-22 on Windows 11 and on Linux (BlueZ). [Bluetooth LE](#bluetooth-le) says what was exercised on
each system and what is still tested against the simulated devices only.
## Features
| Area | What you get |
|---|---|
| **Virtual GUI** | Live screen from the RPC screen stream (PNG plus a half-block text image the model can read), button presses (short / long / hold with auto-repeat / raw press & release), a `navigate` mini-language for multi-step menu walks, typing on the firmware `TextInput` keyboard (cursor paths match the firmware's own movement rules; the Momentum/RogueMaster layout is detected from the firmware fork), and waiting for the screen to change. |
| **CLI** | Any command on the Flipper shell (`help`, `info power`, `loader list`, `subghz rx`, …). Output has ANSI colours removed. Streaming commands are stopped with Ctrl+C after a time limit. y/n prompts are supported. A safety classifier gates risky commands. |
| **Storage** | List, stat, read, write, upload, download, mkdir, delete, rename and MD5 on `/ext` (SD card) and `/int`. Writes go in 512-byte chunks. Text and base64 content are both supported. |
| **Apps** | Start any app by exact name (`"Sub-GHz"`, `"NFC"`, `"Infrared"`, a `.fap` path, …), see which app is running, and exit it. Apps started in RPC mode can be driven with load-file and virtual-button calls. |
| **System** | Device info, battery and power info, RTC get/set, reboot (os / dfu / update), audiovisual "find my Flipper" alert, desktop unlock. |
| **Sub-GHz analysis** | `subghz_identify` names the devices in a Read RAW / BinRAW capture with [rtl_433](https://github.com/merbanan/rtl_433) (installed separately) and rates every device as confirmed (decoded at least twice with nothing suspicious, or once with a CRC), unconfirmed or likely noise; a PT2262 remote also gets its Flipper Princeton key file. |
| **GPIO** | Read and write the 8 header pins, set pin mode and pull, and switch 5 V OTG on header pin 1. |
| **Bluetooth LE** | The same RPC tools over Bluetooth instead of USB: scan, pair with the 6-digit code (read from the Flipper's screen when it is also on USB), connect, reconnect. No CLI over Bluetooth. |
## Configuration
The server is configured with environment variables, set where the server is registered. With Claude Code
(`flipper-zero-mcp` stands for the full path used in the [quick start](#quick-start) when the script is not
on your `PATH`). To change the settings of a server you already registered, remove it first with
`claude mcp remove flipper-zero`, then add it again with the variables. Use one of these:
```bash
# default: USB, first Flipper found
claude mcp add --scope user flipper-zero -- flipper-zero-mcp
# with an explicit port and debug logs:
claude mcp add --scope user flipper-zero -e FLIPPER_ZERO_PORT=/dev/ttyACM0 -e FLIPPER_ZERO_MCP_LOG=INFO -- flipper-zero-mcp
# over Bluetooth LE (pair first, see "Bluetooth LE" below):
claude mcp add --scope user flipper-zero -e FLIPPER_ZERO_TRANSPORT=ble -e FLIPPER_ZERO_BLE_ADDRESS=80:E1:26:12:34:56 -- flipper-zero-mcp
# through the virtual environment's python instead of the script:
claude mcp add --scope user flipper-zero -- /path/to/Flipper-Zero-MCP/.venv/bin/python -m flipper_zero_mcp
```
Or, for a whole project, put a `.mcp.json` in the project root. A copy is in
[`examples/mcp.json`](examples/mcp.json). Replace `flipper-zero-mcp` with the full path from the quick
start if the script is not on your `PATH`:
```json
{
"mcpServers": {
"flipper-zero": {
"type": "stdio",
"command": "flipper-zero-mcp",
"args": [],
"env": {
"FLIPPER_ZERO_PORT": "${FLIPPER_ZERO_PORT:-auto}",
"FLIPPER_ZERO_MCP_LOG": "WARNING"
}
}
}
}
```
| Environment variable | Meaning |
|---|---|
| `FLIPPER_ZERO_PORT` | Serial port (`/dev/ttyACM0`, `/dev/cu.usbmodemflip_Name1`, `COM5`). Unset, empty or `auto` means auto-detect the first Flipper. |
| `FLIPPER_ZERO_TRANSPORT` | `usb` (default) or `ble` (Bluetooth LE). |
| `FLIPPER_ZERO_BLE_ADDRESS` | Bluetooth address of the paired Flipper (`80:E1:26:xx:xx:xx`) for `FLIPPER_ZERO_TRANSPORT=ble`. |
| `FLIPPER_ZERO_HEAVY_APPS` | Apps that leave too little memory for RPC work over Bluetooth (comma-separated, matched on the letters of the name or `.fap` path; default `Sub-GHz`; `unknown` adds apps opened on the Flipper, whose name Bluetooth cannot see; empty disables the guard). See [Heavy apps over Bluetooth](#heavy-apps-over-bluetooth). |
| `FLIPPER_ZERO_HEAVY_APP_IDLE_S` | Seconds a heavy app may run without a button press before the guard arms (default 30; 0 = whenever it runs). |
| `FLIPPER_ZERO_RTL433` | Path of the `rtl_433` executable for `subghz_identify` (default: `rtl_433` on `PATH`). Builds: [rtl_433 releases](https://github.com/merbanan/rtl_433/releases) (Windows: `rtl_433-win-x64-*.zip`); Linux/macOS packages are usually called `rtl-433` or `rtl_433`. |
| `FLIPPER_ZERO_MCP_LOG` | Log level on stderr: `DEBUG`, `INFO`, `WARNING` (default), `ERROR`. Nothing is ever written to stdout, because stdout is the MCP channel. |
## Bluetooth LE
Over Bluetooth the server uses the Flipper's default BLE profile, which carries protobuf RPC (the same
messages as over USB) but **no CLI**. Set `FLIPPER_ZERO_TRANSPORT=ble` and `FLIPPER_ZERO_BLE_ADDRESS`, or
call `flipper_connect(ble_address=...)` at run time; `flipper_connect(port="auto")` switches back to USB.
bleak (installed with the package) does the Bluetooth work. Supported: Windows and Linux (BlueZ). macOS hides
device addresses from programs, so the address-based tools do not work there: on macOS use USB.
> **Hardware status (2026-11-22, Momentum dev firmware).**
>
> Windows 11: in-app pairing with the PIN read automatically from the USB screen (13 s), MTU 414, credit flow control, device info, power, battery and DIS reads, clock, listing with MD5,
> uploads and downloads up to 100 KB with matching MD5 (about 14 KiB/s up, 11 KiB/s down), screenshots,
> button input, a 17 ms ping round trip, and reconnecting (about 4 s) all work, both through `FlipperDevice`
> and through the MCP tools.
>
> Linux, BlueZ 5.88 with bleak 3.1: scanning, pairing through `flipper_ble_pair` with the code read from the
> USB screen, connecting, device and power info, screenshots, button input, file reads, starting and closing
> apps, and switching between USB and Bluetooth all work through the MCP tools. Through `ble_pair.pair()` and
> `BleTransport`: pairing closes the link it opened and a connection right after it takes about 2 s, and
> connecting through a link BlueZ still holds takes under a second. Everything else on Linux is tested
> against the simulated devices only: uploads, and pairing with the code passed in a second call
> (`flipper_ble_pair(address, pin=...)`).
>
> On both systems, recovery from a Flipper-side link drop is tested against the simulated devices only.
### Pairing (once per computer)
The Flipper accepts only authenticated (paired) connections. When a computer pairs, the Flipper shows
**"Pairing code"** and a random 6-digit number, valid for about 30 seconds; every attempt gets a new one.
On the Flipper, Bluetooth must be on (Settings > Bluetooth) and no BLE remote/keyboard app may be running.
- **From the agent:** `flipper_ble_scan` lists the addresses (`80:E1:26:...`), then
`flipper_ble_pair(address)`. If the same Flipper is also connected over USB, the server reads the code
from its screen and finishes in one call. Otherwise the call returns while the code is on screen: the
agent asks you for it and calls `flipper_ble_pair(address, pin="123456")`. If that is too late or wrong,
call it again without `pin` for a new code. The in-app ceremony uses WinRT custom pairing on Windows and
a BlueZ agent (`KeyboardDisplay`, made the default agent) on Linux.
- **Windows (by hand):** Settings > Bluetooth & devices > Add device > Bluetooth, pick the Flipper and type
the code. If it is not listed, set "Bluetooth devices discovery" to Advanced (Settings > Bluetooth &
devices > Devices).
- **Linux (by hand):** `bluetoothctl`, then `agent KeyboardDisplay`, `default-agent`, `scan on` (wait for
the Flipper, `scan off`), `pair <MAC>` and type the code at the passkey prompt, then `trust <MAC>`.
`remove <MAC>` unpairs.
- **Name:** official firmware advertises "Flipper <name>"; **Momentum advertises the bare name** (for
example `Lab01`, not "Flipper Lab01"), and that is what Windows Settings lists. The server never relies on
the name.
- **Stale pairing:** after Settings > Bluetooth > Unpair All Devices on the Flipper, or when the OS still
lists the Flipper but connecting fails with "not paired", call `flipper_ble_unpair(address,
confirm=true)` (or remove it in the OS) and pair again. On Momentum, renaming the Flipper changes its
Bluetooth address, so the old pairing no longer applies.
### One connection at a time
The Flipper accepts a single Bluetooth connection and stops advertising while connected. If the Flipper
app on your phone is connected (it reconnects by itself), the computer cannot see the Flipper: close the
app or turn off the phone's Bluetooth. Two programs on the computer cannot both hold the Bluetooth link
either; a USB session and a Bluetooth session can run at the same time.
On Linux the system's Bluetooth service (BlueZ) keeps a link open after pairing with `bluetoothctl`, and after a
program exits without disconnecting. The Flipper does not advertise then. `flipper_ble_pair` closes the
link it opened itself, and `flipper_connect` takes a kept link over when the Flipper is paired and no
running program is subscribed to its Bluetooth notifications. While a second copy of this server or another
program is talking to the Flipper over that link, `flipper_connect` fails with "not found" and leaves the
link alone. A program that holds the link without subscribing is not detected: connecting then shares its
link, and disconnecting ends it for both, so run one Bluetooth program per Flipper.
### USB vs Bluetooth tools
| Tools | USB | Bluetooth |
|---|---|---|
| `screen_capture`, `press_button`, `navigate`, `type_text`, `type_hex`, `wait_for_screen_change`, `device_info`, `power_info`, `get_datetime`, `set_datetime`, `reboot`, `play_alert`, `storage_*`, `app_start`, `app_exit`, `app_load_file`, `app_button_press`/`release`, `gpio_*` | yes | yes (the screen stream runs only on demand; transfers are much slower) |
| `flipper_status`, `app_status` | yes | no `uptime_s`; the app name is the one given to `app_start`, remembered rather than read from the Flipper (`app_status` adds `app_name_note`); a running app not started by `app_start` is reported as `(unknown app)` |
| `wait_for_device`, reconnect report | uptime and `rebooted` | no uptime; `rebooted` is `"likely"` when an app that ran before the drop is gone, `"unlikely"` when one still runs, `null` when no app was known to run or it was an RPC-mode app (those end with the session anyway) |
| `app_smoke_test` | uptime before and after | a reboot shows as the link dropping |
| `app_start` out-of-memory advice | heap figures | advice without figures |
| `desktop_unlock` | non-PIN locks only | any lock, needs `confirm` (see [PIN lock](#pin-lock)) |
| `cli_run`, `nfc_cli`, `subghz_tx_file` | yes | **no** (they need the CLI; refused before connecting) |
| `flipper_list_ports` | yes | – (use `flipper_ble_scan`) |
| `flipper_ble_scan`, `flipper_ble_pair`, `flipper_ble_unpair` | work whatever the current link | |
On Momentum and RogueMaster a Sub-GHz `app_button_press` stays refused (it crashes the firmware), and
`subghz_tx_file` needs USB, so there is no Sub-GHz transmission over Bluetooth on those forks.
### Heavy apps over Bluetooth
Sub-GHz Read keeps every BinRAW entry of its history on the heap, and the Frequency Analyzer with the
external CC1101 leaves little free. In a field session (Momentum dev, external CC1101, Bluetooth) RPC work
during such a run crashed the Flipper with "out of memory" four times: a screen stream start (every
screenshot over Bluetooth starts one, and so do the "Send" checks of `navigate`/`press_button`), a
`storage_list` with downloads, and a screenshot while leaving Read. About 30 BinRAW history entries were
enough.
The server guards against it. Once a heavy app (`FLIPPER_ZERO_HEAVY_APPS`, default Sub-GHz, known from
`app_start` and the app lock status; an RPC-mode app never counts) has run for 30 s
(`FLIPPER_ZERO_HEAVY_APP_IDLE_S`) without a button press, the guard arms. While it is armed and the app
still runs, the next screen stream start or storage request is refused with an explanation:
`screen_capture`, `press_button`, `navigate` (only steps that look at the screen, and its final
screenshot, which is then left out), `type_text`, `type_hex`, `wait_for_screen_change`, `app_start`,
`app_exit`, `desktop_unlock`, every `storage_*` tool, `flipper_format_read`/`set` and `subghz_identify` on a
Flipper file.
Each of them takes `allow_while_app_running=true` to go ahead anyway (which also disarms the guard): use it
when Read and the Frequency Analyzer are not open, for example in the Sub-GHz menu. The guard disarms by
itself when the app is gone. `flipper_status` reports `heavy_app_running` (`null` for an app of unknown
name), `heavy_app`, `heavy_app_guard` (armed / not armed) and `heavy_app_risk`. Over USB nothing is
refused.
Over Bluetooth the server knows the app's name only from `app_start`: a Sub-GHz opened on the Flipper or
reached through the menus with `press_button`/`navigate` is an app of unknown name, which the default
settings do not guard (`heavy_app_running: null`; `heavy_app_risk` then says so). Open Sub-GHz with
`app_start("Sub-GHz")`, or add `unknown` to `FLIPPER_ZERO_HEAVY_APPS` to guard every app of unknown name.
Safe capture procedure over Bluetooth:
1. Open Sub-GHz with `app_start("Sub-GHz")` (not the menus, so the guard knows it), set up Read
(frequency, modulation, BinRAW, Autosave) with screenshots as usual, then start it.
2. Leave it alone: no screenshots, no file calls. Keep rounds short, about 5 minutes.
3. Exit blind: `navigate("back left back", screenshot=false, confirm=true)`. BACK opens "Discard
Signals?", LEFT (Continue) leaves Read and frees its history, BACK closes the app. `confirm=true` only
skips the "Send" checks before the LEFT step, which would start the screen stream; no Send screen is
involved here.
4. Only then take a screenshot, list `/ext/subghz/Autosave` and download.
### PIN lock
With a PIN lock set, the firmware turns USB off while locked, but Bluetooth stays up, and the RPC unlock
request does not check the PIN (`rpc_desktop.c`). A **paired computer can therefore unlock a PIN-locked
Flipper over Bluetooth** without knowing the PIN. That is why `desktop_unlock` needs `confirm=true` over
Bluetooth. Remove pairings you no longer trust (Unpair All Devices on the Flipper). Momentum's behaviour
here has not been checked.
## Safety model
The agent drives real hardware that can transmit radio signals and erase data, so risky operations need
two steps. A call without `confirm=true` fails with a message telling the agent to **ask the user**, then
retry with `confirm=true`.
- **Confirm required (†):** `storage_delete`, `storage_rename` with `overwrite`, `flipper_format_set`, `set_datetime`, `reboot`,
`gpio_write`, switching a pin to output, switching OTG 5 V, `app_button_press` (it transmits),
`app_start` of JS Runner, `DANGEROUS` CLI commands, `flipper_ble_unpair`, and `desktop_unlock` over
Bluetooth.
- **`cli_run` classifier** (`flipper_zero_mcp/safety.py`, derived from the firmware CLI sources):
- `FORBIDDEN`: always refused. These would break the serial session: `start_rpc_session`, `exit`,
interactive sub-shells such as `nfc` and `subshell_demo`, raw `storage write_chunk/read_chunks`,
`storage write` (Ctrl+C does not stop it while its buffer is empty, which can hang the CLI; use
`storage_write`), and anything outside printable ASCII. That includes TAB, which the firmware shell
uses for command completion (`pow<TAB> off` runs `power off`), and non-ASCII characters, which the
line editor silently drops (`poéwer off` runs `power off`).
- `DANGEROUS`: needs `confirm=true`. Covers `factory_reset`, `storage format/remove/rename/extract`
(rename deletes an existing destination, extract overwrites files), `update install/restore/backup`,
`crypto store_key`, `power off/reboot/5v/3v3`, `gpio set/mode`, setting `date`, `js`,
`loader open` of JS Runner, `loader signal`, `onewire search`, and every RF transmit: `subghz tx*/chat`, `ir tx/universal`,
`rfid write/emulate`, `ikey write/emulate`, `bt tx` tests. Unknown sub-commands of these families
also count as dangerous.
- `CAUTION`: streaming commands (`log`, `top`, `subghz rx`, `ir rx`, `rfid read`, …). These need
`interrupt_after_s`, after which Ctrl+C is sent.
- `SAFE`: everything else.
- **OK on a "Send" softkey transmits.** In Sub-GHz Read RAW, OK starts a recording, OK stops it, and
the next OK *press* sends it on air; saved Sub-GHz keys and the Infrared Learn result send on OK too.
`press_button` and `navigate` recognise the softkey on the screen (an exact match of the
`FontSecondary` "Send" label in a black box, anywhere on the screen, so a highlighted "Send" menu
entry counts too) and refuse an OK press (`ok`, `long:ok`, `hold:ok`, `press:ok`) there without
`confirm=true`; `navigate` checks before every OK step and reports the steps it already ran. On
Momentum, Unleashed and RogueMaster a saved key's Send screen also transmits on Up/Down/Left/Right
(custom buttons: a rolling-code key goes out with another button code and its counter advances), so
on any firmware but the official one an arrow press there is refused too. Read RAW keeps its arrows:
its "Send" sits next to an "Erase" / "New" left softkey, and its arrows only erase, save or open a
menu. `type_text` and `type_hex` refuse any Send screen (the keyboard did not open). BACK
and `app_exit` stay allowed. Infrared remotes have no "Send" label: OK on a button of a saved remote or of
Universal Remotes sends at once. So OK is refused without `confirm=true` while the running app is
known to be Infrared (by the name given to `app_start`, or over USB by `loader info`; also IR remote
`.fap`s), and the held-tap retry never repeats OK there. Over Bluetooth an Infrared app opened from
the menu is not recognised and its button lists are not caught. A custom font from an asset pack defeats the match. The recording is
already on the SD card (`/ext/subghz/RAW_.sub`) before Save is pressed.
- `cli_run`'s `answer` must be exactly one printable character: the firmware y/n prompts read one byte,
and any further bytes (`"\rpower off\r"`) would be run by the shell as new commands after the
classified one.
- Storage paths are checked on the host before anything is sent: non-empty, ≤ 255 printable ASCII
characters, under `/ext`, `/int` or `/any`. An empty path can hard-fault the firmware. Deleting or
writing the storage roots themselves is refused.
The confirm gate guards against agent mistakes. It is not a security boundary: anyone who can run the
server can use the serial port directly.
## Troubleshooting
| Symptom | Cause / fix |
|---|---|
| `No Flipper Zero found` | Check the cable (some are charge-only) and that the Flipper is on and not in DFU mode (that's PID `df11`, which this server can't use). `flipper_list_ports` shows what was detected. |
| `... is listed but not working yet` / `A device attached to the system is not functioning` / `Write timeout` / `ClearCommError ... (22)` (Windows) | The Flipper is rebooting or crashed. The server keeps reconnecting for 60 s; then `flipper_status` shows `uptime_s` and `last_reconnect.rebooted`, and the screen shows "Flipper crashed and was rebooted" with the reason. A program holding the port (fbt, a serial monitor) can keep a crashed Flipper's USB hung: close it. |
| `in use by another program` / `Access is denied` (Windows) | Another process holds the port (qFlipper, fbt `flash_usb_full`, `scripts/selfupdate.py`, a serial monitor, another MCP session). Close it or call `flipper_disconnect` there. Before flashing from this machine call `flipper_disconnect`, afterwards `wait_for_device`. |
| After a firmware update the port is gone for minutes | The updater runs first. `wait_for_device(timeout_s=300)`, then compare `firmware_commit`; the screen shows the update result until OK is pressed. Windows lists the device as "USB Serial Device" or "Martel USB to Serial"; the server finds it by USB IDs and serial number `FLIP_<name>`. |
| Port vanishes while the Flipper looks fine | **PIN lock disables USB CDC entirely.** Unlock the Flipper with its PIN on the device. The server reconnects on the next call. A plain (non-PIN) desktop lock is fine, and `desktop_unlock` clears it. |
| `Timed out: no reply to RPC ...` on every tool | The Flipper's RPC service is stuck while the device itself still runs. `flipper_connect` opens a new session; if the timeouts continue, reboot the Flipper: over USB try `cli_run("power reboot", confirm=true)` (the CLI may still answer), otherwise hold LEFT + BACK on the Flipper until it restarts. |
| Bluetooth: `not found over Bluetooth` | The Flipper is not advertising: Bluetooth off on the Flipper, a BLE remote/keyboard app running, out of range, or another device (the phone app) holds the only connection. |
| Bluetooth: `Timed out: no Bluetooth connection` (Linux) | The Flipper is not advertising (see the row above), or BlueZ holds a link to a Flipper that is not paired yet: `bluetoothctl disconnect <MAC>`, then pair and connect again. |
| Bluetooth: `not paired` / `Insufficient Authentication` | Pair first (`flipper_ble_pair`), or the pairing is stale: `flipper_ble_unpair` and pair again. |
| `... is not available over Bluetooth` | `cli_run`, `nfc_cli` and `subghz_tx_file` need the CLI: `flipper_connect(port="auto")` to switch to USB. |
| `Permission denied` / `could not open port` (Linux) | Your user is not allowed to open the serial port: see [Linux](#linux) for the group and the udev rule. |
| `Port busy` / `could not exclusively lock port` / timeouts at connect | Another program has the port open: **qFlipper** (close it entirely, including the tray icon), the Flipper web lab, `screen`/`minicom`, another MCP server instance, or ModemManager. On Windows only one process can open a COM port. Use `flipper_disconnect` to release it from this server. |
| Garbage or timeouts right after plugging in (Linux) | ModemManager may be probing the port. Add the ignore rule from [Linux](#linux). |
| `cli_run` says FORBIDDEN / needs `interrupt_after_s` | See the [safety model](#safety-model). Prefer the dedicated RPC tools (storage, apps, gpio). |
| `app_start` status 17 | Another app is running. Call `app_exit` first. |
| A Sub-GHz key file sends the wrong button (wrong LED/relay reacts) and the file now holds another key | Momentum/Unleashed "custom button" feature (`lib/subghz/blocks/custom_btn.c`): Princeton and similar encoders rebuild the key from a global button that `subghz rx` decoding and the Sub-GHz app leave set, and CLI `subghz tx_from_file` deserializes straight from the file, so it sends that button and writes it into the file. The global is cleared only at the end of a `tx_from_file`. `subghz_tx_file` clears it before sending and restores a rewritten file; with plain `cli_run`, re-record or rewrite the file. |
| CLI `subghz tx <key> ... <repeat>` is very short whatever the repeat, or sends the wrong button | Plain `subghz tx` builds Princeton data with `TE` and `Repeat` but no `Guard_time`. The decoder reads `TE`, looks for the optional `Guard_time`, and that failed lookup leaves the reader at the end, so `Repeat` is never read: the encoder default goes out (3 frames, about 0.2 s, on Momentum; 10 on official firmware). On Momentum/Unleashed it also never clears the custom-button state, so every key after the first one sent since boot goes out with that first button. `cli_run` adds a note for this command. Save a key file and use `subghz_tx_file`. |
| CLI uses the internal radio although an external CC1101 is connected | Every `subghz` CLI command defaults to device 0; pass `1` (it falls back to internal when no module answers). The Sub-GHz app and `subghz_tx_file` (`device="auto"`) pick the external module by themselves. |
| NFC app: the first **Write** after opening a saved file says "Writing gone wrong!" | Seen repeatedly on Momentum with an NTAG216: Retry writes it. |
| `nfc_cli`: `mfu info` reports "Pages Read: 55/231, Password-protected pages!" on a tag without a password | A Momentum CLI quirk; `mfu rdbl` and the NFC app read every page. |
| "Flipper crashed and was rebooted – out of memory" in Sub-GHz | Sub-GHz alone leaves about 23 KB of heap free on Momentum; opening Saved with many files in `/ext/subghz` (plus the RPC session's buffers) runs out. Keep fewer files there (move them into subfolders) or open them directly with `app_start("Sub-GHz", "/ext/subghz/x.sub")` / `subghz_tx_file`. |
| "Flipper crashed and was rebooted – out of memory" over Bluetooth while Sub-GHz runs | Seen four times on Momentum with the external CC1101: Frequency Analyzer, or Read with 25-36 BinRAW entries in its history, plus a new RPC session, a screen stream start (every screenshot over Bluetooth starts one, and so does an OK step of `navigate` with `screenshot=false`) or file reads. Let a heavy app run without RPC traffic, exit it (BACK) to free its history, then screenshot, list and download. Keep Read rounds short (about 5 min). |
| "Flipper crashed and was rebooted – furi_check failed" after a Sub-GHz RPC transmission | A Momentum/RogueMaster firmware bug: their Sub-GHz RPC scene confirms the button release, then confirms again when TX ends with no command pending (`furi_check(rpc_app->last_command_id != 0)` in `rpc_app.c`). Unleashed removed the second confirm; official firmware never had it. The server refuses Sub-GHz `app_button_press` on these forks; use `subghz_tx_file`. |
| `type_text` saves shifted letters ("Trmpyr_A" for "Remote_A") | The keyboard layout does not match the firmware. `auto` handles Official, Unleashed, Momentum and RogueMaster; for other forks pass `layout` explicitly. |
| `app_start` status 15 | The app name is wrong. Names are exact and case-sensitive (the list is under the table in the [tool reference](#tool-reference)). |
| `app_start` of a `.fap`: "Preload failed: Not enough memory" / status 16 | The loader needs each ELF section in one contiguous block (metroflip's `.rodata` alone is about 56 KB), so it depends on fragmentation. The error lists the largest free block; reboot and retry before blaming the app. |
| A game ignores every button | Apps built on flipperzero-game-engine (air_arkanoid, …) read key state once per frame and miss a press and release within one frame. `press_button` retries as a held tap; in `navigate` use `hold:<key>:250`. |
| "Flipper crashed and was rebooted – furi_check failed" after `loader close` | `loader close` sends the app an exit signal; scene-based apps (tpms_reader, unitemp, weather_station derivatives) skip their cleanup and free a running worker. `cli_run` needs `confirm` for it; use `app_exit`. |
| Screen looks stale | Use `screen_capture(fresh=true)`. The device only sends frames when the display changes. |
| Need more detail | Set `FLIPPER_ZERO_MCP_LOG=DEBUG`. Logs go to stderr; Claude Code shows them in `claude --debug` / the MCP logs. |
## Tool reference
Tools marked † need `confirm=true`. The server's instructions tell the agent to ask the user first.
The screen, input, storage, `flipper_format_*`, `subghz_identify`, `app_start`, `app_exit` and `desktop_unlock`
tools also take `allow_while_app_running=False` (left out of the table): see
[Heavy apps over Bluetooth](#heavy-apps-over-bluetooth).
Tools that return the screen send a PNG plus, with `ascii=True` (the default), a 128 × 32 text
rendering of about 4 KB; `ascii=false` leaves the text out when the image is enough.
Screenshot results are `[PNG image, text]`. The text holds a status line followed by a 32-line half-block
rendering of the screen.
| Tool | Parameters (defaults) | Description |
|---|---|---|
| `flipper_list_ports` | – | Detected Flipper serial ports (device, name, serial number). |
| `flipper_connect` | `port=None`, `ble_address=None` | (Re)connect: `port` switches to USB, `ble_address` to Bluetooth, neither reopens the current link. Returns transport, name, firmware and protobuf version. |
| `flipper_disconnect` | – | Close the port or Bluetooth link, for example to let qFlipper or the phone app use it. |
| `flipper_ble_scan` | `timeout_s=5` | Flippers over Bluetooth: advertising ones plus those paired with this computer (`address`, `name`, `rssi`, `color`, `bonded`, `connected_here`). Matched by address prefix `80:E1:26` or advertised service, never by name. `rssi: null` on a paired Flipper this server is not connected to gets an `rssi_null_note`: the computer may still hold a link another program opened; `flipper_connect` works once that program is gone and fails with "not found" while it is using the Flipper. |
| `flipper_ble_pair` | `address`, `pin=None` | Pair with the 6-digit code the Flipper shows. With the same Flipper on USB the code is read from its screen; otherwise the call returns and the agent calls again with `pin` (within about 25 s). |
| `flipper_ble_unpair` † | `address`, `confirm=False` | Remove this computer's pairing (for a stale one), then pair again. |
| `flipper_status` | – | Connected?, transport, port, link mode, desktop locked, running app, RPC-app state, battery %, `heavy_app_running` (+ over Bluetooth `heavy_app_guard`, `heavy_app_risk`; see [Heavy apps over Bluetooth](#heavy-apps-over-bluetooth)), `uptime_s`, and after a dropped link `last_reconnect` (`at`, `age_s`, `transport`, `rebooted`, `uptime_s`, `disconnected_for_s`). Never raises. `last_reconnect` describes the most recent dropped link and stays until the next one: `at` is the local time of the reconnect, `age_s` the seconds since, `transport` the link it was measured on, `uptime_s` the value at that moment. `flipper_connect`, `wait_for_device`, `reboot` and `flipper_disconnect` open the link without a new report; the old one then has `reopened_since: true` and says nothing about the current connection. Over Bluetooth there is no `uptime_s`, at the top level or in a report taken there; `rebooted` is `"likely"` when an app that ran before the drop is gone (`app_before`, `app_running_now`), and `true` with `crash_reason` when the reconnect's one screenshot (taken only when no app runs) shows "Flipper crashed and was rebooted". `last_crash` (`seen_at`, `reason_text`) appears once any screenshot showed that screen. `reason_text` and `crash_reason` are the reason read from the screen, such as `"out of memory"` or `"furi_check failed"`, or `null` when the server cannot read it; the screen's font draws `I` and `l` alike, so a capital I can come back as `l`. |
| `wait_for_device` | `timeout_s=120` | Closes this server's connection, then waits for the Flipper to come back (firmware update, reboot, crash) and returns name, firmware, `firmware_commit` and `uptime_s` (not over Bluetooth). |
| `screen_capture` | `scale=4`, `ascii=True`, `fresh=False` | Current screen. `fresh` forces a new frame from the device. |
| `press_button` | `key`, `kind="short"`, `count=1`, `hold_ms=0`, `retry_held=True`, `screenshot=True`, `ascii=True`, `confirm=False` | `key`: up/down/left/right/ok/back. `kind`: short, long, hold (`hold_ms`), press, release. `count × hold_ms` ≤ 60 s. Waits for the screen to settle. A single short press that changes nothing while an app runs is repeated as a 250 ms held tap (`retry_held`), for game-engine apps; OK is never repeated in Sub-GHz or an Infrared app, in an app of unknown name, on a "Send" softkey, or over Bluetooth outside RPC-mode apps (the name is then only remembered from `app_start`, and another app may have been opened from the menus since). OK on a "Send" softkey is refused without `confirm=true` (see the [safety model](#safety-model)). |
| `navigate` | `steps`, `screenshot=True`, `ascii=True`, `confirm=False` | Run a step program ([grammar](#navigate-step-grammar)) in one call. Before every OK step the screen settles (up to 1 s) and the step is refused on a "Send" softkey without `confirm=true`. |
| `type_text` | `text`, `clear_existing=0`, `max_length=21`, `layout="auto"`, `screenshot=True` | Type on the on-screen keyboard and select ENTER. `clear_existing` = number of backspaces to send first. Text longer than `max_length` (the field's capacity: 21 for NFC/RFID names, 22 for iButton/IR button names, 63 for Sub-GHz) is refused, because the firmware silently drops the extra characters. `layout` (auto / stock / unleashed / momentum): `auto` reads `firmware_origin_fork`; Momentum and RogueMaster have an extra `[A+]` key that shifts the bottom row. |
| `type_hex` | `hex`, `save=True`, `screenshot=True` | Type bytes on the hex keypad (`ByteInput`: 0-7 / 8-F, backspace, save), e.g. the RFID T5577 password or Add Manually key data. Expects the keypad freshly opened (cursor on `0`); bytes not typed keep their pre-filled value. |
| `wait_for_screen_change` | `timeout_s=5`, `ascii=True`, `region=None` | Waits for the screen to differ from the one the last tool returned (a change between calls is reported at once) and returns the screen, with a "No change" note after the timeout. `region=[x0, y0, x1, y1]` (inclusive pixels) watches only that rectangle, for apps that redraw constantly (a hopping frequency, an RSSI bar). A disconnect during the wait is an error, not "no change". |
| `cli_run` | `command`, `timeout_s=10`, `interrupt_after_s=None`, `answer=None`, `confirm=False`, `close_rpc_app=False` | Run a CLI command (see the [safety model](#safety-model)). `answer` is one printable character sent as a separate write for y/n prompts. Refused while an RPC-mode app runs unless `close_rpc_app`. A USB drop after `power off/reboot` or `update install` is reported as the expected outcome. |
| `device_info` | – | Hardware, firmware, radio and protobuf details. |
| `power_info` | – | Battery level, voltage, current, temperature, charging state. |
| `get_datetime` | – | RTC time. |
| `set_datetime` † | `iso=None` (host now), `confirm=False` | Set the RTC. Years 2000–2099. |
| `reboot` † | `mode="os"` (os / dfu / update), `confirm=False` | Reboot. The server reconnects on the next call. |
| `play_alert` | – | Beep, vibrate and flash ("find my Flipper"). |
| `storage_list` | `path="/ext"`, `offset=0`, `limit=200`, `glob=None`, `newer_than=None`, `sort="none"` (none / name / size), `reverse=False`, `names_only=False` | `{path, total, offset, truncated, entries}`; entries have name, type, size. `glob` (case-insensitive, e.g. `*.sub`) and `newer_than` (names that sort after the string, e.g. `2026-11-22_16,40` for timestamped autosaves) filter, `sort`/`reverse` order, then the page is cut; `total` counts the matches and `dir_total` the whole directory. `names_only` returns plain names (directories end with `/`). Newest N autosaves: `sort="name", reverse=true, limit=N`. |
| `storage_info` | `path="/ext"` | Total and free bytes. |
| `storage_stat` | `path` | Type and size, or `exists: false`. |
| `storage_read` | `path`, `encoding="auto"` (auto / text / base64), `max_bytes=16384` (≤ 49152) | Read a file. A truncated text file is cut at a character boundary. Use `storage_download` for big files. |
| `storage_write` | `path`, `content`, `encoding="text"`, `overwrite=False` | Write a file. Refuses to replace an existing file unless `overwrite`. |
| `storage_upload` | `local_path`, `remote_path`, `overwrite=False` | Copy a host file to the Flipper. |
| `storage_download` | `remote_path`, `local_path`, `overwrite=False` | Copy a Flipper file to the host. Sends MCP progress notifications (bytes) when the client asks for them. Over Bluetooth a 1.3 MB Read RAW file takes about 2 minutes. |
| `storage_download_dir` | `remote_dir`, `local_dir`, `glob=None`, `newer_than=None`, `recursive=False`, `overwrite=False`, `max_files=200` (≤ 1000) | Copy the files of a directory in one call, one after the other (`local_dir` is created). A local file of the same size is skipped, so a repeated call resumes after a timeout, a dropped link or the `max_files` cap (`remaining`). A local file of another size is a `conflict` unless `overwrite`. `glob`/`newer_than` filter file names like in `storage_list`; `recursive` mirrors sub-directories. Returns counts and `files` (downloaded / conflict / error); reports progress. |
| `storage_mkdir` | `path` | Create a directory. An existing one is not an error. |
| `storage_delete` † | `path`, `recursive=False`, `confirm=False` | Delete a file or directory. |
| `storage_rename` | `old`, `new`, `overwrite=False`, `confirm=False` | Rename or move. Refuses an existing destination (the firmware would delete it) unless `overwrite=true` with `confirm=true`. |
| `storage_md5` | `path` | MD5 of a file. |
| `flipper_format_read` | `path` | Parse a FlipperFormat file (`Key: value` lines: `.sub`, `.ir`, `.nfc`, settings) into `{path, filetype, version, values}`. `values` keeps the file order; a repeated key (the `Frequency` lines of `/ext/subghz/assets/setting_user`) becomes a list. Up to 64 KiB. Read `/ext/subghz/assets/last_subghz.settings` for the current Sub-GHz Read / Read RAW frequency, preset, hopping and autosave. |
| `flipper_format_set` † | `path`, `key`, `value`, `index=None`, `confirm=False` | Change one key and keep every other line, comment and the order; a missing key is appended. A repeated key needs `index` (the error lists the values). `Filetype`/`Version` are refused. Writes `<path>.mcp-tmp`, checks its MD5, then renames it over the file. Returns the old value and `warnings` (e.g. `Hopping: true` with `HoppingThreshold: nan`). |
| `subghz_identify` | `path` (one path or a list of ≤ 20), `local=False` | Identify the devices in a Sub-GHz `RAW` or `BinRAW` capture (a Flipper path, or a file on this computer with `local=true`) with rtl_433. A list of paths returns `captures` (one result per file) and `comparison` (the Manchester packets of all files grouped the same way: a packet seen in several captures is a real transmitter). The capture is converted to rtl_433 pulse data (Read RAW split into packets at gaps > 20 ms; one packet per BinRAW segment; FSK presets as FSK) and decoded. Returns `devices` grouped by model + id + channel with `count`, `samples`, `integrity` (CRC > CHECKSUM > PARITY > none), `pulse_spread` and a `verdict`: `confirmed` (decoded at least twice with nothing suspicious, or once with a CRC and plausible values), `unconfirmed`, or `likely_noise` (a single decode without CRC, an id of 0x0/0xF runs, random pulse widths). `undecoded` counts the other packets with rtl_433's modulation guesses and flex-decoder hints. A PT2262 remote (rtl_433 `Generic-Remote`) gets `flipper_key` (24-bit Princeton key, TE and the `.sub` text). A BinRAW recorded with an FM (2-FSK) preset is also searched by the server itself for an alternating preamble (≥ 16 symbols) followed by Manchester data (both phases, ≤ 2 invalid pairs, up to a run of ≥ 6 equal symbols): `manchester.packets` (hex, bits, `te_us`, `baud` = 10⁶ / TE, `data_rate_bps`) and `manchester.groups` (packets of the same length and first 16 bits, with `differing_bits` and a `diff` mask). Needs rtl_433 (`FLIPPER_ZERO_RTL433`); without it the error names the download page. |
| `app_start` | `name`, `args=""`, `screenshot=True`, `ascii=True`, `confirm=False` | Start an app by exact name or `.fap` path. `args="RPC"` starts it in RPC mode. JS Runner (`js_app`) or a `.js` argument needs `confirm`, and so does a file argument for NFC, 125 kHz RFID or iButton (it starts emulation). A missing `.fap` is reported as file not found. A `.fap` gets 30 s for the loader to answer (the first run unpacks assets); a late answer is checked against the loader state. Status 16 reports the heap (largest free block). |
| `app_exit` | `ascii=True` | RPC app exit. Falls back to pressing BACK until no app is running (max 10), switching to held BACK taps when a short BACK changes nothing. If BACK only toggles a confirmation dialog (Sub-GHz "Discard Signals?"), it stops with the dialog on screen for the agent to answer. An app that BACK cannot close is reported as still running (look for an Exit entry). Never sends the loader exit signal. |
| `app_smoke_test` | `name`, `confirm=False` | Start an app, let it run 3 s, check it runs, close it like `app_exit`, and compare the uptime before and after. Returns PASS / FAIL / INCOMPLETE with the app's screen. `dap_link`, `mtp`, `flip_tdi`, `ldtoypad` (switch the USB mode) and `hc_sr04` (drives GPIO) need `confirm`. |
| `app_status` | – | App lock state, the running app's name and the RPC-app state. Safe while an RPC-mode app runs. |
| `app_load_file` | `path`, `confirm=False` | RPC-mode app: load a file. NFC, 125 kHz RFID and iButton start emulating on load, so for them it needs `confirm`; `app_exit` stops it. |
| `app_button_press` † | `args=""` (≤ 512 UTF-8 bytes), `index=0`, `confirm=False` | RPC-mode app: press a virtual button. This transmits (Sub-GHz, IR, RFID emulation), so it needs `confirm`. Refused for Sub-GHz on Momentum/RogueMaster (see [Troubleshooting](#troubleshooting)); use `subghz_tx_file`. |
| `nfc_cli` † | `commands` (list, ≤ 20), `timeout_s=10`, `run_s=None`, `confirm=False` | Runs commands in the NFC CLI subshell (`nfc` … `exit`) in one session: `scanner`, `mfu info/rdbl/wrbl`, `dump`, `raw`, `apdu`, `field`, `emulate`. Reads run freely; card writes, raw frames other than reads, APDUs, `field`, `emulate` and `dump -f` need `confirm`. Page numbers above 255 (the firmware wraps them) and payloads over 250 bytes (a full buffer crashes the firmware) are refused. `run_s` stops `scanner`/`field`/`emulate` with Ctrl+C. The NFC app must be closed. |
| `subghz_tx_file` † | `path`, `repeat=10` (1–100), `device="auto"` (`auto` = external CC1101 if connected, else internal; `0` internal; `1` external), `confirm=False` | Transmit a saved `.sub` file with CLI `subghz tx_from_file` and wait until it is sent. Clears the firmware's stale custom-button state first and restores a key file the firmware rewrote. Returns `sent`, frequency, protocol, `device`/`radio` actually used, `file_restored`, `warning` and the CLI output. Refused while an RPC-mode app runs. |
| `app_button_release` | – | RPC-mode app: release it. |
| `desktop_unlock` | `confirm=False` | Unlock the desktop lock screen. Over USB this cannot remove a PIN lock (USB is off while PIN-locked). Over Bluetooth it also removes a PIN lock without the PIN, so there it needs `confirm`. |
| `gpio_read` | `pin` | Read an input pin (PA7, PA6, PA4, PB3, PB2, PC3, PC1, PC0). |
| `gpio_write` † | `pin`, `value`, `confirm=False` | Drive an output pin. |
| `gpio_set_mode` | `pin`, `mode` (input / output), `pull=None` (no / up / down), `confirm=False` | `mode="output"` needs `confirm`. |
| `gpio_otg` | `on=None`, `confirm=False` | Query 5 V OTG. Switching it needs `confirm`. |
Known app names (exact and case-sensitive): `Sub-GHz`, `125 kHz RFID`, `NFC`, `Infrared`, `GPIO`,
`iButton`, `Bad USB`, `U2F`, and the settings apps `Bluetooth`, `Desktop`, `Power`, `Storage`, `System`,
`About`, `Passport`, `Clock & Alarm`, `LCD and Notifications`. A `.fap` path such as
`/ext/apps/Tools/foo.fap` also works.
### `navigate` step grammar
Steps are separated by whitespace or commas and are case-insensitive. The whole program is checked
before any button is pressed.
| Step | Meaning |
|---|---|
| `<key>` or `short:<key>` | Click: PRESS, SHORT, RELEASE |
| `long:<key>` | Long press: PRESS, LONG, RELEASE |
| `hold:<key>:<ms>` | Hold for `ms` (LONG at 300 ms, then REPEAT every 150 ms), then RELEASE |
| `press:<key>` / `release:<key>` | Raw PRESS / RELEASE event |
| `wait:<ms>` | Pause (≤ 10 000 ms; all waits and holds of one call together ≤ 60 s) |
| `<step>*N` | Repeat a press step N times, e.g. `down*3`, `long:back*2` |
Keys are `up`, `down`, `left`, `right`, `ok` and `back`. The aliases `enter`, `select` and `center` mean
`ok`, and `esc` means `back`. There is a limit of 200 presses per call.
Example: `"ok down*2 ok wait:500 long:back"` opens the menu, moves down two items, opens the app, waits
half a second, then long-presses BACK.
## Capturing Sub-GHz signals
A method for finding the devices transmitting around the Flipper, worked out in a field session
(Momentum, external CC1101, Bluetooth). Receiving needs no `confirm`; transmitting does.
1. **Survey first.** Run the Sub-GHz Frequency Analyzer for 5-15 minutes and note the frequencies that
light up. Ignore known noise: hits at the edges of the band near LTE, and constant carriers (for
example a steady signal on one frequency that records no new samples in Read RAW). A one-off hit is not a band.
2. **Listen on a fixed frequency.** Run Read on each busy frequency rather than wide hopping: hopping
across many frequencies caught nothing in 2.5 minutes, a fixed 433.92 MHz caught signals at once. Hop
only over a short list: the `Hopper_frequency` lines in `/ext/subghz/assets/setting_user` (change
them with `flipper_format_set`, then restart the app).
3. **Keep BinRAW on and analyse the files on the computer.** Read with BinRAW and Autosave writes every
undecoded signal to `/ext/subghz/Autosave`. Do not judge them on the screen: copy them with
`storage_download_dir` and run `subghz_identify` on them (several at once to compare them). FM
BinRAWs can hold Manchester packets rtl_433 does not decode (for example 62-bit packets at 245 µs per
symbol, about 2 kbit/s); `manchester.packets` lists them. Weather sensors with pulse position
500/2000/4000 µs (Acurite, Nexus) show up only as BinRAW in Read; the Weather Station app decodes them
on the Flipper.
4. **Read RAW for long recordings.** Read RAW records the signal on its current frequency and preset to `/ext/subghz/RAW_.sub` while it
runs, so the file can be downloaded without pressing Save; download it before leaving Read RAW.
**The OK press after a recording transmits it**; leave with BACK. A rising sample counter in Read RAW also shows that the radio works
when Read stays silent.
5. **Rotate.** Once a frequency and modulation have given their devices, move on instead of finding the
same sensors again. AM270 decoded about twice as many sensor packets as AM650 with no chance
decodes. FM476 also covers what FM238 receives (wider filter). BinRAWs recorded with an FM preset are
often the strong AM devices seen through the FSK demodulator, not new FM devices.
Pitfalls:
- **Restart the Sub-GHz app after changing Radio Settings** (internal/external module): after switching
the module, Read received nothing for 7.5 minutes while Read RAW on the same settings recorded
signals; a restart fixed it.
- **Read and Read RAW share `/ext/subghz/assets/last_subghz.settings`** (frequency, preset): each starts
with whatever the other used last. Check the Frequency row every time (`flipper_format_read` shows
the file).
- **Turning Hopping off can leave the last hopper frequency** (868.35 MHz instead of the
`Default_frequency` 433.92 MHz from `setting_user`). After switching Hopping off in the Read config,
re-check the Frequency row and set it back before starting Read.
- `Hopping: true` needs a number in `HoppingThreshold` (`nan` shows "Hopping OFF" in the config while
the app hops); `flipper_format_read` warns about it.
- **Memory over Bluetooth.** Read keeps every BinRAW entry of its history on the heap. In the
Frequency Analyzer, or in Read with 25-36 BinRAW entries, a screen stream start, a new RPC session or
file reads crashed the Flipper ("out of memory") four times (Momentum, external CC1101). Every
screenshot over Bluetooth starts the stream, and so does every OK step of `navigate`, even with
`screenshot=false`: the server checks the screen for a "Send" softkey first (on Momentum, Unleashed
and RogueMaster also before the first arrow step after another key). BACK steps never touch the
stream. Run Read in rounds of about 5 minutes with no screenshots or transfers, exit it blind
(`navigate("back left back", screenshot=false, confirm=true)`), then list and download; the server
refuses screenshots and file calls in between (see [Heavy apps over Bluetooth](#heavy-apps-over-bluetooth)).
## Architecture
```
Claude Code / MCP client
│ stdio (JSON-RPC)
▼
┌──────────────────────────────────────────────────────────────┐
│ server.py MCPServer "flipper-zero": 50 tools, confirm │
│ gating, navigate parser, lazy connect + │
│ auto-reconnect, anyio.Lock + to_thread (the │
│ device API is blocking) │
├──────────────────────────────────────────────────────────────┤
│ device.py FlipperDevice: screen cache (frame seq + Cond.), │
│ input sequences, storage/app/system/gpio RPCs, │
│ cli() that returns to RPC afterwards │
│ ├─ screen.py u8g2 page decode, rotation, PNG / ASCII │
│ ├─ keyboard.py TextInput cursor planner (from firmware) │
│ ├─ safety.py CLI command risk classifier │
│ ├─ flipper_format.py 'Key: value' file parse / edit │
│ └─ subghz_analysis.py .sub -> rtl_433 pulse data, verdicts │
├──────────────────────────────────────────────────────────────┤
│ transport.py FlipperTransport: port discovery, DTR cycle, │
│ CLI <-> RPC state machine (lazy switching), │
│ reader thread, command ids, multi-part replies, │
│ broadcast (id 0) listeners, rpc start/stop hooks │
│ └─ framing.py varint length prefix + StreamDecoder │
│ └─ proto/ vendored flipperzero-protobuf 0.25 (pb2) │
├──────────────────────────────────────────────────────────────┤
│ pyserial → USB CDC ACM (VID 0x0483 / PID 0x5740) │
└──────────────────────────────────────────────────────────────┘
│
▼
Flipper Zero (CLI shell ⇄ `start_rpc_session` protobuf RPC)
```
Over Bluetooth, `ble.py` (`BleTransport`, same interface as `FlipperTransport`, bleak on its own event-loop
thread) replaces `transport.py`: protobuf RPC over the GATT serial service with the firmware's flow
control. `ble_pair.py` pairs with the OS APIs (WinRT on Windows, a BlueZ agent on Linux).
The serial link is either in **CLI mode** (text shell, prompt `>: `) or in **RPC mode** (length-prefixed
protobuf `PB.Main` messages). The transport only switches when it has to: an RPC call enters RPC mode,
and a `cli_run` drops to the CLI. After a CLI command, `FlipperDevice.cli()` returns to RPC mode, which
restarts the screen stream.
Dropping to the CLI ends the RPC session, and the firmware closes every app that was started in RPC mode
(`app_start(name, args="RPC")`) together with its session (`rpc_app.c`: `RpcAppEventTypeSessionClose`).
So while such an app runs, `app_status` and `flipper_status` report the name given to `app_start`
instead of asking the CLI, and `cli_run` is refused unless `close_rpc_app=true`. Call `app_exit` first.
If the link (USB or Bluetooth) drops during a call, the server reconnects and repeats the call once, but only if the
call is read-only or none of its bytes reached the device. Button presses, CLI commands, writes and
transmissions are never replayed. If the client cancels a call or times out, the work stops at once: held
buttons are released, remaining steps are skipped and a running CLI command gets Ctrl+C.
## Development
```bash
pip install -e '.[test]'
python -m pytest -q # no hardware needed: tests run against the fakes in flipper_zero_mcp/testing/
pip install mypy && python -m mypy src/flipper_zero_mcp # optional type check
```
The test suite also runs on GitHub Actions (`.github/workflows/tests.yml`) on Python 3.10 to 3.13, with a
mypy type check.
[`docs/DESIGN.md`](docs/DESIGN.md) is the design contract and the summary of the protocol facts (with firmware references)
that the implementation relies on.
## Credits
- [qFlipper](https://github.com/flipperdevices/qFlipper) by Flipper Devices. Its backend was the
reference for the serial and RPC session handling, the screen-stream format and the udev rule in [Linux](#linux).
No qFlipper code is included (qFlipper is GPL-3.0).
- [flipperzero-protobuf](https://github.com/flipperdevices/flipperzero-protobuf) by Flipper Devices. The
`.proto` files in `src/flipper_zero_mcp/proto/` are from release **0.25**, and the `*_pb2.py` modules were
generated from them. See [NOTICE](NOTICE).
- [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware). The CLI,
`text_input.c` keyboard and RPC behaviour were taken from its source.
- [flipperzero_protobuf_py](https://github.com/flipperdevices/flipperzero_protobuf_py), a reference for
the RPC calls.
- [Flipper Android app](https://github.com/flipperdevices/Flipper-Android-App) (MIT), the reference for the
Bluetooth connection sequence, flow control and pairing.
- [Flipper iOS app](https://github.com/flipperdevices/Flipper-iOS-App) on GitHub. The Flipper Zero device
illustration in the banner comes from it: Copyright (c) 2020 Flipper Zero, used under the MIT License.
See [NOTICE](NOTICE).
- The screenshots in the banner and under [What it does](#what-it-does) show the user interface of the
Flipper Zero firmware by Flipper Devices as modified by
[Momentum firmware](https://github.com/Next-Flip/Momentum-Firmware) (both GPL-3.0). The interface and
its graphics belong to their authors.
- [bleak](https://github.com/hbldh/bleak) for Bluetooth LE; pairing follows bleak pull request #1990.
- [rtl_433](https://github.com/merbanan/rtl_433) (GPL-2.0) decodes the Sub-GHz captures for `subghz_identify`.
It runs as a separate program that you install; none of its code is included.
Flipper Zero is a trademark of Flipper Devices Inc. This project is not affiliated with or endorsed by
Flipper Devices.
## License
MIT (see [LICENSE](LICENSE)). The vendored protobuf definitions come from their upstream project; see
[NOTICE](NOTICE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues