Safe use of AI-controlled measurements
With the MCP server (SweepMe! Pro), an AI assistant can load sequences, start and stop measurements and call functions of SweepMe!. The assistant then acts on real instruments and samples. This page collects recommendations for using AI assistants safely with SweepMe! 1.6.1.7. How to connect an assistant is described in AI applications, and all tools are listed in the MCP tool reference.
Responsibility stays with you
You are responsible for a measurement that an assistant starts, in the same way as for a measurement that you start yourself. The safety rules of your lab and your organization apply unchanged.
The language model does not know your instruments, your samples or your setup. It can misunderstand a request, choose a wrong file, or report results incorrectly. Treat what it proposes as a suggestion and check the result.
Many AI applications can ask for your approval before a tool is called. Keep this approval switched on, at least for tools that change something, e.g. load_sequence, start_run, set_driver_version, set_module_version, call_command and close_sweepme. Tell the assistant what it must not do, e.g. "Do not start a measurement without asking me."
What an assistant can change
In SweepMe! 1.6.1.7, the MCP server can:
- load a sequence, start, pause, resume and stop a run, and skip the current branch,
- set the folder and file name of the data and save the data,
- activate other versions of drivers and modules,
- call the commands that SweepMe!, modules, drivers and CustomFunction scripts of the loaded sequence register (
list_commands,call_command). Such functions can communicate with instruments directly, outside of a run, - close SweepMe!.
The MCP server has no tools to edit the loaded sequence, e.g. to change set values or limits. An assistant that has access to your files can, however, write or change sequence files (.seq) and load them, see Creating sequences with AI. Review such files like any other new sequence.
Keep the limits in the sequence and in the instruments
Define the limits of your instruments and samples in the sequence, so that they apply no matter who starts the run:
- SMU: set the field Compliance in A or V: for every SMU. With skip if in compliance, further points beyond the compliance are skipped.
- Temperature: limit the heater or cooler output with Output, max. in %: and Output, min. in %:, if the driver supports it. Zero power afterwards: sets the device to zero power after the temperature variation.
- PID: limit the output with Output, min.: and Output, max.:, and how fast it may change with Output change rate limit in */s:.
- Condition: stop or pause the run automatically with the action stop or pause if a measured value exceeds a limit, e.g. a temperature or a current.
In addition, use the limits that the instruments offer themselves, e.g. an over-voltage or over-current protection or a temperature limit of a controller. They work independently of SweepMe! and of the assistant.
Prepare sequences with safe sweep ranges and let the assistant choose between them, instead of letting it write new set values for critical setups.
Review a sequence before an assistant runs it
- Load the sequence in SweepMe! and check the structure of the Sequencer, the selected drivers and ports, and all fields of each module, especially set values, ranges and limits.
- Ask the assistant to tell you which file it loads and what the run will do, and to wait for your confirmation before it calls
start_run. - If several SweepMe! instances are open, let the assistant check with
get_instance_infowhich instance and which sequence it controls. load_sequencereplaces the loaded sequence without asking about unsaved changes. Save your own changes first.
Test with simulation drivers first
Test a new workflow first with Simulation drivers: let the assistant load the sequence, run it, save the data and evaluate it, exactly as planned for the real measurement. Use the noise-free option of a simulation driver if you need reproducible values, e.g. to test a Condition.
Then switch to the real instruments and start with uncritical settings, e.g. a low compliance and a test sample.
Stopping a measurement
You can stop a run at any time, also while an assistant waits for it to finish:
| Way | How |
|---|---|
| Button Stop | In the toolbar of the main window, or in the widget Run Controls of the Dashboard |
| Keyboard | ⇧ Shift+Alt+S while a SweepMe! window is active, see Keyboard shortcuts |
| Assistant | The MCP tool stop_run. It returns immediately, the assistant can check with get_status that the run has ended.
|
| Sequence | The Condition module with the action stop |
| Other interfaces | The command stop, see Interfaces
|
A stop ends the run as soon as possible. A driver function that is already running, e.g. a long measurement of an instrument, is finished first, and the last point may be incomplete. Afterwards, SweepMe! still calls the functions poweroff, unconfigure, deinitialize and disconnect of the drivers (see Sequencer procedure). What happens with the instrument, e.g. whether an output is switched off, depends on the driver. The data acquired so far can still be saved.
Pause (⇧ Shift+Alt+P, MCP tool pause_run) is not a safety stop. The current point is finished first, and the instruments stay in their current state, e.g. an output stays on.
Emergency stop
Stopping via software requires a working computer, a responsive SweepMe! and a working connection to the instruments. The emergency stop of your setup must therefore be independent of SweepMe! and of the assistant, e.g. an emergency stop button, interlocks, hardware limits and fuses. Make sure that you and everyone in the lab know how to switch the setup off safely before you let an assistant run measurements, especially if a run continues without supervision.
Keep the MCP server on localhost
The MCP server has no authentication. Everyone who can reach its port can control your instruments.
- Keep the default host
localhost, so that only applications on the same computer can connect. - Select a network address only in a trusted network, and never make the port reachable from the internet. Use a VPN for remote access.
- Stop the MCP server in Tools → Interfaces when you do not need it, and use the automatic start only on computers where you want it.
- Requests from web pages of other websites are rejected. See Authentication and security.
Content that an assistant reads, e.g. web pages, e-mails or documents from others, can contain instructions that try to make the assistant do something else ("prompt injection"). Be careful if the same assistant has access to SweepMe! and to such content, and keep the approval of tool calls switched on.
Close SweepMe! only on request
The tool close_sweepme tells the assistant to use it only when you explicitly ask for it. It only works while no measurement is running. SweepMe! then closes without asking about unsaved changes of the sequence. The last state is kept as Last Session, see Automatically saved sequences.
Before you ask an assistant to close SweepMe!, save the measurement data, e.g. with save_data, and read the debug log if you need it, because the file debug.log is overwritten at the next start.
The language model receives everything that the tools return, e.g.:
- measured values and parameter names,
- file paths of sequences and data folders, which can contain user names, project names or sample names,
- names and versions of drivers and modules,
- lines of the debug log, e.g. error messages, ports and file paths,
- information about the SweepMe! instance, e.g. the path of the program and the loaded sequence.
If the assistant has access to your files, it also receives the content of the files it reads, e.g. sequences and data files, and of course everything you type. If the language model runs in the cloud, this data leaves your computer. Follow the rules of your organization, and consider a local language model, see Options for restricted IT environments.
Keeping track of what the assistant did
- Chat history: The AI application shows which tools the assistant called, with which arguments, and what they returned. Keep or export the conversation if you need a record.
- Debug log: SweepMe! writes its messages, e.g. the start of a run, errors and saved files, to the Debug widget (F2) and to the file debug.log in the public SweepMe! folder, see Debug log. The tool calls themselves are not written to the debug log. The assistant can read the log with
get_debug_log; withsince_last_run= true, it gets all lines since the last start of a run. The file is overwritten at each start of SweepMe!. - Sequence copies with the data: Whenever data is saved, SweepMe! saves a copy of the sequence that was used for the run, <file name>_setting.set and <file name>_setting.seq, together with the data files, see Saving data. Ask the assistant to save the data after each run, because data that has not been saved is lost when the next run starts.
get_statusshows whether the data of the last run has been saved. - Last Run: The sequence of the last run is also saved automatically as Last Run, see Automatically saved sequences.
- Change Tracking (SweepMe! Pro): takes a snapshot of the public SweepMe! folder whenever a measurement is started, including sequence files, custom drivers and CustomFunction scripts. You can see later what an assistant changed and restore an earlier state.