AI hardware

AI Hardware Debugging: Agents and Lab Instruments

A closed laptop sits beside a small debug box connected by one cable to a bare circuit board.Illustration

An AI agent can run hardware debugging steps through tools exposed over the Model Context Protocol: query instruments with SCPI through PyVISA, read serial logs, and flash firmware with OpenOCD, pyOCD or esptool. Read-only calls carry the least risk. Output changes, erases and permanent writes need hard limits in code, human approval and a log of every call.

AI coding agents can call tools on the computer next to your bench: read a serial log, query a power supply, flash a build and try again. This guide covers the Model Context Protocol for exposing tools, SCPI and VISA for instruments, serial logs, and probe tools for flashing. It ends with a risk table, the guardrails each action needs, and what still needs an engineer.

This is an engineering summary based on public specifications and tool documentation, which change often. All sources were read on November 15, 2026.

What does an AI agent need to drive a hardware bench?

An agent needs a way to call tools, tools that reach the hardware, and rules about which calls it may make alone. The Model Context Protocol (MCP) covers the first part. Its documentation describes MCP as an open-source standard for connecting AI applications to external systems (MCP introduction, as of November 2026).

In MCP, a server exposes tools that a language model can invoke. Each tool has a JSON Schema for its inputs. The specification calls tools model-controlled: the model can discover and invoke them on its own. It also says that, for trust and safety, there should always be a human in the loop with the ability to deny tool invocations (MCP tools specification, revision 2026-07-28, as of November 2026).

A bench server usually runs on the same computer as the instruments. The MCP architecture page says the stdio transport uses standard input and output streams between local processes on the same machine, and that local servers using it typically serve a single client (MCP architecture, as of November 2026).

Before an agent touches a board, the team should know which signals matter and what a pass looks like. For how firmware, electronics and app work meet, see hardware/software integration in a device project.

How does an agent talk to lab instruments?

SCPI and VISA

The IVI Foundation describes SCPI as a common interface language between computers and test instruments. It is built on IEEE-488.2, its syntax is ASCII text, and SCPI strings can be sent over GPIB, RS-232, VXIbus or LAN (IVI Foundation, The SCPI Standard, as of November 2026).

PyVISA brings VISA to Python. Its guide shows the loop: create a ResourceManager, call list_resources, open one resource and send *IDN? with query, which is a write followed by a read. Without arguments, PyVISA prefers the IVI backend and falls back to pyvisa-py if it is installed (PyVISA, communicating with your instrument, as of November 2026). Each call can become one agent tool, with commands limited to an allowed list.

Where it breaks

PyVISA warns that a wrong setup usually shows up as a VisaIOError reporting a timeout, and that most fixes come from setting the read and write termination characters. For serial instruments, the default baud rate is 9600, and slow instruments may need a delay such as 100 ms between write and read (PyVISA, as of November 2026).

Return a timeout to the agent as an explicit error. An empty reading invites it to conclude the rail is at zero.

Protection lives in the instrument too

Programmable supplies have their own trips. In the Magna-Power SCPI manual, VOLT:PROT sets the over voltage trip level: if the output exceeds it, the supply disables its output and sets a status bit. CURR:PROT does the same for current, and a trip is cleared with OUTP:PROT:CLE after the cause is removed (Magna-Power SOURce subsystem, as of November 2026). Set these trips before the agent starts, and give the agent no tool that changes them.

How does an agent read serial logs safely?

In Python, serial logs are read with pySerial. Its guide warns that readline() can block forever if no newline arrives, so open the port with a timeout. If the returned line has no newline at the end, the read ended on timeout (pySerial short introduction, as of November 2026).

On a bench with several boards, pySerial's list_ports returns ports in no particular order, and the strings differ across operating systems for the same device. On Linux, macOS and Windows, the hardware ID of a USB port includes VID:PID, the serial number and the USB location (pySerial tools, as of November 2026). Bind each board to a serial number in a config file, and have the tool refuse a port that does not match.

Log text is also input to the model. The MCP specification says clients should validate tool results before passing them to the model (MCP tools specification, as of November 2026). A device under test can print text that reads like an instruction. Pass logs back as quoted data and cap their length.

How does an agent flash firmware through a debug probe?

Three scriptable tools show the range of what a probe tool can do.

  • OpenOCD. The program script runs init, then reset init to reset and halt the target, then flash write_image to erase and write. With the verify parameter it calls verify_image, and with the reset parameter it calls reset run (OpenOCD flash programming, as of November 2026).
  • pyOCD. The commander includes load for binary, hex or ELF files, erase for all internal flash or a range of sectors, read32 for memory, reset with a choice of reset types, and unlock to unlock security on the target (pyOCD command reference, as of November 2026).
  • esptool. For Espressif chips, write-flash takes address and file pairs. All 4096-byte sectors touched by a write must be erased first. Before flashing, esptool compares the chip ID and chip revision fields in the image header with the connected chip, and stops if an incompatible image targets the bootloader offset (esptool basic commands, as of November 2026).

The esptool page also shows why an agent should never pass override flags. Erasing flash is disabled by default when secure boot or flash encryption is active, as a safety measure against bricking, and the --force option overrides that check (esptool basic commands, as of November 2026). eFuses go further. Espressif's espefuse page says eFuses are one-time-programmable, bits only go from 0 to 1, and each burn asks the user to type BURN unless --do-not-confirm is passed (espefuse, as of November 2026).

For update design that survives power loss and bad images, see OTA update failures that brick devices, and for key handling before any lock bits are set, see secure boot and signed firmware.

Which bench actions are safe to hand to an agent?

The table sorts common actions by what they can break. The risk levels and guardrails are engineering reasoning from the tool documentation above, and none describes a specific project.

ActionExample callRiskGuardrail
Identify an instrument*IDN? through PyVISA queryLowAllow. Log the reply.
List serial portspySerial list_portsLowAllow. Match by serial number, never list order.
Read a serial logpySerial readline with a timeoutLowAllow. Treat the text as untrusted data.
Read target memorypyOCD read32LowAllow. Record the firmware build with the dump.
Reset the targetpyOCD reset, OpenOCD reset runMediumAllow with a rate limit.
Change supply voltage or currentSCPI source commandsHighClamp to a per-board limit in the server. Instrument trip as a second layer.
Turn a supply output onSCPI output commandHighHuman approval per session and after any wiring change.
Flash firmwareOpenOCD program, pyOCD load, esptool write-flashMediumOnly images from the build folder. Always verify.
Erase flashpyOCD erase, esptool erase-flashHighHuman approval each time.
Unlock target securitypyOCD unlockHighHuman only. Not in the agent tool list.
Burn eFuses or pass a force flagespefuse burn-efuse, any --forcePermanentBlocked in code. A person runs these by hand.

Reads run freely. Changes to power or memory need a limit in code and a person. Anything permanent stays out of the agent's tool list.

What guardrails does an agent bench need?

The MCP specification sets a baseline. Servers must validate all tool inputs, implement access controls, rate limit tool invocations and sanitize tool outputs. Clients should prompt for confirmation on sensitive operations, show tool inputs before calling the server, implement timeouts and log tool usage for audit (MCP tools specification, as of November 2026).

Do not trust labels

MCP lets a tool describe itself with hints. In the schema, readOnlyHint means the tool does not modify its environment, and destructiveHint means it may perform destructive updates. The schema calls all of these hints and says clients should never make tool use decisions based on annotations from untrusted servers (MCP schema reference, as of November 2026). Enforce the real limits inside the server code.

Local servers run code

The MCP security guide warns that local servers without sandboxing and consent allow arbitrary code execution and data loss. For one-click setup, it says the client must show the exact command that will run and require explicit user approval (MCP security best practices, as of November 2026). On a bench computer that also holds signing keys, run the instrument server under its own account with access only to what it needs.

Limits that hold when the model is wrong

Put voltage and current limits in two places: the server rejects any setpoint above the board limit, and the instrument trip catches what the server misses. Default every output to off when the server starts or loses its client. Log every call so a person can replay what happened. This is engineering reasoning built on the specification text above.

What works today, and what still needs an engineer?

Agents handle repetitive, scriptable loops well: build, flash, verify, reset, read the log, compare with the last run, and repeat. This is engineering reasoning based on the tools above being scriptable from a host computer.

An engineer is still needed where the work is physical or the judgment carries risk: wiring the board, choosing the probe point, telling noise from a fault, approving the first power-up of a new revision, and deciding what a pass means. For how bench tests later become a production test plan, see in-circuit test vs functional test, and for the day-to-day firmware loop the agent plugs into, see the embedded programming workflow.

If the device also has an app and a cloud side, see our device, app and cloud architecture work for how those parts connect.

What should you check before an agent touches a board?

Run these questions and tests on a spare board before you give an agent write access.

  • Are voltage and current limits stored per board in a file the agent cannot edit?
  • Is the instrument trip level set below the board rating, and has a test shown that it trips?
  • Does the server reject any argument outside its schema, including flags such as --force?
  • Does each write call wait for a human yes, with the exact command shown?
  • Is every tool call logged with time, inputs, result and firmware build?
  • Are ports and instruments picked by serial number, so the agent cannot reach the wrong board?
  • Does a failed flash or a timeout come back as an error, never as an empty result?
  • Has someone fed in a log line that contains instructions, to check the agent treats it as data?

Questions about AI agents and hardware debugging

Do I need MCP to let an AI agent run hardware tests?

No. MCP is one way to expose tools, and the specification says the protocol does not mandate any specific user interaction model (MCP tools specification, as of November 2026). A command line tool that returns JSON can serve the same agent. MCP helps when several AI clients need the same bench tools.

Should an agent ever burn eFuses or use force flags?

Keep those out of the agent's reach. Espressif says eFuses are one-time-programmable and that it is possible to permanently damage or brick a chip with espefuse (espefuse, as of November 2026). The esptool force option overrides checks that exist to prevent bricking (esptool basic commands, as of November 2026). A person should run these steps by hand.

How can Duobay help with debugging and test tooling for a device?

Duobay develops custom devices with a Shenzhen engineering team that covers electronics, firmware, enclosure, app and test, and builds samples and small batches. Duobay is also developing an AI hardware debug box for this kind of bench work; it is in development, and details may change. Firmware source and the SBOM are delivered to you, and source files are assigned to you at every paid gate. Initial calls are free, and we do not publish prices. Tell us about your device.

Sources. All pages accessed November 15, 2026. Tool options and specification revisions change, so check the current version before you build.

  • Model Context Protocol, What is the Model Context Protocol? (link)
  • Model Context Protocol, Architecture overview (link)
  • Model Context Protocol, Specification revision 2026-07-28, Tools (link)
  • Model Context Protocol, Specification revision 2026-07-28, Schema reference (link)
  • Model Context Protocol, Security Best Practices (link)
  • IVI Foundation, The SCPI Standard (link)
  • PyVISA, Communicating with your instrument (link)
  • Magna-Power Electronics, MagnaDC SCPI SOURce subsystem (link)
  • pySerial, Short introduction (link)
  • pySerial, Tools (link)
  • OpenOCD User's Guide, Flash Programming (link)
  • pyOCD, Command reference (link)
  • Espressif, esptool basic commands for ESP32 (link)
  • Espressif, espefuse for ESP32 (link)

Planning a device like this? Tell us what it needs to do. A Duobay engineer replies within 1 business day. Send a project brief →

Related reading

More engineering guides

Have a dev kit and a deadline?

Tell us what the device must do. An engineer replies within 1 business day with questions, not a sales deck.

Talk to an engineer