stmctl-mcp
Enables CrewAI agents to program STM32 firmware, read/write memory, erase chips, and control hardware through the STM32_Programmer_CLI interface.
Provides LangChain agents with tools for discovering ST-Link probes, connecting to STM32 chips, flashing firmware, and executing hardware control commands like reset and memory manipulation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@stmctl-mcp flash firmware.bin to STM32"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
STM32 Flashing & Hardware Control MCP Server (stmctl-mcp)
A production-grade Model Context Protocol (MCP) server wrapping STM32CubeCLT (STM32_Programmer_CLI.exe). This MCP server enables any AI coding assistant or agent framework (Antigravity, Claude Desktop, Cursor, custom Node.js/Python agents) to perform hardware flashing, memory dumps, option byte modification, chip erase, board resets, and live SWO printf log tracing.
Hardware & Software Requirements
1. Host Computer Requirements
Node.js: v18.0.0 or higher
Operating System: Windows 10 / 11, Linux, or macOS
2. Platform Installation Scripts (scripts/)
Automated installer & environment setup scripts are provided in the scripts/ folder:
Windows:
scripts/install_win.batLinux:
scripts/install_linux.sh(Includes ST-LINK USBudevpermission rules setup)macOS:
scripts/install_mac.sh(Includes Homebrewstlinkfallback check)
Related MCP server: stm32-mcp
Flexible Path Configuration & Dynamic Resolution Hierarchy
To accommodate different computers, OS environments, and version numbers (e.g., STM32CubeCLT_1.17.0, 1.22.0, 2.0.0), stmctl-mcp resolves STM32_Programmer_CLI.exe using the following priority sequence:
Priority 1: Local Configuration File (stmctl_config.json)
You can manually specify any custom path in stmctl_config.json in the server root directory:
{
"cli_path": "C:\\MyCustomPath\\STM32_Programmer_CLI.exe",
"default_port": "SWD",
"default_mode": "HOTPLUG"
}Priority 2: Environment Variable
Set STM32_PROGRAMMER_CLI_PATH in your environment or MCP launcher configuration:
STM32_PROGRAMMER_CLI_PATH=C:\ST\STM32CubeCLT_1.22.0\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exePriority 3: Automatic Dynamic Version Scanning (C:\ST\STM32CubeCLT_*)
If no manual path is specified, stmctl-mcp automatically scans C:\ST\ for any installed version number (sorting highest version first) to locate:
C:\ST\STM32CubeCLT_<version>\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe
Priority 4: Standard Program Files Directories
Scans standard Program Files, Program Files (x86), /usr/local/STMicroelectronics/..., /opt/st/..., and /Applications/... directories.
Priority 5: System PATH Fallback
Tries executing STM32_Programmer_CLI directly from system environment PATH.
Capabilities & Tools Exposed
stm32_list_probes: Discover connected ST-LINK, J-Link, UART COM ports, USB devices.stm32_connect_info: Query chip ID, Flash/RAM size, revision ID, CPU core.stm32_flash_firmware: Program.bin,.hex,.elf,.srecfiles with automatic erase, verification, reset, and run flags.stm32_erase_memory: Perform full chip mass erase or sector/page erase.stm32_read_memory: Read raw memory addresses or dump to.bin/.hexfiles.stm32_write_memory: Write bytes/words to specific memory addresses or peripheral registers.stm32_read_option_bytes: Read RDP protection level, BOR level, Watchdog, and Boot flags.stm32_write_option_bytes: Modify Option Bytes (e.g.RDP=0xAA,nBOOT0=1).stm32_reset_mcu: Hardware (HWrst), Software (SWrst), or Core (Crst) reset.stm32_run_mcu: Start or resume program execution at specified address.stm32_start_swv_trace: Stream/capture live SWO Serial Wire Viewer printf logs.stm32_raw_cli: Direct passthrough for any customSTM32_Programmer_CLIflags.
Installation & Build
1. Install Dependencies
npm install2. Build TypeScript Source
npm run buildThis compiles TypeScript files into ./dist/index.js.
How to Integrate stmctl-mcp into Any Agent
Method 1: Desktop IDEs & Apps (Antigravity, Claude Desktop, Cursor, VS Code)
Add the JSON configuration block below to your application's MCP settings file (e.g., claude_desktop_config.json or .vscode/mcp.json):
{
"mcpServers": {
"stmctl-mcp": {
"command": "node",
"args": [
"c:/Users/kunur/OneDrive/Documents/Smarttrak/Firmware_Agent/STMCTL_MCP/dist/index.js"
]
}
}
}Method 2: Custom Node.js / TypeScript Agent
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
async function main() {
const transport = new StdioClientTransport({
command: "node",
args: ["c:/Users/kunur/OneDrive/Documents/Smarttrak/Firmware_Agent/STMCTL_MCP/dist/index.js"],
});
const client = new Client({ name: "firmware-agent-host", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);
const probeResult = await client.callTool({
name: "stm32_list_probes",
arguments: {},
});
console.log("Probes Result:", probeResult.content[0].text);
}
main().catch(console.error);Method 3: Custom Python Agent (LangChain / LlamaIndex / CrewAI / AutoGen)
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def run_firmware_agent():
server_params = StdioServerParameters(
command="node",
args=["c:/Users/kunur/OneDrive/Documents/Smarttrak/Firmware_Agent/STMCTL_MCP/dist/index.js"],
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool("stm32_list_probes", arguments={})
print("Probe Result:", result.content[0].text)
asyncio.run(run_firmware_agent())Method 4: Interactive Web Browser Debugging (MCP Inspector)
npm run inspectorThis opens the MCP Inspector UI at http://localhost:5173.
Available Tools
12 toolsstm32_connect_infoA
Connect to target STM32 MCU and retrieve Chip ID, Flash size, Revision ID, and CPU Core details.
Inputs: sn, freq, mode, port, +1 more.
stm32_erase_memoryB
Perform Flash memory erase operation (Full Chip Mass Erase or Sector/Page Erase).
Inputs: sn, port, sectors, erase_type.
stm32_flash_firmwareA
Flash/program firmware file (.bin, .hex, .elf, .srec) to target STM32 MCU with optional verification, mass erase, reset, and run.
Inputs: file_path (required), sn, port, verify, +3 more.
stm32_list_probesA
List all connected ST-LINK debug probes, J-Link programmers, USB bootloaders, and COM serial ports.
Inputs: interface_type.
stm32_raw_cliA
Run raw parameters directly against STM32_Programmer_CLI for advanced/custom operations.
Inputs: args (required).
stm32_read_memoryA
Read target MCU memory or register contents and return hex dump or output to binary file.
Inputs: size (required), address (required), port, output_file.
stm32_read_option_bytesA
Read target MCU Option Bytes configuration (RDP protection level, BOR, Watchdog, Boot flags).
Inputs: sn, port.
stm32_reset_mcuB
Trigger reset signal on target MCU.
Inputs: port, reset_type.
stm32_run_mcuB
Start or resume program execution at specified address or entry point.
Inputs: port, address.
stm32_start_swv_traceA
Connect to Serial Wire Viewer (SWO/ITM) and stream printf log outputs.
Inputs: log_file, port_number, clock_freq_mhz.
stm32_write_memoryB
Write value or file payload directly to memory address or peripheral register.
Inputs: address (required), data_or_file (required), port.
stm32_write_option_bytesA
Modify target MCU Option Bytes (e.g. set RDP=0xAA to remove read protection, set nBOOT0, etc.).
Inputs: option_bytes (required), port.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Each tool targets a distinct STM32 operation (probing, firmware flashing, memory access, option bytes, reset/run, tracing). Potential overlaps like read_memory vs read_option_bytes are clearly separated by the resource type they act on.
All tools share the stm32_ prefix and use snake_case with a clear verb_noun structure (list_probes, flash_firmware, read_memory, write_option_bytes). Even the specialized stm32_raw_cli follows the same pattern and is easily recognizable.
12 tools provide a well-scoped surface for STM32 programming and debugging, covering the full workflow without redundancy or bloat. The count is ideal for this domain.
The set covers the complete lifecycle: discovery, connection, flashing, memory and option byte read/write, erasing, reset, run, and tracing. Advanced needs are handled via raw_cli, ensuring no obvious dead ends.
Maintenance
Related MCP Connectors
- DNS-DATA RemoteDeprecatedcom.dns-data
Connect AI assistants to authorized Windows and macOS devices for files, commands, and management.
Design circuits, simulate and verify embedded firmware, and lay out PCBs with AI agents.
Run, build, and validate firmware on virtual hardware from your AI agent. Hardware knowledge corpus.
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with STM32 development boards via J-Link debugger using RTT communication, supporting connection, logging, memory operations, and firmware flashing through natural language.121MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude Code to build, flash, and communicate with STM32 hardware over SWD and serial, including multi-board management, live memory monitoring, and hardware sequences.25MIT
- AlicenseAqualityBmaintenanceEnables AI coding assistants to perform complete headless STM32 embedded firmware development, including project creation, pin configuration, code generation, building, and flashing, by driving the official STM32 command-line toolchain.29MIT
- AlicenseAqualityCmaintenanceThis server enables AI agents to fully control STM32CubeIDE and STMicroelectronics hardware, including GUI automation, headless builds, flashing, GDB debugging, option bytes, serial telemetry, and CubeMX .ioc engineering.342Apache 2.0