
Ble Mcp Server
io.github.es617Published by GitHub account es617v0.3.0Updated Oct 24, 2026
Let AI agents interact with real BLE hardware — scan, connect, read, write, and subscribe.
Overview
A local MCP server that lets an AI assistant scan, connect to, read, write and subscribe to real Bluetooth Low Energy devices.
- What you can do
- Scan for nearby BLE devices and connect or disconnect, with connection status and service discovery checks. Read and write characteristic and descriptor values, and query MTU. Subscribe to notifications and collect streaming data by waiting, polling or batch draining. List active connections, scans, subscriptions and background tasks, and cancel tasks. Register, attach and search markdown protocol specs describing a device's commands and data formats. Load device plugins that expose higher-level shortcut tools, and inspect the server's tool-call trace.
- When to use it
- Useful for embedded engineers, makers, QA and field engineers who want an assistant to explore, debug or test real BLE hardware conversationally, or to automate sensor data collection and device test sequences.
- Requirements
- Runs locally as a Python package (pip install ble-mcp-server) over stdio by default; optional SSE or Streamable HTTP transports need BLE_MCP_AUTH_TOKEN unless started with --no-auth. Needs a Bluetooth adapter and OS permissions: Bluetooth access for the terminal on macOS, Windows 10 1709+ with Bluetooth on, or BlueZ 5.43+ and D-Bus access on Linux.
Installation
In SourceWeft
- Open Ble Mcp Server in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
BLE MCP Server
[MCP] [License: MIT] [Python] [BLE]
A stateful Bluetooth Low Energy (BLE) Model Context Protocol (MCP) server for developer tooling and AI agents. Works out of the box with Claude Code, VS Code with Copilot, and any MCP-compatible runtime. Defaults to stdio (no HTTP, no open ports), with optional SSE and Streamable HTTP transports for remote access and multi-session use. Uses bleak for cross-platform BLE on macOS, Windows, and Linux.
Example: Let Claude Code scan for nearby BLE devices, connect to one, read characteristics, and stream notifications from real hardware.
Demo
7-minute video walkthrough — scanning a real BLE device, discovering services, reading values, and promoting flows into plugins.
Why this exists
You have a BLE device. You want an AI agent to talk to it — scan, connect, read sensors, send commands, stream data. This server makes that possible.
It gives any MCP-compatible agent a full set of BLE tools: scanning, connecting, reading, writing, subscribing to notifications — plus protocol specs and device plugins, so the agent can reason about higher-level device behavior instead of just raw UUIDs and bytes.
The agent calls these tools, gets structured JSON back, and reasons about what to do next — no human in the loop for each BLE operation.
What agents can do with it:
- Develop and debug — connect to your device, explore its services, read characteristics, test commands, and diagnose issues conversationally. "Why is this sensor returning zeros?" becomes a question you can ask.
- Iterate on new hardware — building a BLE device? Attach a protocol spec so the agent understands your commands and data formats as you evolve them.
- Automate testing — write device-specific plugins that expose high-level actions (e.g., device.start_stream, device.run_self_test), then let the agent run test sequences: enable a sensor, collect samples, validate values, report results.
- Explore — point the agent at a device you’ve never seen. It discovers services, probes characteristics, and builds up protocol documentation from scratch.
- Build BLE automation — agents controlling real hardware for real tasks: reading environmental sensors on a schedule, managing a fleet of BLE beacons, triggering actuators based on conditions.
Who is this for?
- Embedded engineers — faster iteration on BLE protocols, conversational debugging, automated test sequences
- Hobbyists and makers — explore BLE devices without writing boilerplate; let the agent help reverse-engineer simple protocols
- QA and test engineers — build repeatable BLE test suites with plugin tools, run them from CI or agent sessions
- Support and field engineers — diagnose BLE device issues interactively without specialized tooling
- Researchers — automate data collection from BLE sensors, explore device capabilities systematically
Quickstart (Claude Code)
Then in Claude Code, try:
"Scan for nearby BLE devices and connect to the one whose name starts with Arduino."
The server is read-only by default. Writes and plugins can control real hardware and execute code, and are opt-in via environment variables. See Safety for details.
What the agent can do
Once connected, the agent has full BLE capabilities:
- Scan for nearby devices, with optional name or service UUID filters
- Connect to a device and discover its services and characteristics
- Read and write characteristic values (writes require
BLE_MCP_ALLOW_WRITES) - Subscribe to notifications and collect streaming data — single events, polling, or batch draining
- Attach protocol specs to understand device-specific commands and data formats
- Use plugins for high-level device operations (e.g.,
sensortag.read_temp) instead of raw reads/writes - Create specs and plugins for new devices, building up reusable knowledge across sessions
The agent handles multi-step flows automatically. For example, "read the temperature from my SensorTag" might involve scanning, connecting, discovering services, attaching a spec, enabling the sensor, and reading the value — without you specifying each step.
At a high level:
Raw BLE → Protocol Spec → Plugin
You can start with raw BLE tools, then move up the stack as your device protocol becomes understood and repeatable. See Concepts for how the pieces fit together.
Install (development)
MCP is a protocol — this server works with any MCP-compatible client. Below are setup instructions for the most common ones.
Add to Claude Code
Add to VS Code / Copilot
Add to your project's .vscode/mcp.json (or create it):
Adjust env to match your needs — remove BLE_MCP_ALLOW_WRITES for read-only mode, or set BLE_MCP_PLUGINS to specific plugin names.
Add to Cursor
Add to your project's .cursor/mcp.json (or create it):
Environment variables
Tools
See Concepts for how everything fits together, and the Tools Reference for detailed input/output schemas.
Protocol Specs
Specs are markdown files that describe a BLE device's protocol — services, characteristics, commands, and data formats. They live in .ble_mcp/specs/ and teach the agent what a device can do beyond raw UUIDs and bytes.
Without a spec, the agent can still discover services and read characteristics. With a spec, it knows what the values mean and what commands to send.
You can create specs by telling the agent about your device — paste a datasheet, describe the protocol, or just let it explore and document what it finds. The agent generates the spec file, registers it, and references it in future sessions. You can also write specs by hand.
See Concepts for details on spec format and how the agent uses them.
Plugins
Plugins add device-specific shortcut tools to the server. Instead of the agent composing raw read/write sequences, a plugin provides high-level operations like sensortag.read_temp or ota.upload_firmware.
The agent can also create plugins (with your approval). It explores a device, writes a plugin based on what it learns, and future sessions get shortcut tools — no manual coding required.
To enable plugins:
Editing an already-loaded plugin only requires ble_plugin_reload — no restart needed.
Background tasks
Plugins can start background asyncio tasks for continuous monitoring — periodic scans, data collection loops, etc. The plugin template includes commented examples for this pattern.
Background tasks are registered with the server via state.register_task(name, task), making them visible to the agent:
ble_tasks_list— shows all running background tasks with statusble_tasks_cancel— stops a task by ID (safety net for runaway tasks)
Plugin notifications
Plugins can send MCP log notifications to the client via state.on_log_cb(level, message). This allows plugins to proactively alert the agent about events — device arrival, threshold crossed, anomaly detected — without waiting for a tool call.
See Concepts for the plugin contract, metadata matching, and how specs and plugins work together.
Tracing
Every tool call is traced to .ble_mcp/traces/trace.jsonl and an in-memory ring buffer (last 2000 events). Tracing is on by default — set BLE_MCP_TRACE=0 to disable.
Event format
Two events per tool call:
connection_idis extracted from args when presentvalue_b64andvalue_hexare stripped from traced args by default (enable withBLE_MCP_TRACE_PAYLOADS=1)
Inspecting the trace
Use ble.trace.status to check config and event count, and ble.trace.tail to retrieve recent events — no need to read the file directly.
Platform BLE permissions
macOS
No special setup is needed for most cases. On macOS 12+, the Terminal app (or whichever terminal you use) must have Bluetooth permission. Go to System Settings > Privacy & Security > Bluetooth and ensure your terminal is listed and enabled. If running from an IDE, the IDE itself may need the permission.
Windows
Requires Windows 10 version 1709 (Fall Creators Update) or later. No extra drivers needed — bleak uses the native WinRT Bluetooth APIs. Just make sure Bluetooth is turned on in Settings.
Linux
Requires BlueZ 5.43+. Your user must have permission to access the D-Bus Bluetooth interface. The simplest approach:
If you are running in a container or headless environment, ensure dbus and bluetoothd are running.
Example session
The repo includes a simulated BLE peripheral you can run on a second machine (e.g. a Raspberry Pi) to try things end-to-end — no real hardware needed. See examples/demo-device/ for setup.
"Scan for BLE devices and connect to DemoDevice. Read the battery level, then start a data collection."
The agent will:
- Scan for nearby devices and find DemoDevice
- Connect and discover its services
- Check for a matching protocol spec — if one exists, attach it to understand the device's protocol
- Check for a matching plugin — if one exists, use its shortcut tools
- If no spec or plugin exists, explore the device using raw BLE tools, or ask you for guidance
- Read the battery level, configure the data service, and start collection
The example includes a pre-built protocol spec and plugin — copy them into .ble_mcp/specs/ and .ble_mcp/plugins/ to skip the exploration phase, or let the agent create its own from scratch.
Try without an agent
You can test the server interactively using the MCP Inspector — no Claude or other agent needed:
Open the URL with the auth token from the terminal output. The Inspector gives you a web UI to call any tool, see responses, and observe MCP notifications (like disconnect alerts) in real time.
Transports
The server supports three MCP transports. stdio is the default and recommended for most use cases — zero configuration, no network exposure. HTTP transports are available for remote access and multi-client scenarios.
HTTP transport options
For SSE, clients connect via GET /sse and post messages to /messages/. For Streamable HTTP, the endpoint is /mcp.
Session isolation: each MCP session gets its own BLE state — connections, scans, and subscriptions are not shared between sessions. Two sessions can independently scan or connect to the same device (if the BLE hardware and device allow it).
Authentication
HTTP transports require BLE_MCP_AUTH_TOKEN to be set. This token serves as the password for the OAuth 2.0 approval page — when a client connects, it goes through the standard OAuth flow and the user must enter this password to approve access.
The OAuth flow (handled automatically by Claude Desktop and other MCP clients):
- Client discovers the server's OAuth metadata at
/.well-known/oauth-authorization-server - Client registers itself via dynamic client registration (
/register) - User is redirected to an approval page where they enter the
BLE_MCP_AUTH_TOKENpassword - Client exchanges the authorization code for access/refresh tokens
All OAuth state (clients, tokens) is stored in memory and lost on restart — clients simply re-authenticate.
Claude Desktop setup (remote via tunnel):
In Claude Desktop, add a remote MCP server with the tunnel URL + /mcp path (e.g. https://abc123.trycloudflare.com/mcp). Claude Desktop handles the OAuth flow — you just enter the password when prompted.
No auth (local testing only):
For local testing with MCP Inspector or similar tools, you can disable auth entirely:
Without BLE_MCP_AUTH_TOKEN or --no-auth, the server refuses to start on HTTP transports.
stdio transport ignores all auth settings — it doesn't need auth because the client launches the server as a subprocess.
Note: uvicorn and starlette are required for HTTP transports. They are already transitive dependencies of the mcp package, but you can install them explicitly with pip install ble-mcp-server[http].
Architecture
- Multiple transports — stdio (default), SSE, and Streamable HTTP
- Per-session isolation — each MCP session gets its own BLE state
- Stateful — connections and subscriptions persist in memory
- Safe by default — writes gated by env flags + allowlist
- Agent-friendly — structured outputs, buffered notifications
- Graceful shutdown — disconnects all clients on exit
Known limitations
-
Real hardware is asynchronous; agent runtimes mostly aren't. Devices disconnect, notifications arrive out of band, and state changes while the agent is thinking. Most agent runtimes are optimized for clean request/response loops. The server bridges this with polling tools, buffered notification queues, and MCP log notifications for disconnects, incoming data, and scan results — but MCP log notifications are client-dependent (they work in MCP Inspector; Claude Code and Claude Desktop currently ignore them). The agent can always detect disconnects on the next tool call and poll for notifications explicitly — the log messages are a best-effort heads-up, not a guarantee. Custom MCP clients (e.g., an edge agent using the MCP SDK directly) can receive and act on these notifications.
-
stdio is single-session. The stdio transport handles one MCP session at a time. For multi-session use, switch to SSE or Streamable HTTP transport with
--transport sseor--transport streamable-http.
Safety
This server connects an AI agent to real hardware. That's the point — and it means the stakes are higher than pure-software tools.
Plugins execute arbitrary code. When plugins are enabled, the agent can create and run Python code on your machine with full server privileges. Review agent-generated plugins before loading them. Use BLE_MCP_PLUGINS=name1,name2 to allow only specific plugins rather than all.
Writes affect real devices. A bad write to the wrong characteristic can brick a device, trigger unintended behavior, or disrupt other connected systems. Keep writes disabled unless you need them. Use BLE_MCP_WRITE_ALLOWLIST to restrict which characteristics are writable.
Use tool approval deliberately. When your MCP client prompts you to approve a tool call, consider whether you want to allow it once or always. "Always allow" is convenient but means the agent can repeat that action without further confirmation.
This software is provided as-is under the MIT license. You are responsible for what the agent does with your hardware.
License
This project is licensed under the MIT License — see LICENSE for details.
Acknowledgements
This project is built on top of the excellent bleak library for cross-platform BLE in Python.
Source: README.md at commit d8cb674
Tools
0Version history
1- v0.3.0LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts