btdiag

btdiag

Enables AI agents to control Bluetooth audio devices via MCP tools, including battery status, connect/disconnect, find-my, and snoop decoding.

Category
访问服务器

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)

  1. Standalone app (recommended) — install dist/btbattery-debug.apk. It runs as a background service, listens for the headset's IPHONEACCEV battery 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.
  2. From the PC over ADB (development/diagnostics) — python btdiag.py battery (one-shot) or python 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)

  1. OS-exposed, any device: name, MAC, vendor, device class, profiles, battery %, connection state, pairing history. info decodes all of it.
  2. Vendor control, device-specific: per-bud battery, ANC, EQ, gestures — needs the vendor protocol (BES TOTA module).
  3. 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).

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选