EmbedForge
by He-user520
README.md
# EmbedForge
> AI 嵌入式一体化开发平台 — MCP-first 架构,让 AI 直接帮你写嵌入式代码
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
[]()
EmbedForge 把 **AI 代码生成 → 编译 → 烧录 → 测试 → 自动修复** 打通成一个闭环,
并以 MCP Server 形式接入 Claude Code / Trae / Cursor 等编程工具,让你用自然语言就能完成嵌入式开发。
---
## 核心能力
| 能力 | 说明 |
|------|------|
| AI 代码生成 | 支持多 LLM 后端(Ollama / OpenAI / Anthropic / Echo) |
| 多构建系统 | 自动检测 PlatformIO / CMake / Makefile / ESP-IDF / GCC 裸机 |
| 硬件交互 | 串口监视、OpenOCD 烧录、Wokwi 仿真 |
| 闭环编排 | 生成→编译→烧录→测试→自动修复,最多 N 轮迭代 |
| 独立修复 | `fix` 命令根据编译错误或串口日志修复已有代码 |
| MCP Server | 一键接入 Claude Code / Trae / Cursor |
---
## 快速开始
### 方式一:一键安装脚本(推荐)
```powershell
# 克隆项目
git clone https://github.com/He-user520/EmbedForge.git
cd EmbedForge
# 运行安装脚本(自动安装依赖 + 配置 MCP)
.\install.ps1
```
### 方式二:手动安装
```bash
# 克隆
git clone https://github.com/He-user520/EmbedForge.git
cd EmbedForge
# 安装
pip install -e ".[dev]"
# 一键接入编程工具
embedforge mcp install
```
安装完成后 **重启 Claude Code / Trae / Cursor**,即可使用。
---
## 接入编程工具
```bash
# 自动检测并安装到所有可用工具
embedforge mcp install
# 只安装到 Claude Code
embedforge mcp install -t claude
# 只安装到 Trae(项目级配置)
embedforge mcp install -t trae -p .
# 只安装到 Cursor
embedforge mcp install -t cursor
# 强制覆盖已有配置
embedforge mcp install --force
```
接入后,你可以在编程工具里直接说:
- "帮我创建一个 STM32 的点灯程序"
- "编译一下这个项目"
- "把固件烧录到开发板"
- "读取串口日志,看看哪里错了,帮我修"
---
## CLI 命令一览
```bash
# 一键开发:AI生成 → 编译 → 烧录 → 测试 → 自动修复
embedforge dev "在STM32F407上配置USART2发送Hello World" --mcu STM32F407VG
# 编译项目
embedforge build -p ./myproject
# 烧录固件
embedforge flash -p ./myproject
# 串口监视器
embedforge monitor --port COM3
# 初始化新项目
embedforge init myproject --mcu STM32F407VG
# 根据编译错误修复代码
embedforge fix compile -p ./myproject
# 根据串口运行时日志修复代码
embedforge fix runtime -p ./myproject --port COM3
# 以 MCP Server 模式启动
embedforge mcp start -s ai
# 检查依赖环境
embedforge doctor
```
---
## 项目结构
```
embedforge/
├── cli/ # 命令行接口
│ └── main.py # 所有 CLI 命令
├── core/ # 核心模块
│ ├── config.py # 配置管理
│ ├── orchestrator.py # 闭环编排器
│ ├── templates.py # 代码模板
│ └── exceptions.py # 异常定义
├── servers/ # MCP Server 实现
│ ├── ai_server/ # AI 代码生成服务
│ ├── build_server/ # 构建编译服务
│ │ ├── base.py # 构建系统自动检测
│ │ ├── platformio.py # PlatformIO 后端
│ │ ├── cmake.py # CMake 后端
│ │ ├── esp_idf.py # ESP-IDF 后端
│ │ └── gcc.py # GCC 裸机后端
│ └── hardware_server/ # 硬件交互服务
│ ├── serial.py # 串口通信
│ ├── flash.py # 固件烧录
│ ├── debug.py # 调试接口
│ └── simulation.py # Wokwi 仿真
├── templates/ # 项目模板
│ ├── stm32_baremetal/ # STM32 裸机模板
│ ├── stm32_freertos/ # STM32 FreeRTOS 模板
│ ├── arduino_basic/ # Arduino 基础模板
│ └── esp32_wifi/ # ESP32 WiFi 模板
└── tests/ # 测试套件(44 个用例)
```
---
## 支持的硬件
| MCU | 构建系统 | 烧录方式 |
|-----|---------|---------|
| STM32 (F1/F4/H7) | PlatformIO / CMake / GCC | OpenOCD / ST-Link |
| ESP32 / ESP8266 | ESP-IDF / PlatformIO | esptool |
| Arduino | PlatformIO | avrdude |
| 通用 ARM | GCC 裸机 | OpenOCD |
---
## 开发
```bash
# 运行测试
pytest tests/ -v
# 代码检查
ruff check embedforge/
# 类型检查
mypy embedforge/
```
---
## License
MIT
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues