OpenOCD MCP Server

An OpenOCD debug MCP server that manages debugging targets and sessions.

README.md

openocd-mcp

基于 fastmcp 的 OpenOCD 调试 MCP 服务,复用项目中的 .vscode/launch.json 作为调试目标来源。

当前阶段(MVP)

  • 已实现:项目切换、调试目标刷新、一次性烧录、调试会话启动/停止、GDB 命令执行、状态查询。
  • 未实现:RTT 相关能力(已拆分到独立文档)。

使用 uv 运行

uv sync
uv run openocd-mcp --openocd-path openocd --gdb-path arm-none-eabi-gdb

如果直接运行:

uv run openocd-mcp

服务会自动读取当前目录 config.json(若存在)中的路径配置。 参数优先级:命令行参数 > 环境变量 > config.json > 内置默认值。

启动为 SSE/HTTP(给本地其他 AI 客户端)

默认是 stdio

uv run openocd-mcp -sse

默认监听:http://127.0.0.1:9000/sse

可自定义:

uv run openocd-mcp -sse --host 127.0.0.1 --port 9000 --path /sse

也可通过环境变量配置:

  • OPENOCD_PATH
  • GDB_PATH
  • OPENOCD_SCRIPTS

VS Code MCP 配置

已提供 .vscode/mcp.json,使用 stdio + uv run openocd-mcp 启动服务。

如需改为 SSE,可使用:

{
	"servers": {
		"openocd-mcp": {
			"type": "sse",
			"url": "http://127.0.0.1:9000/sse"
		}
	},
	"inputs": []
}

工具列表(MVP)

  • set_project(project_dir)
  • refresh_debug_targets()
  • flash_download(config_name, firmware_path?)
  • debug_start(config_name, firmware_path?)
  • debug_stop()
  • debug_command(command)
  • debug_status()
  • get_runtime_config()

文档

  • 接口定义:接口定义.md
  • 架构设计:架构设计.md
  • RTT 特性(非 MVP):RTT特性.md

License

MIT

Tools 8

set_projectSets the current project directory.
refresh_debug_targetsRefreshes the available debug targets.
flash_downloadPerforms a firmware flash download.
debug_startStarts a debug session.
debug_stopStops the current debug session.
debug_commandExecutes a GDB command.
debug_statusQueries the current debug status.
get_runtime_configRetrieves the current runtime configuration.

Environment Variables

OPENOCD_PATHPath to the OpenOCD executable
GDB_PATHPath to the GDB executable
OPENOCD_SCRIPTSPath to OpenOCD scripts directory

Try it

Refresh my debug targets and start a new debug session for the current project.
Flash the firmware located at build/firmware.elf to my target device.
Check the current status of the debug session.
Execute a GDB command to reset the target device.
Stop the active debug session.

Frequently Asked Questions

What are the key features of OpenOCD MCP?

Reuses VS Code launch.json configurations for debug targets. Supports firmware flashing and GDB command execution. Provides real-time status monitoring of embedded systems. Supports both stdio and SSE/HTTP transport modes.

What can I use OpenOCD MCP for?

Automating firmware flashing workflows directly from an AI chat interface. Managing complex embedded debugging sessions without leaving the IDE. Integrating GDB command execution into AI-assisted troubleshooting workflows.

How do I install OpenOCD MCP?

Install OpenOCD MCP by running: uv run openocd-mcp --openocd-path openocd --gdb-path arm-none-eabi-gdb

What MCP clients work with OpenOCD MCP?

OpenOCD MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep OpenOCD MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare