h7tools-mcp

h7tools-mcp

Read-only MCP server for diagnosing H7-TOOL hardware via Modbus, USB HID, and Lua diagnostics, exposing only safe read operations.

Category
访问服务器

README

H7-TOOL MCP Assistant

中文说明

This project provides a local MCP server for H7-TOOL. After it is enabled in an AI client, the AI can call H7-TOOL-related tools to inspect the connected programmer, search the local device library, identify a target board, and read development diagnostics.

The public documentation only covers installation and usage. Product-internal communication details are intentionally not documented here.

What It Does

  • Lists available H7-TOOL USB interfaces and local bridge settings.
  • Reads H7-TOOL status and health information.
  • Searches the local H7-TOOL device Lua library by vendor, series, or chip name.
  • Searches bundled H7-TOOL Lua examples and bus helper scripts so the AI can inspect original peripheral usage.
  • Provides public safety and style rules for AI-authored H7-TOOL Lua helper scripts.
  • Provides an offline Lua draft workspace to create, list, read, and validate drafts without executing them.
  • Provides a dangerous-action policy gate for future programming, erase, unlock, protection, power, and raw-Lua actions.
  • Parses device profiles for interface type, expected ID, UID location, memory ranges, included libraries, and algorithm entries.
  • Summarizes profile capabilities so the AI can understand what a chip profile appears to support.
  • Probes a connected STM32H7 target and combines live results with the selected local profile.
  • Reads bounded target memory ranges for diagnostics.
  • Reads option-byte values described by a selected local profile.
  • Summarizes protection status when the selected profile provides the required rules.
  • Sends and receives short data through H7-TOOL UART channels for loopback tests, AT commands, and simple serial debugging.
  • Sends bounded CAN/CAN-FD frames through H7-TOOL.
  • Scans I2C addresses or performs one bounded I2C write/read transaction.
  • Performs one bounded SPI write/read transaction with CS0 or CS1.
  • Attempts to read SEGGER RTT up-buffer logs from target firmware.

Directory Layout

Recommended layout:

h7toolPC_release/
  EMMC/
    H7-TOOL/
      Programmer/
        Device/
  mcp/
    h7tool_mcp.py
    README.md
    requirements.txt
    config.json

In other words, place or clone this repository as the mcp directory under the H7-TOOL PC software package root, beside EMMC.

Example:

cd D:\Tools\h7toolPC_release
git clone https://github.com/zhe0523/h7tools-mcp.git mcp

This layout lets the MCP server find the H7-TOOL device library automatically.

Install

Use Python 3.11 or newer.

cd D:\Tools\h7toolPC_release\mcp
python -m pip install -r requirements.txt
python h7tool_mcp.py --self-test

If the self-test prints Self-test passed, the Python side is working.

Configure H7-TOOL Access

Create a local config.json from the example that matches your connection method. The most common current path is USB HID:

copy config.usb-hid.example.json config.json
python h7tool_mcp.py --list-hid-devices

If more than one matching H7-TOOL interface is found, copy the correct serial_number into config.json.

Useful local checks:

python h7tool_mcp.py --device-vendors
python h7tool_mcp.py --device-search STM32H743 --device-vendor ST
python h7tool_mcp.py --lua-example-search BH1750 --lua-example-interface i2c
python h7tool_mcp.py --lua-authoring-rules
python h7tool_mcp.py --lua-draft-list
python h7tool_mcp.py --dangerous-action-policy
python h7tool_mcp.py --device-profile ST/STM32H7xx/STM32H7x_2M.lua
python h7tool_mcp.py --lua-health
python h7tool_mcp.py --target-identity ST/STM32H7xx/STM32H7x_2M.lua
python h7tool_mcp.py --target-summary ST/STM32H7xx/STM32H7x_2M.lua
python h7tool_mcp.py --target-flash-info ST/STM32H7xx/STM32H7x_2M.lua

config.json is intentionally ignored by git because it contains local device settings.

Dangerous actions are disabled by default. Future programming, erase, unlock, protection, power-control, and raw-Lua tools must check dangerous_actions in config.json and require the matching confirmation phrase on each request.

Start The MCP Server

The MCP server uses stdio. Usually you do not start it manually; your AI client starts it.

On Windows, prefer the launcher script:

D:\Tools\h7toolPC_release\mcp\h7tool_mcp.cmd

Replace the path with the absolute path on your machine. The launcher avoids many client-specific differences around Python launchers, argument splitting, non-ASCII paths, and paths containing spaces.

For manual command-line checks, use one of the flags shown by:

python h7tool_mcp.py --help

When no flag is provided, the program waits for MCP JSON-RPC messages on stdin/stdout, which is what MCP clients expect.

Connect From AI Tools

Configure this repository's h7tool_mcp.cmd as a local stdio MCP server.

Before connecting an AI client, verify the server from a terminal:

cd D:\Tools\h7toolPC_release\mcp
.\h7tool_mcp.cmd --self-test
.\h7tool_mcp.cmd --lua-health

Then verify any hardware workflow you plan to expose to the AI:

.\h7tool_mcp.cmd --target-summary ST/STM32H7xx/STM32H7x_2M.lua --include-protection-status
.\h7tool_mcp.cmd --uart-transact --uart-channel 1 --uart-baud 115200 --uart-send-hex "48 37 0D 0A" --uart-rx-length 64
.\h7tool_mcp.cmd --i2c-transact --i2c-clock 100000 --i2c-scan
.\h7tool_mcp.cmd --spi-transact --spi-freq-id 0 --spi-cs 0 --spi-write-hex "9F" --spi-read-length 3

Most AI clients need the same fields:

  • Name: h7tool
  • Type: stdio
  • Command: D:\Tools\h7toolPC_release\mcp\h7tool_mcp.cmd
  • Arguments: empty

If a client cannot launch .cmd directly, use cmd as the command and /c D:\Tools\h7toolPC_release\mcp\h7tool_mcp.cmd as the arguments.

Codex / ChatGPT Desktop / Codex IDE

Open the Codex MCP settings and add a stdio server, or edit ~/.codex/config.toml:

[mcp_servers.h7tool]
command = 'D:\Tools\h7toolPC_release\mcp\h7tool_mcp.cmd'
args = []
enabled = true
startup_timeout_sec = 20
tool_timeout_sec = 60

You can also add it with Codex CLI:

codex mcp add h7tool -- D:\Tools\h7toolPC_release\mcp\h7tool_mcp.cmd
codex mcp list

After adding the server, restart or reload the AI client if it does not appear immediately. Ask the AI to call bridge_status to confirm the connection.

Cherry Studio

In Cherry Studio, open Settings -> MCP Server -> Add server, choose STDIO, then set:

Name: h7tool
Command: D:\Tools\h7toolPC_release\mcp\h7tool_mcp.cmd
Arguments: empty

Chinese step-by-step guide: Cherry Studio 配置 H7-TOOL MCP 教程.

Claude Code / Claude Desktop / opencode

These clients use the same local stdio MCP idea. Chinese multi-client guide: AI 客户端接入 H7-TOOL MCP 指南.

Lua helper authoring rules are documented in Chinese here: AI 编写 H7-TOOL Lua 辅助脚本规则.

How To Ask The AI To Use It

Once the MCP server is connected, ask the AI to use the H7-TOOL tools directly. Example prompts:

Use the h7tool MCP server to list available H7-TOOL interfaces.
Use h7tool to search the local device library for STM32H743.
Use h7tool lua_example_search to find bundled I2C BH1750 examples and summarize how they are called.
Use h7tool lua_authoring_rules before drafting a custom H7-TOOL Lua helper script.
Use h7tool lua_draft_create to draft an I2C register-read Lua helper, then validate it with lua_draft_validate without executing it.
Use h7tool dangerous_action_policy to check whether programming, erase, unlock, protection, and similar dangerous actions are currently allowed.
Use h7tool target_identity with ST/STM32H7xx/STM32H7x_2M.lua and summarize the connected target.
Use h7tool target_summary with ST/STM32H7xx/STM32H7x_2M.lua and recommend the next diagnostic step.
Use h7tool protection_status for the selected STM32H7 profile and explain the result.
Use h7tool uart_transact on channel 1, 115200 8N1, send hex: 48 37 0D 0A, and read up to 64 response bytes.
Use h7tool can_transact at 500K bitrate to send standard frame ID 0x321 with data 01 02 03 04.
Use h7tool i2c_transact to scan I2C addresses at 100K clock.
Use h7tool spi_transact with freq_id 0, phase 0, polarity 0, CS0, send hex 9F, and read 3 bytes.
Use h7tool rtt_read to try reading target RTT channel 0 logs.

Good workflow:

  1. Ask the AI to check bridge_status.
  2. Ask it to search or inspect the target device profile.
  3. Ask it to run lua_health or health_summary.
  4. Ask it to run target_summary.
  5. Ask for focused memory, option-byte, RTT, or peripheral transactions only after the target profile is selected.

Available MCP Tools

  • bridge_status
  • device_vendors
  • device_search
  • lua_example_search
  • lua_authoring_rules
  • lua_draft_create
  • lua_draft_list
  • lua_draft_read
  • lua_draft_validate
  • dangerous_action_policy
  • dangerous_action_explain
  • device_profile
  • device_capabilities
  • tool_status
  • health_summary
  • lua_health
  • target_probe
  • target_identity
  • target_summary
  • target_flash_info
  • tool_registers
  • read_option_bytes
  • protection_status
  • uart_transact
  • can_transact
  • i2c_transact
  • spi_transact
  • rtt_read
  • log_tail
  • read_memory

Notes

Device scripts in the H7-TOOL package often describe whole chip families rather than one exact part number. For example, searching for STM32H743 may return a generic STM32H7 profile. Use live target data, profile metadata, and chip-specific registers together when exact identification matters.

Only one program should actively control the same H7-TOOL operation path at a time. If an AI call times out or returns an unexpected result, close conflicting operations in the PC tool and try again.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选