btdiag
Enables AI agents to control Bluetooth audio devices via MCP tools, including battery status, connect/disconnect, find-my, and snoop decoding.
README
btdiag — universal Bluetooth audio diagnostics + battery alerts
A small, open tool that surfaces everything your OS and your earbuds expose — battery (with the timestamp of when it was reported), every supported profile in plain English, device class, vendor, connection history, the adapter in use, and the vendor control channels — for any Bluetooth audio device, regardless of brand. Then it alerts you before the battery dies at thresholds you choose.
No vendor app. No account. No cloud. Works on devices that never shipped an app at all (budget TWS like Noise, boAt, Baseus, TOZO, Wings…).
⚡ MCP for Bluetooth — control your earbuds with AI (a first)
btdiag ships an MCP server — so far the only
known one that lets an AI agent control Bluetooth audio devices. Point Claude,
Claude Code, or an on-device/edge model at btdiag_mcp.py and just say what
you want:
"is my left bud dying?" →
bt_battery· "disconnect my earbuds" →bt_disconnect"find my earbuds" →bt_findmy· "what is my headset sending?" →bt_snoop_decode
The CLI does the doing (talks to Bluetooth); the AI does the deciding. The
same core serves humans (CLI + GUI), scripts (--json), and AI agents (MCP) —
cloud or a private on-device model. 500+ public MCP servers exist (GitHub,
Slack, Postgres…) — none for Bluetooth devices. This is the first.
// Register in any MCP client (e.g. Claude Desktop config):
"btdiag": { "command": "python", "args": ["C:/path/to/btdiag_mcp.py"] }
9 tools: bt_scan · bt_info · bt_battery · bt_monitor_status ·
bt_connect · bt_disconnect · bt_unpair · bt_findmy · bt_snoop_decode.
See docs/RESEARCH_AI_FINDMY_TRANSPORT.md for the edge-AI architecture (on-device function-calling models → MCP → Bluetooth).
Why this exists
Most budget earbuds — the majority of units sold — have no PC app, no Linux app, and often no/dropped mobile app. Windows itself still has no built-in low-battery alert for Bluetooth headsets. Existing open tools each target a single premium brand:
| Project | Platform | Brands | Reach |
|---|---|---|---|
| GadgetBridge | Android | Galaxy/Huawei/Sony/Pixel | premium only |
| OpenFreebuds | Win+Linux | Huawei | single brand |
| FreeBuddy | Android | Huawei 4i | single model |
| baseus-desktop | Windows | Baseus | 1 verified model |
| Bluetooth Battery Monitor | Windows | any (battery only) | paid, closed, no diagnostics |
btdiag is brand-agnostic by design. Layer 1 (this release) uses standard OS interfaces, so it works on every headset today. Layer 2 (in progress) adds vendor-protocol modules (BES TOTA, JieLi RCSP) for deeper data — per-bud + case battery, ANC, EQ, find-my — across whole families of cheap earbuds at once.
Layout
btdiag.py CLI entry point
btdiag/ Python package (Windows + Android backends, decoders)
android-app/ standalone Android app (Kotlin) — battery alerts on phone
dist/ build outputs (Android APK; Windows .exe via PyInstaller)
scripts/ install/uninstall the silent Windows background monitor
docs/ research report
research/ every approach we tried, worked or not (research/README.md)
apk_work/ decompiler + tooling (not part of source)
Windows (PC)
Requires Python 3.10+ . No third-party packages for the core (standard library only).
python btdiag.py scan # list all paired BT devices, one line each
python btdiag.py info [name] # full decoded report for connected device(s)
python btdiag.py raw [name] # dump every hidden PnP property (the full unfurl)
python btdiag.py monitor [name] # low-battery alert loop (80/60/40/20/10%)
python btdiag.py status | stop # check / stop the background monitor
[name] is an optional case-insensitive filter, e.g. python btdiag.py info noise.
Run silently at every login (no console, no admin)
powershell -ExecutionPolicy Bypass -File scripts\install_autostart.ps1
This drops a hidden launcher in your Startup folder and starts the monitor now.
Remove it any time with scripts\uninstall_autostart.ps1.
Android (phone)
- Standalone app (recommended) — install
dist/btbattery-debug.apk. It runs as a background service, listens for the headset'sIPHONEACCEVbattery report, shows a live status notification, and alerts at each threshold. After install it needs no PC and no debugging — it is a normal app, auto-starts on boot. - From the PC over ADB (development/diagnostics) —
python btdiag.py battery(one-shot) orpython btdiag.py android(continuous). Needs the phone on USB or wireless debugging; port discovery is automatic via mDNS.
Example
============================================================
Airdopes 148 Gen 2
============================================================
Status : CONNECTED
Address : BB:D1:7A:A6:BA:BF
Address note : randomized / locally-administered address (no IEEE vendor)
Via adapter : 40:1A:58:4B:82:5F
Device class : Audio / Video > Wearable Headset
Capabilities : Rendering, Audio
Battery : [####################] 100%
Profiles / services (what the device can do):
- Advanced Audio Distribution (A2DP)
-> streams stereo music to the device
- Hands-Free (HFP)
-> call audio + microphone + battery reporting
- Serial Port (SPP)
-> raw data channel - often the vendor control/config link
First paired : 05/26/2026 16:49:07
Last connected: 06/14/2026 18:07:17
============================================================
That report was produced unmodified against a boAt device, though the tool was developed against a Noise device — the same code handles both.
Architecture
btdiag/
bt_constants.py Class-of-Device decoder, profile names + plain-English meanings,
MAC/OUI vendor analysis, vendor UUIDs
win_query.ps1 fast batched PnP property query (Windows backend)
windows.py assembles physical devices, decodes, reads SDP cache
android.py ADB backend: battery via IPHONEACCEV from dumpsys
report.py human-readable rendering
monitor.py multi-threshold, charging-aware battery alerts
tota.py BES TOTA Layer-2 module (read-only; reverse-engineered)
btdiag.py CLI entry point
The backends are isolated, so macOS/Linux backends and Layer-2 protocol modules plug in without touching the CLI or rendering.
Optional: full vendor names
The MAC/OUI vendor table is a small curated hint list. For complete vendor
coverage, drop the IEEE/Wireshark oui.txt into btdiag/oui.txt — it is loaded
automatically if present.
What's readable from Bluetooth (honest scope)
- OS-exposed, any device: name, MAC, vendor, device class, profiles,
battery %, connection state, pairing history.
infodecodes all of it. - Vendor control, device-specific: per-bud battery, ANC, EQ, gestures — needs the vendor protocol (BES TOTA module).
- Raw live packets: require Android HCI snoop log or a hardware sniffer —
a research activity, not a runtime feature. See
research/README.md.
Roadmap
- [x] Layer 1: universal OS-level diagnostics + battery alerts (Windows)
- [x] Android battery alerts (standalone APK + ADB backend)
- [ ] BES TOTA protocol module → per-bud + case battery, ANC, EQ, find-my
- [ ] JieLi RCSP protocol module
- [ ] Linux (BlueZ) and macOS backends
- [ ] System-tray UI
History
This began as a focused reverse-engineering effort on the Noise earbuds; see
docs/RESEARCH_REPORT.md for the full protocol findings (GATT map, BES TOTA
auth handshake, command IDs) and research/README.md for every approach tried.
research/superseded/battery_monitor.py is the original single-file monitor that
btdiag replaced.
License
MIT — see LICENSE. Safe by design: read-only against the OS; vendor modules use only documented, non-destructive commands (never firmware/OTA).
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.