microbit-claude-mcp
v0.2.0
Published
MCP server for BBC micro:bit: CODAL firmware tools, MakeCode TypeScript projects, and a human-in-the-loop MicroPython help desk for classrooms.
Maintainers
Readme
microbit-claude-mcp
MCP server for micro:bit v2 CODAL projects. It exposes a small REST API plus an MCP stdio bridge so agents can read and write source/main.cpp, list sources, validate a project, and run build.py to generate MICROBIT.hex.
Features
- Validate a CODAL project layout
- Read and write source files (defaults to
source/main.cpp) - List C/C++ source files
- Run
build.pyto build firmware - REST + MCP stdio transport
Requirements
- A micro:bit v2 CODAL project (for example
microbit-v2) withbuild.pyandsource/ - Python 3 available as
python(or setMICROBIT_PYTHON) - The micro:bit toolchain required by your CODAL project
- Node.js 18+
Installation
Global install:
npm install -g microbit-claude-mcpLocal dev:
npm install
npm run build
npm run build:mcpUsage
Run the REST server
microbit-claude-mcpDefaults to port 3040. Override with:
$env:PORT=3041
microbit-claude-mcpRun the MCP stdio server
node build/mcp.jsIf your REST server is not on the default port, set one of:
MICROBIT_API_URL(full URL, for examplehttp://localhost:3041)MICROBIT_API_PORT(port only, for example3041)
MCP client config
{
"mcpServers": {
"microbit-mcp": {
"command": "node",
"args": ["/absolute/path/to/build/mcp.js"]
}
}
}Tutorial (10 minutes)
- Start the REST server.
- Validate the project:
POST /validate- Body:
{ "projectRoot": "/path/to/microbit-v2" }
- Read the main source:
POST /read_source- Body:
{ "projectRoot": "/path/to/microbit-v2" }
- Write a small change:
POST /write_source- Body:
{ "projectRoot": "/path/to/microbit-v2", "content": "// your code" }
- Build (optional):
POST /build- Body:
{ "projectRoot": "/path/to/microbit-v2" }
Environment variables
PORT: REST server port (default3040)MICROBIT_API_URL: REST base URL for the MCP bridgeMICROBIT_API_PORT: REST port for the MCP bridgeMICROBIT_PYTHON: Python executable forbuild.pyMICROBIT_BUILD_TIMEOUT_MS: Build timeout in ms (default120000)
REST API
Health
GET /health->{ status: "ok" }
Validate
POST /validatebody:{ projectRoot: string }- Returns
{ valid, missing, projectRoot }
List sources
POST /list_sourcesbody:{ projectRoot: string }- Returns
{ files: string[] }
Read source
POST /read_sourcebody:{ projectRoot: string, relativePath?: string }- Returns
{ path, content }
Write source
POST /write_sourcebody:{ projectRoot: string, relativePath?: string, content: string }- Returns
{ success, path, bytes }
Append source
POST /append_sourcebody:{ projectRoot: string, relativePath?: string, content: string }- Returns
{ success, path, bytes }
Build
POST /buildbody:{ projectRoot: string, timeoutMs?: number }- Returns
{ success, exitCode, stdout, stderr, hexPath, hexExists }
Clawdbot / Moltbot compatibility
This repo ships a skill at skills/microbit-mcp/SKILL.md.
Enable it in Moltbot:
{
"skills": {
"load": {
"extraDirs": ["~/.clawdbot/skills"],
"watch": true,
"watchDebounceMs": 250
},
"entries": {
"microbit-mcp": {
"enabled": true,
"env": {}
}
}
}
}Example prompts
- "Open this micro:bit project and add a scrolling LED message that says HELLO."
- "Read source/main.cpp and explain what the program currently does."
- "Add a button A handler that toggles the LED matrix, then build the firmware."
Testing
npm testThe tests focus on REST behavior. The build endpoint is not exercised unless a working CODAL toolchain is installed.
Publishing
- Update
package.jsonversion - Build:
npm run build npm run build:mcp - Publish:
npm publish --access public - Tag and push to trigger
.github/workflows/publish.yml
Project structure
src/index.tsREST APIsrc/mcp.tsMCP stdio bridgeskills/microbit-mcp/SKILL.mdagent skillserver.jsonMCP registry metadata
Contributing
PRs welcome. Please keep changes small and include tests where possible.
License
MIT
