labmcp-ms-worklist 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ build/
8
+ *.egg-info/
9
+ .DS_Store
10
+ *.jsonl
11
+ !**/fixtures/*.jsonl
12
+ .idea/
13
+ .vscode/
14
+
15
+ CLAUDE.md
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.5
2
+ Name: labmcp-ms-worklist
3
+ Version: 0.1.0
4
+ Summary: MCP server that builds, validates and exports LC-MS worklist import files for MassLynx, SCIEX OS, MassHunter and Xcalibur.
5
+ Project-URL: Homepage, https://github.com/K-Dense-AI/lab-instrument-mcps/tree/main/servers/chemistry/ms-worklist
6
+ Author: K-Dense and LabMCP contributors
7
+ License-Expression: Apache-2.0
8
+ Keywords: lab-instrument,lc-ms,mass-spectrometry,masshunter,masslynx,mcp,sciex-os,sequence,worklist,xcalibur
9
+ Requires-Python: >=3.10
10
+ Requires-Dist: labmcp<0.2,>=0.1
11
+ Description-Content-Type: text/markdown
12
+
13
+ # LC-MS Worklist Builder (MassLynx, SCIEX OS, MassHunter, Xcalibur): MCP Server
14
+
15
+ <!-- mcp-name: io.github.K-Dense-AI/labmcp-ms-worklist -->
16
+
17
+ Let an AI agent build LC-MS sample queues (worklists, sequences, batches) and export them as **import files** for Waters MassLynx, SCIEX OS, Agilent MassHunter Acquisition and Thermo Xcalibur. The agent can lay out samples on a tray, insert blanks and QCs, randomise the run order with a recorded seed, check the list for mistakes, convert an existing file from one vendor to another, and write the file for a person to import. It uses **only documented import formats**. It **never starts an acquisition** and doesn't talk to the mass spectrometer.
18
+
19
+ | | |
20
+ |---|---|
21
+ | **Package** | `labmcp-ms-worklist` |
22
+ | **Software** | Waters MassLynx 4.x, SCIEX OS, Agilent MassHunter Acquisition (LC/TQ, LC/Q-TOF), Thermo Xcalibur 2.2+ |
23
+ | **Interfaces** | File (writes CSV/TXT import files into one output folder) |
24
+ | **Protocol** | Vendor sample-list import formats (see [Formats](#formats) for sources) |
25
+ | **Status** | ๐Ÿงช **simulated**: tested with golden files and round-trip tests, not yet imported into the vendor software by us. [Report a test](https://github.com/K-Dense-AI/lab-instrument-mcps/issues/new?template=hardware-verification.yml) |
26
+
27
+ ## Try it without an instrument
28
+
29
+ ```bash
30
+ uvx labmcp-ms-worklist --simulate --check
31
+ ```
32
+
33
+ `--simulate` uses a temporary output folder that is deleted when the server stops. Everything else is the same code.
34
+
35
+ ## Set up
36
+
37
+ The "instrument address" is the **output folder** where worklist files are written (default `./worklists`, created if missing):
38
+
39
+ ```bash
40
+ uvx labmcp-ms-worklist --address "D:\Worklists" --check # Windows acquisition PC or a shared drive
41
+ uvx labmcp-ms-worklist --address ~/lcms/worklists --check # macOS / Linux, then copy the files over
42
+ ```
43
+
44
+ - The server only reads and writes inside this folder. It refuses `..`, absolute paths elsewhere and symlinks that point outside it. It never overwrites an existing file unless the agent passes `overwrite=true`.
45
+ - To edit or convert an existing file, or to use a vendor template, **copy it into the folder first**.
46
+ - Point `--address` at a folder the acquisition software watches only if the vendor documents that behaviour for your setup. Otherwise import the file by hand (instructions below).
47
+
48
+ ## Add to your MCP client
49
+
50
+ **Claude Code**
51
+ ```bash
52
+ claude mcp add ms-worklist -- uvx labmcp-ms-worklist --address ~/lcms/worklists
53
+ ```
54
+
55
+ **Claude Desktop / Cursor / Windsurf**
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "ms-worklist": { "command": "uvx", "args": ["labmcp-ms-worklist", "--address", "/path/to/worklists"] }
60
+ }
61
+ }
62
+ ```
63
+
64
+ `--read-only` keeps only the tools that inspect things (`list_formats`, `validate_worklist`, `import_worklist`, `get_worklist`, `list_worklists`).
65
+
66
+ ## Tools
67
+
68
+ <!-- TOOLS:START -->
69
+ | Tool | Kind | Description |
70
+ |---|---|---|
71
+ | `add_samples` | ๐ŸŽ› control | Append samples to a draft worklist (the worklist's defaults and automatic positions apply; any blank/QC/randomisation plan is re-applied to the longer list with the same seed). |
72
+ | `create_worklist` | ๐ŸŽ› control | Create an in-memory draft worklist from a sample list plus defaults (methods, injection volume, tray positions, data-file naming pattern). Nothing is written to disk until export_worklist. Injection volumes above the max_injection_volume_ul limit are refused. |
73
+ | `export_worklist` | ๐ŸŽ› control | Validate the draft and write the vendor import file into the output folder. Returns the path, a preview of the first lines, warnings and import instructions. Refuses if validation finds errors or the file exists (unless overwrite=true). This does not start an acquisition: a person imports the file into the acquisition software. |
74
+ | `get_command_log` | ๐Ÿ‘ read | Return the most recent raw commands sent to / replies received from the instrument (newest last). Useful for debugging and for recording what was done. |
75
+ | `get_connection_info` | ๐Ÿ‘ read | Report which instrument is connected (identity, address, simulated or real), whether the server is read-only, and the active safety limits. Call this first. |
76
+ | `get_worklist` | ๐Ÿ‘ read | Show a draft worklist in run order, with its defaults, blank/QC plan, randomisation seed and the history of operations applied to it. |
77
+ | `import_worklist` | ๐Ÿ‘ read | Parse an existing MassLynx, SCIEX OS, MassHunter or Xcalibur import file from the output folder into a draft, so it can be validated, edited or exported in another vendor's format. Columns without a neutral equivalent are kept verbatim. Only reads; nothing is written. |
78
+ | `insert_qc_blanks` | ๐ŸŽ› control | Insert blanks and QC injections and optionally randomise the run order (with a recorded seed). Replaces any previous plan, so calling it again does not duplicate blanks. The plan is re-applied whenever samples are added; data-file names follow the new run order. |
79
+ | `list_formats` | ๐Ÿ‘ read | List the supported import formats (Waters MassLynx, SCIEX OS, Agilent MassHunter, Thermo Xcalibur): columns, required fields, sample-type names, file extensions, how to import, what is verified against vendor documents and what is assumed, and the source URLs. Also lists the position patterns and the formats that were researched but not implemented. |
80
+ | `list_worklists` | ๐Ÿ‘ read | List the draft worklists in memory and the files in the output folder. |
81
+ | `reconnect` | ๐Ÿ›‘ safety | Close and re-open the connection to the instrument (e.g. after it was power cycled or a cable was re-plugged). |
82
+ | `validate_worklist` | ๐Ÿ‘ read | Check a draft against the target format: required fields, duplicate data-file names, characters Windows does not allow in file names, tray/vial position format and plate bounds, injection volume (> 0 and <= the max_injection_volume_ul limit), and method file extensions. Errors block export; warnings don't. |
83
+ <!-- TOOLS:END -->
84
+
85
+ `get_connection_info`, `get_command_log` and `reconnect` are built into every LabMCP server. There are **no HAZARD tools**: nothing here moves, heats, injects or acquires. The server only writes files. The CONTROL tools change in-memory drafts or write a file, and `--read-only` hides them.
86
+
87
+ Typical flow: `create_worklist` โ†’ `add_samples` (optional) โ†’ `insert_qc_blanks` โ†’ `validate_worklist` โ†’ `export_worklist`, then import the file in the vendor software.
88
+
89
+ ## Formats
90
+
91
+ The table below separates what the vendor documents say (**verified**) from what the server assumes. `list_formats` returns the same information to the agent. To be sure of the header for your software version, export an empty batch, sequence or worklist from your own system, put it in the output folder, and pass it to `export_worklist` as `template_path`. The server then writes that header, and that delimiter, exactly.
92
+
93
+ ### Waters MassLynx: sample list worksheet (`waters_masslynx`)
94
+
95
+ - **Import:** Sample list > File > Import Worksheet, File of Type "Comma Delimited (*.CSV, *.TXT)".
96
+ - **Verified:**
97
+ - Row 1 holds the MassLynx FIELD IDs, which are case sensitive. Columns can be in any order, and an `Index` column is added. Source: [WKB63781](https://support.waters.com/KB_Inf/MassLynx/WKB63781_How_do_you_create_a_comma_delimited_text_file_that_can_be_imported_into_MassLynx_as_a_sample_list).
98
+ - The required columns are `FILE_NAME`, `INLET_FILE`, `MS_FILE`, `SAMPLE_LOCATION` and `INJ_VOL`. Source: [MassLynx 4.2 Getting Started Guide 715009602, Table 5-1](https://help.waters.com/content/dam/waters/en/support/usermanuals/2025/715009602/715009602v00.pdf). The "Bottle" column's FIELD ID is `SAMPLE_LOCATION`, not `BOTTLE`.
99
+ - The example files attached to WKB63781 use CRLF line endings and unquoted fields, `TYPE` values `Blank`/`Standard`/`QC`/`Analyte`, and method names without an extension.
100
+ - **Mapping:** `FILE_NAME` = data file, `FILE_TEXT` = sample name, `MS_FILE`, `MS_TUNE_FILE`, `INLET_FILE`, `SAMPLE_LOCATION`, `TYPE`, `ID`, `INJ_VOL`, `Index`. You can add any other FIELD ID (for example `CONC_A` or `QUAN_REF`) per sample through `extra`.
101
+ - **Assumed:**
102
+ - `solvent` and `double_blank` are written as `Blank`.
103
+ - Extension checks: `.exp` for MS_FILE and `.ipr` for the tune file, applied only when an extension is given.
104
+ - Files are UTF-8 without a BOM. Non-ASCII text is flagged.
105
+ - The `waters_plate_well` position pattern (`1:A,1`) is a common convention. Its comma is CSV-quoted.
106
+
107
+ ### SCIEX OS: batch import (`sciex_os`)
108
+
109
+ - **Import:** Batch workspace > Open > Import from file, then Save As.
110
+ - **Verified:**
111
+ - Batches import from `.txt` or `.csv`, and the column layout must come from a batch exported from SCIEX OS. Source: [SCIEX KB](https://sciex.com/support/knowledge-base-articles/how-to-import-txt-file-to-make-sciex-os-batch_en_us).
112
+ - Column names Sample Name (< 252 characters), MS Method, Sample Type, Data File and Processing Method. Source: [SCIEX OS Feature Guide RUO-IDV-05-15796-C, Table 4-1](https://sciex.com/content/dam/SCIEX/pdf/customer-docs/user-guide/sciex-os-echo-msplus-7600-feature-guide-en.pdf).
113
+ - Rack Type, Rack Position, Plate Type, Plate Position and Vial Position columns. Source: [SCIEX KB](https://sciex.com/resource-hub/knowledge-base-articles/lcms/troubleshooting/unable-to-add-plates-or-samples-to-a-batch-en-us).
114
+ - Sample types Unknown, Blank, Standard, QualityControl, Solvent and Double blank.
115
+ - Several samples can share one data file.
116
+ - **Assumed:**
117
+ - **SCIEX doesn't publish the exact header text of an exported batch.** The default header (`Sample Name,Sample ID,Sample Type,MS Method,LC Method,Rack Type,Rack Position,Plate Type,Plate Position,Vial Position,Injection Volume,Data File,Processing Method,Comment`) is a best guess. Use `template_path` with your own export. `validate_worklist` and `export_worklist` warn when no template was used.
118
+ - Extensions `.msm`, `.lcm` and `.qmethod` produce warnings only.
119
+ - Rack and plate columns are set with `vendor_columns` or per sample with `extra`.
120
+
121
+ ### Agilent MassHunter Acquisition: worklist CSV import (`agilent_masshunter`)
122
+
123
+ - **Import:** Worklist, right-click > "Add/Append Samples from... (csv, xlsx)". Older versions call it "Import Worklist...". You don't need a map file because the headers match the worklist column names.
124
+ - **Verified:**
125
+ - The header `Sample Name,Barcode,Rack Code,Sample Position,Method,Data File,Sample Type,Level Name,Inj Vol (ยตL),Comment`, positions like `P1-A1`, and the types `Calibration` and `Sample` come from the example file shipped in `D:\MassHunter\Worklist_Import`, as quoted on the [Agilent Community](https://community.agilent.com/technical/mass-spectrometry-software/f/mass-spectrometry-software-user-forum/12581/how-to-format-a-csv-file-for-import-as-a-new-worklist-for-masshunter).
126
+ - Save as UTF-8 when the file contains ยต. Source: [Agilent Community](https://community.agilent.com/technical/mass-spectrometry-software/f/mass-spectrometry-software-user-forum/9000/map-file-generator-in-masshunter-workstation-version-12-1).
127
+ - `Inj Vol` = `-1` means "As method". Source: [Agilent Known Problem Report](https://www.agilent.com/cs/library/support/Patches/SSBs/MHAcqLCTQ_Classic.html).
128
+ - Sample Position, Method and Data File must be filled in. Source: Study Manager Quick Start G3335-90140.
129
+ - **Assumed:**
130
+ - The file has a UTF-8 BOM and CRLF line endings.
131
+ - Data files get a `.d` suffix.
132
+ - Methods should end in `.m`.
133
+ - The sample types Blank, QC and DoubleBlank don't appear in the example; `solvent` is written as Blank.
134
+
135
+ ### Thermo Xcalibur: sequence CSV import (`thermo_xcalibur`)
136
+
137
+ - **Import:** Sequence Setup > File > Import Sequence.
138
+ - **Verified** in the [Xcalibur 2.2 Acquisition and Processing User Guide XCALI-97209 Rev. D](https://tools.thermofisher.com/content/sfs/manuals/Man-XCALI-97209-Xcalibur-22-Acquisition-ManXCALI97209-D-EN.pdf), Appendix A:
139
+ - Only `.csv` files are accepted.
140
+ - The first cell must be `Bracket Type=n` (1 Overlapped, 2 None, 3 Non-Overlapped, 4 Open).
141
+ - The separator must match the Windows list separator. Use `delimiter=";"` where that is `;`.
142
+ - The sequence column names and the sample types Unknown, Blank, QC, Std Bracket, Std Clear and Std Update.
143
+ - **Corroborated, not published by Thermo:** the exact row-2 header strings (`Sample Type,File Name,Sample ID,Path,Instrument Method,Process Method,Calibration File,Position,Inj Vol,Level,Sample Wt,Sample Vol,ISTD Amt,Dil Factor,L1 Study,L2 Client,L3 Laboratory,L4 Company,L5 Phone,Comment,Sample Name`). Open-source generators that target Xcalibur import use them: [protti](https://github.com/jpquast/protti/blob/master/R/create_queue.R), fgcz/qg and lcms-sequencer. Native exports start with a bare `Bracket Type=4` line ([Rapid-QC-MS #83](https://github.com/czbiohub-sf/Rapid-QC-MS/issues/83)). Export one sequence from your Xcalibur as a template if you want certainty.
144
+ - **Assumed:**
145
+ - Sample Wt 0, Sample Vol 0, ISTD Amt 0 and Dil Factor 1 are written as defaults.
146
+ - `standard` is written as `Std Bracket`, which suits bracket type 4.
147
+ - Extension checks: `.meth` for the instrument method and `.pmd` for the processing method.
148
+
149
+ ### Not implemented
150
+
151
+ - **MassHunter Walkup Custom Sample Import** ([G2725-90026](https://www.agilent.com/cs/library/usermanuals/public/G2725-90026_Walkup_Programmer.pdf)): the guide couldn't be retrieved (HTTP 403), so its format couldn't be verified.
152
+ - **Native worklist and sequence files** (MassHunter `.wkl` XML, Xcalibur `.sld`, MassLynx `.spl`): not implemented. We found no public specification for them, so the server uses the CSV import paths above.
153
+
154
+ ## Validation
155
+
156
+ `validate_worklist`, which `export_worklist` also runs, reports **errors**, which block export, and **warnings**:
157
+
158
+ - Required fields for the format are missing.
159
+ - Duplicate data-file names, compared case-insensitively. For SCIEX OS a shared data file is allowed, but a sample name repeated within one data file is an error.
160
+ - Characters Windows doesn't allow in file names (`< > : " / \ | ? *`, control characters), a trailing dot or space, and reserved names (CON, NUL, COM1โ€ฆ).
161
+ - The position doesn't match the chosen `position_pattern` (`vial_number`, `well`, `agilent_plate_well`, `waters_plate_well`, `tray_well`) or falls outside the `plate_size` (24/48/54/96/384) or `max_vial`.
162
+ - The injection volume is โ‰ค 0, not a number, or above the `max_injection_volume_ul` limit. This includes injection-volume columns set through `extra` or `vendor_columns`.
163
+ - A text field or `extra` value contains a line break or another control character, which would break the import file.
164
+ - The method file has the wrong extension, for example an Analyst `.dam` in a SCIEX OS batch, or a MassHunter `.m` in an Xcalibur sequence.
165
+ - Fields the target format has no column for, and non-ASCII text in formats without a BOM.
166
+
167
+ ## Safety limits
168
+
169
+ | Limit | Default | Meaning |
170
+ |---|---|---|
171
+ | `max_injection_volume_ul` | 100 ยตL | Largest injection volume allowed in a worklist. Enforced when samples are added and again at export, including volume columns set verbatim through `extra` or `vendor_columns`. `import_worklist` warns about larger volumes, and such a draft can't be exported. |
172
+
173
+ Override at launch, for example `--limit max_injection_volume_ul=20` for a 20 ยตL loop.
174
+
175
+ ## Example prompts
176
+
177
+ - "Make an Xcalibur sequence for the 40 plasma samples in this list: wells A1 onwards on the R tray, 2 ยตL, method C:\Xcalibur\methods\DIA_60min. Add a blank after every 10 samples from R:H12 and a pooled QC at the start and end from R:H11. Randomise the samples and tell me the seed."
178
+ - "Import `old_batch.csv` from the worklist folder and convert it to a MassHunter worklist with method D:\MassHunter\methods\Panel.m."
179
+ - "I put `blank_batch.txt` (exported from our SCIEX OS) in the folder. Use it as the template for this batch."
180
+ - "Check this MassLynx sample list for duplicate file names and bad vial positions before I import it."
181
+
182
+ ## Notes
183
+
184
+ - Drafts live in memory. `reconnect` (or restarting the server) discards them. In `--simulate` it also deletes the temporary folder. Export files you want to keep.
185
+ - By default, `export_worklist` also writes `<file>.provenance.json` next to the worklist (for example `Plasma.csv.provenance.json`). Like the worklist itself, it is never overwritten unless `overwrite=true`. It contains the operation history, the randomisation seed and the sample order before randomisation, so the run order can be reproduced. Pass `write_provenance=false` to skip it.
186
+ - `blank_every_n` / `qc_every_n` also add a control after the last sample when the count divides evenly, unless `blank_at_end` / `qc_at_end` already adds one there.
187
+ - When a draft is exported in another vendor's format, values kept verbatim from the original vendor for columns the new vendor maps itself (for example Xcalibur's `Std Clear` sample type) are not copied; the export notes say so.
188
+ - Randomisation shuffles only the types in `randomize_types` (by default unknown samples) among their own slots, using Python's `random.Random(seed)`. Standards, blanks and QCs stay where they are.
189
+ - Method names must match methods that exist on the acquisition PC. The server can't check that.
190
+
191
+ ## Verification
192
+
193
+ | Software | Version | Format | Verified by | Date |
194
+ |---|---|---|---|---|
195
+ | *none yet: [be the first](https://github.com/K-Dense-AI/lab-instrument-mcps/issues/new?template=hardware-verification.yml)* | | | | |
@@ -0,0 +1,183 @@
1
+ # LC-MS Worklist Builder (MassLynx, SCIEX OS, MassHunter, Xcalibur): MCP Server
2
+
3
+ <!-- mcp-name: io.github.K-Dense-AI/labmcp-ms-worklist -->
4
+
5
+ Let an AI agent build LC-MS sample queues (worklists, sequences, batches) and export them as **import files** for Waters MassLynx, SCIEX OS, Agilent MassHunter Acquisition and Thermo Xcalibur. The agent can lay out samples on a tray, insert blanks and QCs, randomise the run order with a recorded seed, check the list for mistakes, convert an existing file from one vendor to another, and write the file for a person to import. It uses **only documented import formats**. It **never starts an acquisition** and doesn't talk to the mass spectrometer.
6
+
7
+ | | |
8
+ |---|---|
9
+ | **Package** | `labmcp-ms-worklist` |
10
+ | **Software** | Waters MassLynx 4.x, SCIEX OS, Agilent MassHunter Acquisition (LC/TQ, LC/Q-TOF), Thermo Xcalibur 2.2+ |
11
+ | **Interfaces** | File (writes CSV/TXT import files into one output folder) |
12
+ | **Protocol** | Vendor sample-list import formats (see [Formats](#formats) for sources) |
13
+ | **Status** | ๐Ÿงช **simulated**: tested with golden files and round-trip tests, not yet imported into the vendor software by us. [Report a test](https://github.com/K-Dense-AI/lab-instrument-mcps/issues/new?template=hardware-verification.yml) |
14
+
15
+ ## Try it without an instrument
16
+
17
+ ```bash
18
+ uvx labmcp-ms-worklist --simulate --check
19
+ ```
20
+
21
+ `--simulate` uses a temporary output folder that is deleted when the server stops. Everything else is the same code.
22
+
23
+ ## Set up
24
+
25
+ The "instrument address" is the **output folder** where worklist files are written (default `./worklists`, created if missing):
26
+
27
+ ```bash
28
+ uvx labmcp-ms-worklist --address "D:\Worklists" --check # Windows acquisition PC or a shared drive
29
+ uvx labmcp-ms-worklist --address ~/lcms/worklists --check # macOS / Linux, then copy the files over
30
+ ```
31
+
32
+ - The server only reads and writes inside this folder. It refuses `..`, absolute paths elsewhere and symlinks that point outside it. It never overwrites an existing file unless the agent passes `overwrite=true`.
33
+ - To edit or convert an existing file, or to use a vendor template, **copy it into the folder first**.
34
+ - Point `--address` at a folder the acquisition software watches only if the vendor documents that behaviour for your setup. Otherwise import the file by hand (instructions below).
35
+
36
+ ## Add to your MCP client
37
+
38
+ **Claude Code**
39
+ ```bash
40
+ claude mcp add ms-worklist -- uvx labmcp-ms-worklist --address ~/lcms/worklists
41
+ ```
42
+
43
+ **Claude Desktop / Cursor / Windsurf**
44
+ ```json
45
+ {
46
+ "mcpServers": {
47
+ "ms-worklist": { "command": "uvx", "args": ["labmcp-ms-worklist", "--address", "/path/to/worklists"] }
48
+ }
49
+ }
50
+ ```
51
+
52
+ `--read-only` keeps only the tools that inspect things (`list_formats`, `validate_worklist`, `import_worklist`, `get_worklist`, `list_worklists`).
53
+
54
+ ## Tools
55
+
56
+ <!-- TOOLS:START -->
57
+ | Tool | Kind | Description |
58
+ |---|---|---|
59
+ | `add_samples` | ๐ŸŽ› control | Append samples to a draft worklist (the worklist's defaults and automatic positions apply; any blank/QC/randomisation plan is re-applied to the longer list with the same seed). |
60
+ | `create_worklist` | ๐ŸŽ› control | Create an in-memory draft worklist from a sample list plus defaults (methods, injection volume, tray positions, data-file naming pattern). Nothing is written to disk until export_worklist. Injection volumes above the max_injection_volume_ul limit are refused. |
61
+ | `export_worklist` | ๐ŸŽ› control | Validate the draft and write the vendor import file into the output folder. Returns the path, a preview of the first lines, warnings and import instructions. Refuses if validation finds errors or the file exists (unless overwrite=true). This does not start an acquisition: a person imports the file into the acquisition software. |
62
+ | `get_command_log` | ๐Ÿ‘ read | Return the most recent raw commands sent to / replies received from the instrument (newest last). Useful for debugging and for recording what was done. |
63
+ | `get_connection_info` | ๐Ÿ‘ read | Report which instrument is connected (identity, address, simulated or real), whether the server is read-only, and the active safety limits. Call this first. |
64
+ | `get_worklist` | ๐Ÿ‘ read | Show a draft worklist in run order, with its defaults, blank/QC plan, randomisation seed and the history of operations applied to it. |
65
+ | `import_worklist` | ๐Ÿ‘ read | Parse an existing MassLynx, SCIEX OS, MassHunter or Xcalibur import file from the output folder into a draft, so it can be validated, edited or exported in another vendor's format. Columns without a neutral equivalent are kept verbatim. Only reads; nothing is written. |
66
+ | `insert_qc_blanks` | ๐ŸŽ› control | Insert blanks and QC injections and optionally randomise the run order (with a recorded seed). Replaces any previous plan, so calling it again does not duplicate blanks. The plan is re-applied whenever samples are added; data-file names follow the new run order. |
67
+ | `list_formats` | ๐Ÿ‘ read | List the supported import formats (Waters MassLynx, SCIEX OS, Agilent MassHunter, Thermo Xcalibur): columns, required fields, sample-type names, file extensions, how to import, what is verified against vendor documents and what is assumed, and the source URLs. Also lists the position patterns and the formats that were researched but not implemented. |
68
+ | `list_worklists` | ๐Ÿ‘ read | List the draft worklists in memory and the files in the output folder. |
69
+ | `reconnect` | ๐Ÿ›‘ safety | Close and re-open the connection to the instrument (e.g. after it was power cycled or a cable was re-plugged). |
70
+ | `validate_worklist` | ๐Ÿ‘ read | Check a draft against the target format: required fields, duplicate data-file names, characters Windows does not allow in file names, tray/vial position format and plate bounds, injection volume (> 0 and <= the max_injection_volume_ul limit), and method file extensions. Errors block export; warnings don't. |
71
+ <!-- TOOLS:END -->
72
+
73
+ `get_connection_info`, `get_command_log` and `reconnect` are built into every LabMCP server. There are **no HAZARD tools**: nothing here moves, heats, injects or acquires. The server only writes files. The CONTROL tools change in-memory drafts or write a file, and `--read-only` hides them.
74
+
75
+ Typical flow: `create_worklist` โ†’ `add_samples` (optional) โ†’ `insert_qc_blanks` โ†’ `validate_worklist` โ†’ `export_worklist`, then import the file in the vendor software.
76
+
77
+ ## Formats
78
+
79
+ The table below separates what the vendor documents say (**verified**) from what the server assumes. `list_formats` returns the same information to the agent. To be sure of the header for your software version, export an empty batch, sequence or worklist from your own system, put it in the output folder, and pass it to `export_worklist` as `template_path`. The server then writes that header, and that delimiter, exactly.
80
+
81
+ ### Waters MassLynx: sample list worksheet (`waters_masslynx`)
82
+
83
+ - **Import:** Sample list > File > Import Worksheet, File of Type "Comma Delimited (*.CSV, *.TXT)".
84
+ - **Verified:**
85
+ - Row 1 holds the MassLynx FIELD IDs, which are case sensitive. Columns can be in any order, and an `Index` column is added. Source: [WKB63781](https://support.waters.com/KB_Inf/MassLynx/WKB63781_How_do_you_create_a_comma_delimited_text_file_that_can_be_imported_into_MassLynx_as_a_sample_list).
86
+ - The required columns are `FILE_NAME`, `INLET_FILE`, `MS_FILE`, `SAMPLE_LOCATION` and `INJ_VOL`. Source: [MassLynx 4.2 Getting Started Guide 715009602, Table 5-1](https://help.waters.com/content/dam/waters/en/support/usermanuals/2025/715009602/715009602v00.pdf). The "Bottle" column's FIELD ID is `SAMPLE_LOCATION`, not `BOTTLE`.
87
+ - The example files attached to WKB63781 use CRLF line endings and unquoted fields, `TYPE` values `Blank`/`Standard`/`QC`/`Analyte`, and method names without an extension.
88
+ - **Mapping:** `FILE_NAME` = data file, `FILE_TEXT` = sample name, `MS_FILE`, `MS_TUNE_FILE`, `INLET_FILE`, `SAMPLE_LOCATION`, `TYPE`, `ID`, `INJ_VOL`, `Index`. You can add any other FIELD ID (for example `CONC_A` or `QUAN_REF`) per sample through `extra`.
89
+ - **Assumed:**
90
+ - `solvent` and `double_blank` are written as `Blank`.
91
+ - Extension checks: `.exp` for MS_FILE and `.ipr` for the tune file, applied only when an extension is given.
92
+ - Files are UTF-8 without a BOM. Non-ASCII text is flagged.
93
+ - The `waters_plate_well` position pattern (`1:A,1`) is a common convention. Its comma is CSV-quoted.
94
+
95
+ ### SCIEX OS: batch import (`sciex_os`)
96
+
97
+ - **Import:** Batch workspace > Open > Import from file, then Save As.
98
+ - **Verified:**
99
+ - Batches import from `.txt` or `.csv`, and the column layout must come from a batch exported from SCIEX OS. Source: [SCIEX KB](https://sciex.com/support/knowledge-base-articles/how-to-import-txt-file-to-make-sciex-os-batch_en_us).
100
+ - Column names Sample Name (< 252 characters), MS Method, Sample Type, Data File and Processing Method. Source: [SCIEX OS Feature Guide RUO-IDV-05-15796-C, Table 4-1](https://sciex.com/content/dam/SCIEX/pdf/customer-docs/user-guide/sciex-os-echo-msplus-7600-feature-guide-en.pdf).
101
+ - Rack Type, Rack Position, Plate Type, Plate Position and Vial Position columns. Source: [SCIEX KB](https://sciex.com/resource-hub/knowledge-base-articles/lcms/troubleshooting/unable-to-add-plates-or-samples-to-a-batch-en-us).
102
+ - Sample types Unknown, Blank, Standard, QualityControl, Solvent and Double blank.
103
+ - Several samples can share one data file.
104
+ - **Assumed:**
105
+ - **SCIEX doesn't publish the exact header text of an exported batch.** The default header (`Sample Name,Sample ID,Sample Type,MS Method,LC Method,Rack Type,Rack Position,Plate Type,Plate Position,Vial Position,Injection Volume,Data File,Processing Method,Comment`) is a best guess. Use `template_path` with your own export. `validate_worklist` and `export_worklist` warn when no template was used.
106
+ - Extensions `.msm`, `.lcm` and `.qmethod` produce warnings only.
107
+ - Rack and plate columns are set with `vendor_columns` or per sample with `extra`.
108
+
109
+ ### Agilent MassHunter Acquisition: worklist CSV import (`agilent_masshunter`)
110
+
111
+ - **Import:** Worklist, right-click > "Add/Append Samples from... (csv, xlsx)". Older versions call it "Import Worklist...". You don't need a map file because the headers match the worklist column names.
112
+ - **Verified:**
113
+ - The header `Sample Name,Barcode,Rack Code,Sample Position,Method,Data File,Sample Type,Level Name,Inj Vol (ยตL),Comment`, positions like `P1-A1`, and the types `Calibration` and `Sample` come from the example file shipped in `D:\MassHunter\Worklist_Import`, as quoted on the [Agilent Community](https://community.agilent.com/technical/mass-spectrometry-software/f/mass-spectrometry-software-user-forum/12581/how-to-format-a-csv-file-for-import-as-a-new-worklist-for-masshunter).
114
+ - Save as UTF-8 when the file contains ยต. Source: [Agilent Community](https://community.agilent.com/technical/mass-spectrometry-software/f/mass-spectrometry-software-user-forum/9000/map-file-generator-in-masshunter-workstation-version-12-1).
115
+ - `Inj Vol` = `-1` means "As method". Source: [Agilent Known Problem Report](https://www.agilent.com/cs/library/support/Patches/SSBs/MHAcqLCTQ_Classic.html).
116
+ - Sample Position, Method and Data File must be filled in. Source: Study Manager Quick Start G3335-90140.
117
+ - **Assumed:**
118
+ - The file has a UTF-8 BOM and CRLF line endings.
119
+ - Data files get a `.d` suffix.
120
+ - Methods should end in `.m`.
121
+ - The sample types Blank, QC and DoubleBlank don't appear in the example; `solvent` is written as Blank.
122
+
123
+ ### Thermo Xcalibur: sequence CSV import (`thermo_xcalibur`)
124
+
125
+ - **Import:** Sequence Setup > File > Import Sequence.
126
+ - **Verified** in the [Xcalibur 2.2 Acquisition and Processing User Guide XCALI-97209 Rev. D](https://tools.thermofisher.com/content/sfs/manuals/Man-XCALI-97209-Xcalibur-22-Acquisition-ManXCALI97209-D-EN.pdf), Appendix A:
127
+ - Only `.csv` files are accepted.
128
+ - The first cell must be `Bracket Type=n` (1 Overlapped, 2 None, 3 Non-Overlapped, 4 Open).
129
+ - The separator must match the Windows list separator. Use `delimiter=";"` where that is `;`.
130
+ - The sequence column names and the sample types Unknown, Blank, QC, Std Bracket, Std Clear and Std Update.
131
+ - **Corroborated, not published by Thermo:** the exact row-2 header strings (`Sample Type,File Name,Sample ID,Path,Instrument Method,Process Method,Calibration File,Position,Inj Vol,Level,Sample Wt,Sample Vol,ISTD Amt,Dil Factor,L1 Study,L2 Client,L3 Laboratory,L4 Company,L5 Phone,Comment,Sample Name`). Open-source generators that target Xcalibur import use them: [protti](https://github.com/jpquast/protti/blob/master/R/create_queue.R), fgcz/qg and lcms-sequencer. Native exports start with a bare `Bracket Type=4` line ([Rapid-QC-MS #83](https://github.com/czbiohub-sf/Rapid-QC-MS/issues/83)). Export one sequence from your Xcalibur as a template if you want certainty.
132
+ - **Assumed:**
133
+ - Sample Wt 0, Sample Vol 0, ISTD Amt 0 and Dil Factor 1 are written as defaults.
134
+ - `standard` is written as `Std Bracket`, which suits bracket type 4.
135
+ - Extension checks: `.meth` for the instrument method and `.pmd` for the processing method.
136
+
137
+ ### Not implemented
138
+
139
+ - **MassHunter Walkup Custom Sample Import** ([G2725-90026](https://www.agilent.com/cs/library/usermanuals/public/G2725-90026_Walkup_Programmer.pdf)): the guide couldn't be retrieved (HTTP 403), so its format couldn't be verified.
140
+ - **Native worklist and sequence files** (MassHunter `.wkl` XML, Xcalibur `.sld`, MassLynx `.spl`): not implemented. We found no public specification for them, so the server uses the CSV import paths above.
141
+
142
+ ## Validation
143
+
144
+ `validate_worklist`, which `export_worklist` also runs, reports **errors**, which block export, and **warnings**:
145
+
146
+ - Required fields for the format are missing.
147
+ - Duplicate data-file names, compared case-insensitively. For SCIEX OS a shared data file is allowed, but a sample name repeated within one data file is an error.
148
+ - Characters Windows doesn't allow in file names (`< > : " / \ | ? *`, control characters), a trailing dot or space, and reserved names (CON, NUL, COM1โ€ฆ).
149
+ - The position doesn't match the chosen `position_pattern` (`vial_number`, `well`, `agilent_plate_well`, `waters_plate_well`, `tray_well`) or falls outside the `plate_size` (24/48/54/96/384) or `max_vial`.
150
+ - The injection volume is โ‰ค 0, not a number, or above the `max_injection_volume_ul` limit. This includes injection-volume columns set through `extra` or `vendor_columns`.
151
+ - A text field or `extra` value contains a line break or another control character, which would break the import file.
152
+ - The method file has the wrong extension, for example an Analyst `.dam` in a SCIEX OS batch, or a MassHunter `.m` in an Xcalibur sequence.
153
+ - Fields the target format has no column for, and non-ASCII text in formats without a BOM.
154
+
155
+ ## Safety limits
156
+
157
+ | Limit | Default | Meaning |
158
+ |---|---|---|
159
+ | `max_injection_volume_ul` | 100 ยตL | Largest injection volume allowed in a worklist. Enforced when samples are added and again at export, including volume columns set verbatim through `extra` or `vendor_columns`. `import_worklist` warns about larger volumes, and such a draft can't be exported. |
160
+
161
+ Override at launch, for example `--limit max_injection_volume_ul=20` for a 20 ยตL loop.
162
+
163
+ ## Example prompts
164
+
165
+ - "Make an Xcalibur sequence for the 40 plasma samples in this list: wells A1 onwards on the R tray, 2 ยตL, method C:\Xcalibur\methods\DIA_60min. Add a blank after every 10 samples from R:H12 and a pooled QC at the start and end from R:H11. Randomise the samples and tell me the seed."
166
+ - "Import `old_batch.csv` from the worklist folder and convert it to a MassHunter worklist with method D:\MassHunter\methods\Panel.m."
167
+ - "I put `blank_batch.txt` (exported from our SCIEX OS) in the folder. Use it as the template for this batch."
168
+ - "Check this MassLynx sample list for duplicate file names and bad vial positions before I import it."
169
+
170
+ ## Notes
171
+
172
+ - Drafts live in memory. `reconnect` (or restarting the server) discards them. In `--simulate` it also deletes the temporary folder. Export files you want to keep.
173
+ - By default, `export_worklist` also writes `<file>.provenance.json` next to the worklist (for example `Plasma.csv.provenance.json`). Like the worklist itself, it is never overwritten unless `overwrite=true`. It contains the operation history, the randomisation seed and the sample order before randomisation, so the run order can be reproduced. Pass `write_provenance=false` to skip it.
174
+ - `blank_every_n` / `qc_every_n` also add a control after the last sample when the count divides evenly, unless `blank_at_end` / `qc_at_end` already adds one there.
175
+ - When a draft is exported in another vendor's format, values kept verbatim from the original vendor for columns the new vendor maps itself (for example Xcalibur's `Std Clear` sample type) are not copied; the export notes say so.
176
+ - Randomisation shuffles only the types in `randomize_types` (by default unknown samples) among their own slots, using Python's `random.Random(seed)`. Standards, blanks and QCs stay where they are.
177
+ - Method names must match methods that exist on the acquisition PC. The server can't check that.
178
+
179
+ ## Verification
180
+
181
+ | Software | Version | Format | Verified by | Date |
182
+ |---|---|---|---|---|
183
+ | *none yet: [be the first](https://github.com/K-Dense-AI/lab-instrument-mcps/issues/new?template=hardware-verification.yml)* | | | | |
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "labmcp-ms-worklist"
3
+ version = "0.1.0"
4
+ description = "MCP server that builds, validates and exports LC-MS worklist import files for MassLynx, SCIEX OS, MassHunter and Xcalibur."
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ requires-python = ">=3.10"
8
+ authors = [{ name = "K-Dense and LabMCP contributors" }]
9
+ keywords = ["mcp", "lab-instrument", "mass-spectrometry", "lc-ms", "worklist", "sequence", "masslynx", "sciex-os", "masshunter", "xcalibur"]
10
+ dependencies = ["labmcp>=0.1,<0.2"]
11
+
12
+ [project.scripts]
13
+ labmcp-ms-worklist = "labmcp_ms_worklist.server:main"
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/K-Dense-AI/lab-instrument-mcps/tree/main/servers/chemistry/ms-worklist"
17
+
18
+ [tool.labmcp]
19
+ name = "LC-MS Worklist Builder"
20
+ domain = "chemistry"
21
+ category = "Mass spectrometry"
22
+ vendor = "Multi-vendor"
23
+ models = ["Waters MassLynx 4.x", "SCIEX OS", "Agilent MassHunter Acquisition", "Thermo Xcalibur"]
24
+ interfaces = ["File"]
25
+ protocol = "Sample-list import files: MassLynx worksheet CSV, SCIEX OS batch CSV/TXT, MassHunter worklist CSV, Xcalibur sequence CSV"
26
+ summary = "Build, randomise, validate, convert and export LC-MS sample queues as vendor import files (never starts a run)."
27
+ status = "simulated"
28
+
29
+ [build-system]
30
+ requires = ["hatchling"]
31
+ build-backend = "hatchling.build"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["src/labmcp_ms_worklist"]
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.K-Dense-AI/labmcp-ms-worklist",
4
+ "title": "LC-MS Worklist Builder",
5
+ "description": "MCP server that builds, validates and exports LC-MS worklist import files for MassLynx, SCIEX OS, Ma",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/K-Dense-AI/lab-instrument-mcps",
9
+ "source": "github",
10
+ "subfolder": "servers/chemistry/ms-worklist"
11
+ },
12
+ "websiteUrl": "https://github.com/K-Dense-AI/lab-instrument-mcps/tree/main/servers/chemistry/ms-worklist",
13
+ "packages": [
14
+ {
15
+ "registryType": "pypi",
16
+ "registryBaseUrl": "https://pypi.org",
17
+ "identifier": "labmcp-ms-worklist",
18
+ "version": "0.1.0",
19
+ "transport": {
20
+ "type": "stdio"
21
+ },
22
+ "environmentVariables": [
23
+ {
24
+ "name": "LABMCP_ADDRESS",
25
+ "description": "Instrument address, e.g. serial:///dev/ttyUSB0 or tcp://192.168.1.50:5025",
26
+ "isRequired": false
27
+ },
28
+ {
29
+ "name": "LABMCP_SIMULATE",
30
+ "description": "Set to 1 to use the built-in simulator (no hardware)",
31
+ "isRequired": false
32
+ },
33
+ {
34
+ "name": "LABMCP_READ_ONLY",
35
+ "description": "Set to 1 to disable all state-changing tools",
36
+ "isRequired": false
37
+ },
38
+ {
39
+ "name": "LABMCP_LIMITS",
40
+ "description": "Safety limit overrides, e.g. max_temperature_c=80",
41
+ "isRequired": false
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1 @@
1
+ """LabMCP server for Mass Spectrometer Worklists (MassLynx, SCIEX OS, MassHunter, Xcalibur)."""