Skip to main content

microbit-mcp

An MCP (Model Context Protocol) server for the micro:bit that enables LLMs to interact with micro:bit devices.

Features

Tools

  • display_message: Display text messages on the micro:bit LED matrix
  • display_image: Display custom images on the micro:bit LED matrix using a 5x5 grid format
  • wait_for_button_press: Wait for a button press on the micro:bit with optional button selection and timeout
  • get_temperature: Return the real-time reading from the micro:bit's built-in temperature sensor

Setup

  1. Flash the src/microbit/main.py program to your micro:bit
  2. Connect the micro:bit via USB
  3. Run the MCP server: uv run microbit-mcp
  4. Configure your MCP client to connect to this server

Command Line Options

The MCP server supports several command-line options for configuration:

# Use default port (recommended for most users)
uv run microbit-mcp

# Specify a custom serial port
uv run microbit-mcp --port /dev/tty.usbmodem1234
uv run microbit-mcp -p COM3  # Windows example

# List available serial ports to find your micro:bit
uv run microbit-mcp --list-ports

# Show help and usage information
uv run microbit-mcp --help

Finding Your micro:bit Port

If you're unsure which port your micro:bit is using, run:

uv run microbit-mcp --list-ports

This will show all available serial ports and highlight likely micro:bit devices. The output will look something like:

Available Serial Ports:

Likely micro:bit devices:
  /dev/cu.usbmodem2114202 - "BBC micro:bit CMSIS-DAP"
    Hardware ID: USB VID:PID=0D28:0204

All serial ports (3 found):
  /dev/cu.usbmodem2114202 - "BBC micro:bit CMSIS-DAP" ⭐
  /dev/cu.Bluetooth-Incoming-Port - Bluetooth-Incoming-Port
  /dev/cu.usbserial-A1B2C3D4 - USB Serial Device

Recommended: Use /dev/cu.usbmodem2114202 for your micro:bit

The ⭐ symbol indicates ports that are likely micro:bit devices.

Button Press Tool

The wait_for_button_press tool allows you to wait for button presses on the micro:bit with flexible configuration options.

Parameters (all optional)

  • button (optional): Which specific button to wait for
    • "a" - Wait only for button A
    • "b" - Wait only for button B
    • If not specified, waits for any button press
  • timeout (optional): Maximum time to wait in seconds (default: 10.0)

Usage Examples

Wait for any button with default timeout:

{}

Wait for any button with custom timeout:

{
  "timeout": 5.0
}

Wait for specific button A:

{
  "button": "a"
}

Wait for button B with custom timeout:

{
  "button": "b",
  "timeout": 3.0
}

Response Format

Success response:

{
  "button_pressed": "a",
  "timeout": false,
  "timestamp": 12345,
  "waited_for": "any"
}

Timeout response:

{
  "button_pressed": null,
  "timeout": true,
  "timestamp": null,
  "waited_for": "any",
  "timeout_duration": 10.0
}

Communication Protocol

The server communicates with the micro:bit using simple text commands over serial:

  • MESSAGE:<text> - Display text message
  • IMAGE:<pattern> - Display image pattern (e.g., "00300:03630:36963:03630:00300")
  • TEMP: - Request temperature reading
  • WAIT_BUTTON:<button>:<timeout> - Wait for button press (e.g., "WAIT_BUTTON:a:10" or "WAIT_BUTTON:any:5")

The micro:bit responds with status events and data in the format:

  • STATUS|<message>|<timestamp> - General status updates
  • TEMP|<celsius>|<timestamp> - Temperature response
  • BUTTON|<button>|<action>|<timestamp> - Button press event (e.g., "BUTTON|a|pressed|12345")
  • BUTTON_TIMEOUT|<waited_for>|<timeout_duration> - Button wait timeout

Using the MCP Inspector

To test/debug the server, you can also use the MCP Inspector. To launch the inspector:

  1. Run npx @modelcontextprotocol/inspector (recommend LTS-version of Node)
  2. The inspector will launch in a new browser window.
  3. Set transport type to STDIO, command is the full path to your uv binary (e.g., /Users/yourname/.local/bin/uv), arguments is --directory /full-path-to-the-mcp-server run microbit-mcp
  4. Click on the Connect button to connect and inspect the MCP server.

Project Structure

The project is organized as follows:

microbit-mcp/
├── src/
│   ├── mcp_server/             # Main MCP server package
│   │   ├── server.py           # Main server entry point
│   │   ├── microbit_client.py  # Serial communication with micro:bit
│   │   ├── protocol.py         # Command/response protocol definitions
│   │   └── tools/              # MCP tools organized by category
│   │       ├── display.py      # Display-related tools
│   │       ├── sensors.py      # Sensor-related tools
│   │       └── input.py        # Input-related tools
│   ├── microbit/               # Micro:bit firmware
│   │   ├── main.py            # Firmware to flash to micro:bit
│   │   └── README.md          # Micro:bit setup instructions
│   └── examples/               # Usage examples
└── README.md                   # This file

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_simonguest_microbit_mcp-0.1.0.tar.gz (64.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_simonguest_microbit_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_simonguest_microbit_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 64.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_simonguest_microbit_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0eabc370d32a9cb1f09d621581b400218ab89f0c632db6d64fd3e97763ef2218
MD5 d073d5bffe16f02a739d11449fe531a6
BLAKE2b-256 babaa92676ae1a3343ec999fdc956816c76d4e12fb9adbf26311dc0613476324

See more details on using hashes here.

File details

Details for the file iflow_mcp_simonguest_microbit_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_simonguest_microbit_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_simonguest_microbit_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d3425b459d5bf8f22a635d723cd520d532f8ad440d95c0d678be489d205df00
MD5 3baa1ea8af17ae3358f2db5c419505e3
BLAKE2b-256 ce02fa13f3ea7142e4a8bf57ca509acde7b2a3d58213e671f7c0fa3c767cd8cb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page