Skip to content

Use Guided Prompts

mcgpib ships with five MCP prompts — structured instruction templates that guide the LLM through common GPIB workflows. Prompts are not tools. They do not execute commands directly. Instead, they provide the LLM with a step-by-step plan that references the appropriate tools, so the LLM knows what to call and in what order.

Think of prompts as domain expertise encoded into reusable scripts. They capture the knowledge of “what to do first” and “what to check when something goes wrong” so that the LLM does not have to figure it out from scratch each time.

PromptParametersPurpose
initialize_benchbridge_nameConnect, scan, and summarize all instruments on a bridge
troubleshoot_instrumentbridge_name, addressSystematic diagnosis of a non-responsive instrument
measurement_sequencebridge_name, address, measurement_typeConfigure and capture a specific type of measurement
bus_health_check(none)Full infrastructure audit across all bridges
scpi_command_helpinstrument_modelLook up SCPI commands for a specific instrument model

Use this when setting up a test bench for the first time or after power cycling instruments.

> Use the initialize_bench prompt for bench-a

The prompt instructs the LLM to:

  1. Call connect_bridge("bench-a") to open the serial or TCP connection
  2. Call bus_scan("bench-a") to discover all listeners and identify them
  3. Summarize the bench: firmware version, number of instruments, their addresses and identities
  4. Flag any addresses that responded to findlstn but failed *IDN?

If the connection fails, the prompt includes troubleshooting guidance for both serial and TCP transports. If no instruments are found, it suggests checking cables, power, and trying interface_clear.

This prompt is a good starting point for any session. It gets the entire bench into a known state before you start working.

Use this when a specific instrument is not responding, returning errors, or behaving unexpectedly.

> Use the troubleshoot_instrument prompt for address 5 on bench-a

The prompt walks through six escalating steps:

  1. Bus connectivity — Scan to check if the address is present
  2. Identity — Send *IDN? to verify the instrument can communicate
  3. Status byte — Serial poll to check for SRQ, MAV, or error bits
  4. Error clearing — Send *CLS, then read SYST:ERR? until the queue is empty
  5. Reset — Send *RST and re-identify
  6. Bus recovery — Assert interface_clear and bus_clear as last resort

The LLM exits the sequence at the first step that resolves the problem. For a simple error queue overflow, it stops at step 4. For a completely hung bus, it goes through all six.

Use this when you want to take a specific type of measurement and need the LLM to handle instrument configuration, triggering, and validation.

> Use the measurement_sequence prompt for dc_voltage on address 1, bench-a

The prompt guides the LLM through:

  1. Identify the instrument — Call *IDN? to determine the model and adapt commands accordingly
  2. Configure — Send the appropriate CONF:* command for the measurement type (DC voltage, AC voltage, frequency, resistance, current)
  3. Trigger and read — Choose between READ? for simple measurements or INIT / FETCH? for triggered acquisition
  4. Validate — Check *STB? to verify the reading completed without error

Supported measurement_type values include dc_voltage, ac_voltage, frequency, resistance, 4wire_resistance, dc_current, and ac_current. The prompt provides the corresponding SCPI subsystem commands for each.

Use this for a periodic infrastructure audit, or when you are not sure which bridges are connected and what instruments are available.

> Run a bus health check

The prompt has no parameters — it operates across all configured bridges:

  1. List bridges — Show which are connected and which are disconnected
  2. For each connected bridge — Scan the bus, check SRQ, serial poll all instruments
  3. For each disconnected bridge — Attempt to connect and log the result
  4. Generate a report — Total bridges, total instruments, any SRQ assertions, any error statuses, and recommendations

This is useful at the start of a workday to verify that everything is online, or after a power event to assess what survived.

Use this when you need to know the correct commands for a specific instrument model.

> Use the scpi_command_help prompt for HP3478A

The prompt asks the LLM to provide:

  1. Measurement commandsCONF:*, SENS:*, TRIG:*, READ?, FETCH?, MEAS:*
  2. Status and error handling — Status byte bit assignments, SYST:ERR?, *ESE, *ESR?
  3. Important notes — Whether the instrument is IEEE 488.2 compliant, non-standard behavior, typical timeout requirements, power-on initialization needs

MCP prompts are part of the Model Context Protocol specification. When an MCP client (like Claude Code) supports prompts, it can:

  • List available prompts with list_prompts
  • Retrieve a prompt’s content with get_prompt, passing the required parameters
  • Inject the resulting text into the conversation as context for the LLM

The LLM then follows the instructions in the prompt text, calling the appropriate mcgpib tools to carry out each step. The prompt itself does not execute anything — it provides a plan that the LLM executes.

Not all MCP clients support prompts yet. If yours does not, you can achieve the same result by describing the workflow to the LLM directly. The prompt text is documented in the mcgpib source code in prompts.py if you want to use it as a reference for manual instructions.