微型mcp
把你的BBC micro:bit变成一个 模型上下文协议 (MCP)服务器
使用此库,您将能够在TypeScript中定义MCP工具(块尚未) 并使用桥接脚本通过stdio连接到MCP客户端。
https://github.com/user-attachments/assets/48418354-385a-45e9-bee1-7e36633dd243
示例
此示例显示了如何定义一个在micro:bit的LED矩阵上显示数字的工具。
mcp.tool({
definition: {
name: "show_number",
description: "Show a number on the 5 x 5 LED matrix",
inputSchema: {
type: "object",
properties: {
number: { type: "integer", description: "Integer to show" }
},
required: ["number"]
},
annotations: {
title: "Show Number",
idempotentHint: true,
}
},
handler: (args: { number: number }) => {
const number = args.number || 0;
basic.showNumber(number);
return `ok`;
}
})
mcp.startServer()Visual Studio Code
要测试MCP服务器,您可以使用 bridge 此存储库中的脚本。
- 安装依赖项
npm ci- 创建一个
.vscode/mcp.json此存储库根目录中的文件,内容如下:
{
"servers": {
"micro-mcp": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/bridge.mjs"]
}
}
}- 打开GitHub Copilot聊天
- 打开
mcp.json文件并启动服务器 - 点击
Tools图标,并确保您的工具已列出并选中 - 赶快离开!
用作扩展
此存储库可以添加为 扩展 在MakeCode中。
- 打开 https://makecode.microbit.org/
- 点击 新项目
- 点击 扩展 在齿轮菜单下
- 搜索 https://github.com/pelikhan/micro-mcp 和进口
编辑此项目
使用Visual Studio代码编辑此项目。
元数据(用于搜索、呈现)
- PXT/微生物
