Skip to main content
Glama

agentic-lcms-hplc-nmr

Agentic control of LC-MS, HPLC and NMR through the vendor software, shown in simulation.

A planning agent should be able to say "measure these samples with this approved method" and get back a result it can trust, without touching pumps, gradients or pulse programs. This repository is that layer for 3 analytical instruments, with simulators standing in for the instruments and their software. Nothing here has run against a real instrument or real vendor software; the vendor call names and XML in the adapters are placeholders.

One round on a timeline

The approach

  1. The vendor software stays in charge. OpenLab CDS, SCIEX OS and TopSpin keep control of acquisition, interlocks and raw data. The agent works through them, never around them.

  2. Use the most supported interface the installed system offers. In order: the vendor's API; the vendor's documented queue or file interface for a LIMS; a lab standard if the instrument ships one (SiLA 2, OPC UA LADS); only then the operator screen, through browser or desktop UI automation.

  3. Give the agent a few tools, not the instrument. 5 MCP tools: list_instruments, request_measurement, get_measurement, cancel_measurement, read_ledger. The agent names an approved method version; it never sends instrument parameters.

  4. Make every request idempotent and findable. The agent's request_id goes into a field the vendor software stores (batch name, command file name, experiment title). Asking twice returns the same request. After a lost reply, the gateway searches the vendor's own queue and history for it.

  5. Never retry blind. A lost reply puts the request in unknown and holds the instrument. Found once: monitoring resumes. Not found within the grace period, or found twice: a person decides (adopt, resubmit or abandon), and the decision is recorded under their name. The agent has no tool for this.

  6. Record every call that changes an instrument, before the call is made, in a hash-chained ledger.

  7. A completed run and a usable result are 2 decisions. Each approved method version carries its acceptance criteria. Only results that pass them feed the next design round.

Related MCP server: Open Science MCP

How each instrument is reached

HPLC purity

LC-MS plasma stability

NMR structure

Vendor software

Agilent OpenLab CDS

SCIEX OS

Bruker TopSpin 5 with SpinPilot

Interface

Sample Scheduler for OpenLab: LIMS XML commands in a watched folder

SCIEX OS Control API; Data API for .wiff2

SpinPilot Python API; TopSpin acquires

Unit of work

one XML command

one batch

one experiment per tube

Where the request_id lives

command file and sequence name

batch name

experiment title

After a lost reply, look in

commands folder, trash folder, analysis table

queue and acquisition history

experiment list

Adapter

openlab_scheduler.py

sciex_os.py

spinpilot.py

The interfaces are the vendors' documented routes. Their exact call names and XML schema are not public: the SCIEX OS APIs come through SCIEX's API program, the SpinPilot API is documented in the TopSpin help, and the Sample Scheduler schema is in its Command Guide. So each adapter talks to a small client interface defined here, and binding it to the licensed library is an install step. The simulators implement the same interfaces. On TopSpin 4 without SpinPilot, the NMR adapter can run TopSpin commands (sx, lock, atma, topshim, rga, zg, efp, apk) through TopSpin's Python 3 interface instead.

The operator screen, as a last resort (ui_fallback.py): fields addressed by their labels (Playwright get_by_label, or Windows UI Automation names), every field read back before anything is pressed, acceptance confirmed by finding the request_id in the instrument's own queue view. If the screen cannot confirm acceptance reliably, the adapter prepares the run and leaves Start to the operator.

One round, in simulation

4 top hits go through purity, plasma stability and NMR. 4 things go wrong on purpose.

Step

What happened

HPLC purity, 4 hits

Vial P1-A3 holds another peptide's tube: barcode mismatch, not injected, reported. TOPHIT-04 at 86.9 % is held back.

LC-MS stability

The planner first names a draft method version: refused before anything is sent. Then the reply from SCIEX OS is lost after the batch was accepted: the gateway finds the batch in the queue and keeps monitoring. Nothing runs twice.

NMR on the most stable hit

Finished, but the DSS line is 1.66 Hz against a 1.0 Hz limit, so not usable. Asked again with a full reshim: 0.76 Hz, and the designed residue's 2 methyl singlets are there.

TOPHIT-03 after the vial fix

Purity 95.4 %. Its stability batch never reaches SCIEX OS: unknown, then needs_operator after 10 minutes. A second LC-MS request is refused while the instrument is held. The operator checks SCIEX OS and resubmits.

Decision

Build on TOPHIT-01 (plasma half-life about 300 min, extrapolated past the last sample at 240 min; designed residue confirmed by NMR); NMR for TOPHIT-03 next.

Plasma stability

NMR

The full run page, with the HPLC chromatograms, every acceptance check, the ledger and all 34 tool calls, is live here (source: docs/demo/index.html).

Run it

uv sync
uv run pytest
uv run lab-demo --out runs/demo
uv run python -m lab_gateway.report runs/demo docs/demo

The tests (37, a few seconds) cover the checks before submission, both lost-reply branches, a gateway restart mid-request, the barcode rule, dead plasma and carryover failures, the shim and lock failures, the UI fallback, and the whole round over a real MCP stdio connection.

Point any MCP client at the server, for example in a Claude Desktop or Claude Code config:

{"mcpServers": {"lab-gateway": {"command": "uv",
  "args": ["run", "--directory", "/path/to/agentic-lcms-hplc-nmr", "lab-gateway-mcp"],
  "env": {"LAB_GATEWAY_RUN_DIR": "runs/agent", "LAB_GATEWAY_SCENARIO": "demo"}}}}

Operator decisions go through a separate command:

uv run lab-operator pending --run-dir runs/demo
uv run lab-operator decide --run-dir runs/demo --request-id ID --decision resubmit --operator NAME --note "what you checked"

Layout

src/lab_gateway/
  mcp_server.py          the 5 tools
  gateway.py             checks, reservation, ledger, lost replies, operator decisions
  evaluate.py            acceptance criteria per method: the QC gate
  analysis.py            integration, tailing, plate count, half-life fit, NMR processing
  ledger.py              hash-chained record of instrument-changing calls
  approved_methods.json  method versions, vendor method fingerprints, acceptance criteria
  adapters/              Sample Scheduler, SCIEX OS, SpinPilot, operator screen
  sim/                   the simulated vendor systems and what is physically in each vial
  campaign.py            the demo round, driven over MCP
tests/
docs/demo/               the run page and figures

Before a real instrument

Run the same reference samples through an expert-operated sequence and through the gateway. Compare sample identity, method version, raw data completeness, and the method's own measures: HPLC retention time repeatability, LC-MS internal standard response and carryover, NMR reference linewidth and signal-to-noise. Commission the barcode mismatch path on a system with a reader, and check the XML against the Command Guide of the installed Sample Scheduler version.

Everything here is simulated. Method names, timings and peptides are illustrative, and peptides carry numbers only.

Available Tools

5 tools
cancel_measurementB
DestructiveIdempotent

Cancel a queued or running request. Requests with an unknown outcome are an operator's call.

Inputs: reason (required), request_id (required).

get_measurementA
Read-only

State, progress and (when done) the QC verdict, findings and provenance of a request. wait_s: wait up to this many seconds for the state to change (long poll).

Inputs: request_id (required), wait_s.

list_instrumentsA
Read-only

List the instruments, the vendor software and interface behind each, readiness, which request holds each one, and the approved method versions with their acceptance criteria.

Inputs: no named parameters.

read_ledgerB
Read-only

The record of every call that changed an instrument, with a check that the chain is intact.

Inputs: limit, request_id.

request_measurementA
Idempotent

Request a measurement under an approved method version.

sample_manifest: [{"sample_id", "position", "kind": sample|control, "barcode", "attrs": {...}}]. Standards and blanks come from the method's own template; list only your samples. request_id: your idempotency key (3-64 chars). The same id with the same content returns the existing request; nothing is sent twice. dry_run=true runs every check and sends nothing.

Inputs: instrument (required), request_id (required), method_version (required), sample_manifest (required), +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a distinct role in the lab workflow: discovery, request creation, status retrieval, cancellation, and audit review. The boundaries between request_measurement/get_measurement and list_instruments/read_ledger are clear from their descriptions.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern: list_instruments, request_measurement, get_measurement, cancel_measurement, read_ledger. There are no mixed conventions or vague names.

    Tool Count5/5

    Five tools is well within the appropriate range and each tool maps to a necessary operation in the lab measurement lifecycle. The set is focused rather than padded.

    Completeness4/5

    The core lifecycle is covered: list instruments/methods, request a measurement, poll status, cancel, and audit the ledger. A way to list or discover existing measurement requests would close a minor gap, but most workflows can proceed using the request_id idempotency key.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLM agents to connect to and control OPC UA LADS laboratory instruments, with approval-gated execution of state-changing operations and retrievable SHA-256 witnessed provenance records.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables MCP clients to control the local Open Science research application, including creating projects, starting or continuing research sessions, inspecting progress and plans, canceling runs, and reading generated artifacts.
      12
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to discover, configure, measure, and operate simulated lab instruments (microscope, oscilloscope, robot arm, liquid handler and reader) through a single tool layer. Requests are validated before dispatch, confirmed against the instrument's own readback, and qualified with units, age, calibration, uncertainty, and quality flags, so mismatches, stale data, and partial effects are reported instead of silently retried.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables chemistry agents to run deterministic structure, HRMS, fluorescence, and NMR evidence audits with schema-validated, content-addressed snapshots and typed tools/resources over stdio or Streamable HTTP.
      Apache 2.0