Grounded analysis
MSMCP computes exact masses, adduct shifts, isotope envelopes, ppm gates and cosine scores in deterministic Python tools. The glucose isotope figure below shows output from the released tool.
Open-source MCP server · Mass spectrometry
MSMCP puts your own data in front of an AI client — Claude, Zed, or any other MCP host. Ask it to open an mzML, MGF or imzML file, check a precursor mass against a formula, compute isotope and adduct patterns, score an MS/MS spectrum against your MSP library, or summarise QC across a run.
The model reasons. The tools compute.
MCP — the Model Context Protocol — is the open standard that lets an assistant call tools and read files it is given. MSMCP is the mass spectrometry end of it.
Run it now
uvx --python 3.13 --from msmcp==1.0.2 msmcpHow the peaks stay out of the prompt
An opaque, random, expiring handle — never an address, an id or a path.
Large peak arrays stay server-side; the host carries references, job IDs and compact reports.
Reproducible demo · release 1.0.2
The release includes a small caffeine MGF query and an MSP library. Put both files under the configured allowed root, load the MS2 spectrum, dispatch a search, then poll its job. The fixture deliberately duplicates a library record, so this verifies the tool flow — not identification accuracy or scientific significance.
0 · Prompt to your assistant
/data/caffeine_spectrum.mgf and search it against /data/caffeine_library.msp with instrument_class="orbitrap".”1 · Load the query
load_spectrum(file_path="/data/caffeine_spectrum.mgf", spectrum_index=0)2 · Search and poll
search_library(database_file="/data/caffeine_library.msp", spectrum_reference="ptr:spectrum:…", scoring_method="classical", instrument_class="orbitrap")check_search_status(job_id="<job ID returned by search_library>")Example candidate report
| Rank | Candidate | Score | Precursor m/z |
|---|---|---|---|
| 1 | Caffeine C8H10N4O2 | 1.0000 | 195.0877 |
These are fabricated demonstration spectra and an exact synthetic match. The score is a ranking value, not an identification probability or error rate.
search_library refuses non-MS2 queries, applies the chosen instrument class's precursor tolerance, and excludes records whose polarity, charge or adduct conflicts (entries omitting context remain ranked as unknown). Production search reports similarity-ranked candidates only; it does not report p-values, q-values or calibrated FDR.LLMs should reason about mass spectrometry, not perform the arithmetic. Every scientific value on this page is a tool's output rather than a model's recollection, and every derived result carries a record of how it was made. That is the standard AI-assisted mass spectrometry should be held to, and MSMCP is infrastructure for it.
MSMCP computes exact masses, adduct shifts, isotope envelopes, ppm gates and cosine scores in deterministic Python tools. The glucose isotope figure below shows output from the released tool.
Long searches run as jobs that a client can poll. Loaded spectra and search reports include provenance for their inputs and parameters; a score remains a ranking, not a confidence estimate.
MSMCP runs locally over stdio, makes no network calls of its own, and confines file reads to an allowed root under size caps. The host still controls the process with your permissions, so anyone who can drive that client can drive MSMCP; run it on a machine you own, never as a network service. See the security notes.
annotate_isotopes("C6H12O6", isotopologues=3)
M+1 and M+2 are plotted on a 0–0.10 vertical axis (×10 magnification); on the full-scale panel above they are 6.86 % and 1.43 % of the monoisotopic peak. Values are displayed to the tool's four-decimal precision.
Also verified in the tree
search_library can search supported local libraries without an upload or hosted service.Tools that apply tolerances accept instrument_class and record the chosen defaults in provenance. Unit-resolution classes use Da rather than ppm because a fixed ppm gate shrinks below 1 Da at small-molecule masses.
| Class | Precursor | MS2 / diag. | SNR bands |
|---|---|---|---|
generic default | 5.0 ppm | 0.02 Da | 5 / 20 |
orbitrap accurate mass | 5.0 ppm | 0.01 Da | 5 / 20 |
tof reflectron TOF | 15.0 ppm | 0.05 Da | 5 / 20 |
ion_trap unit resolution | 0.5 Da | 0.5 Da | 5 / 20 |
triple_quad unit resolution | 0.7 Da | 0.7 Da | 5 / 20 |
These are documented conventions, not measured from raw file headers; compute_cosine also accepts an explicit ms2_tolerance override in Da.
Passing unit tests is not scientific validation. MSMCP separates software tests from independent evidence in SCIENTIFIC_VALIDATION.md.
MSMCP 1.0.2 is published on PyPI and requires Python 3.13 or later. Install it in an isolated environment with uv; the command below is pinned to the published version. No API key, account or hosted service is needed.
uvx --python 3.13 --from msmcp==1.0.2 msmcpThis is the stdio server command for your MCP host. The release wheel is fetched from PyPI into uv's isolated tool environment; source cloning is not required.
uv tool install --python 3.13 msmcp==1.0.2pip install msmcp==1.0.2.ibd) reading via massflow>=0.1.2,<0.2. Keep separate from the unrelated analytical MassFlow engine; importing the imaging package creates a logs/ directory in the working directory.annotate_isotopes(is_smiles=True). Explicit formulas work in the core install without RDKit.dreams from source, and LSM-MS2 awaits public weights..mzML files use MS-Numpress compression (zlib-compressed mzML works out of the box).{
"mcpServers": {
"msmcp": {
"command": "uvx",
"args": [
"--python",
"3.13",
"--from",
"msmcp==1.0.2",
"msmcp"
],
"env": {
"MSMCP_ALLOWED_ROOT": "/absolute/path/to/ms-data"
}
}
}
}Uses the standard mcpServers schema. Keep uvx on the host's PATH (or pass its full path) and point MSMCP_ALLOWED_ROOT at the directory containing your acquisitions and libraries.
{
"context_servers": {
"msmcp": {
"command": "uvx",
"args": [
"--python",
"3.13",
"--from",
"msmcp==1.0.2",
"msmcp"
],
"env": {
"MSMCP_ALLOWED_ROOT": "/absolute/path/to/ms-data"
}
}
}
}Uses Zed's context_servers schema with the exact same pinned uvx command and MSMCP_ALLOWED_ROOT boundary. Once connected, ask your assistant to run ping or inspect a file inside the allowed root.
Every runtime limit has a conservative default; if MSMCP_ALLOWED_ROOT is unset, it defaults to the server's working directory. Set these in your MCP client's env block when needed.
| Variable | Default | Effect |
|---|---|---|
| MSMCP_ALLOWED_ROOT | process working directory | Directory subtree that all file-reading tools (including library paths) are confined to. |
| MSMCP_MAX_FILE_SIZE_BYTES | 500 MiB | Per-file ceiling, enforced on inflated bytes for .gz and zlib-compressed arrays. |
| MSMCP_MAX_SPECTRA | 1000 | Per-request spectrum cap for indexed loads and QC scans (extract_chromatograms caps at 10,000). |
| MSMCP_MAX_REFERENCES | 128 | Maximum live ptr:spectrum:… handles held in server memory before new registrations fail. |
| MSMCP_MAX_TOTAL_BYTES | 512 MiB | Total payload ceiling across active server-side data references. |
| MSMCP_REFERENCE_TTL_SECONDS | 3600 | Reference expiration in seconds (0 disables lazy expiry). |
| MSMCP_EMBEDDING_BACKEND | real | real requires installed DreaMS/LSM-MS2 weights; mock selects test-only stand-ins. |
Every call below matches the signature and defaults the server advertises in tools/list. When a spectrum is loaded with load_spectrum, summarise_reference, compute_cosine and search_library accept its ptr:spectrum:… handle instead of copying peaks across MCP/JSON.
What is in this file?
load_mzml_summary(file_path="/data/run.mzML", max_spectra=5)Per spectrum: MS level, retention time, total ion current, peak count, base peak (with optional noise_threshold filter; max_spectra 1–50). The footer states the file's total spectrum count.
Which spectra are MS2, and which index do I want?
list_spectra(file_path="/data/run.mzML", ms_level=2)An index table — spectrum index, MS level, retention time, precursor m/z, peak count — across .mzML, .mzML.gz, .mgf, .mgf.gz, or .imzML (supports ms_level, min_peaks, and max_spectra up to 1,000).
Hold one spectrum server-side.
load_spectrum(file_path="/data/run.mzML", spectrum_index=0)Metadata plus a ptr:spectrum:… handle. The peak array stays in the server's memory instead of entering the conversation; index must sit below MSMCP_MAX_SPECTRA.
What is behind this handle?
summarise_reference(reference="ptr:spectrum:264a5ae9…")The same compact spectrum block, read from memory rather than the file, followed by the reference's provenance.
Free that memory now rather than waiting for expiry.
release_reference(reference="ptr:spectrum:264a5ae9…")Confirmation. Releasing an unknown or already-released reference is reported, not raised, so a retry is safe.
Does this precursor mass fit the formula I think it does?
validate_precursor(theoretical_mass=180.0634, experimental_mass=180.0634)Mass error and a PASSED or REJECTED verdict against the optional instrument_class (default generic: 5.0 ppm; unit-resolution classes use Da).
What does [M+H]+ add, exactly?
predict_adduct_offset(adduct_string="[M+H]+")Polarity, charge state, exact mass shift in daltons and offset formula for 14 canonical adducts: [M+H]+, [M+Na]+, [M+K]+, [M+NH4]+, [M+H-H2O]+, [M+2H]2+, [M+3H]3+, [M+2Na-H]+, [M-H]-, [M+Cl]-, [M+HCOO]-, [M+CH3COO]-, [M-H2O-H]-, and [M+Na-2H]-. Anything else is refused.
What should the isotope envelope look like for this formula?
annotate_isotopes(identifier="C6H12O6", isotopologues=3)Monoisotopic mass and M … M+(n-1) masses (isotopologues 1–10) with abundances normalised to M = 1.0000 via exact multinomial expansion (collapsed to nominal centroids). Set is_smiles=True with msmcp[chem] for SMILES input; fails closed without RDKit.
How similar are these two MS/MS spectra?
compute_cosine(query_peaks=[[100.0, 1.0]], reference_peaks=[[100.0, 1.0]])A cosine score and matched/unmatched peak details. Each side accepts inline peaks or a ptr:spectrum:… reference (query_reference / reference_reference). Defaults to scoring_method='classical' (greedy 1-to-1 matching under ms2_tolerance or instrument_class); 'dreams' and 'lsm-ms2' require model weights.
Extract TIC, BPC and target-ion traces from an mzML acquisition.
extract_chromatograms(file_path="/data/run.mzML", targets_mz=[195.0877], tolerance=5.0, tolerance_unit="ppm", ms_level=1)Structured scan-level traces (schema_version '1.0' in structuredContent) with mandatory SHA-256 digest and completeness metadata. Accepts up to 20 XIC targets, optional retention_time_range_min, and up to 10,000 scanned spectra. No smoothing, blank subtraction or identification is performed.
Was this run worth searching?
generate_qc_summary(file_path="/data/run.mzML")Spectrum and total-ion-current counts, peak density, estimated signal-to-noise ratio, and diagnostic-ion prevalence (optional instrument_class). Scans up to MSMCP_MAX_SPECTRA and states when full-acquisition coverage is unconfirmed.
Match this MS2 against the library I already have.
search_library(database_file="/data/libraries/MassBank.msp", spectrum_reference="ptr:spectrum:…", scoring_method="classical")Returns a job ID immediately (accepts spectrum_reference or experimental_file + spectrum_index, plus optional instrument_class). Reads .msp/.msp.gz and .mgf/.mgf.gz from disk behind the allowed root; unrecognised paths fall back to a labelled synthetic library. Refuses non-MS2 queries and gates candidates on precursor tolerance, polarity, charge and adduct; reports similarity rankings only.
Is the scan finished?
check_search_status(job_id="2aafd7b8f1c44b42a987a34b0f724610")Queued, running, completed, failed or cancelled — then delivers the full ranked report once (later polls return a short digest unless full_report=True), naming the scorer, tolerances, library source and provenance.
Stop the scan.
cancel_search(job_id="2aafd7b8f1c44b42a987a34b0f724610")Cancellation. A job that already finished is reported as finished, and a cancelled scan's partial work is discarded.
Is the server alive?
ping()Operational status and optional imaging-distribution metadata. This does not verify imzML compatibility; call it first when another tool fails unexpectedly.
stdio (mcp[cli]>=2.2.0). Diagnostics write to stderr; stdout carries MCP framing only.open_world_hint=False. Thirteen are read_only_hint=True; only release_reference and cancel_search mark state mutation (both idempotent_hint=True).extract_chromatograms publishes an MCP outputSchema (schema_version: "1.0") and returns parallel arrays in structuredContent.search_library uses an in-memory job executor (4 concurrent jobs max, 1-hour finished-job TTL) polled via check_search_status; MSMCP does not implement the MCP Tasks protocol, and in-flight jobs do not survive a server restart.PathEscapeError, UnsupportedFormatError, MalformedFileError, MissingDependencyError, SpectrumCountExceededError, EmbeddingBackendUnavailable) surface as MCP tool errors with diagnostic details in stderr logs.The package, release notes and scientific documentation are pinned to 1.0.2 so their contracts stay aligned with this page.
Contact. There is no mailing list and no contact form. Bug reports, questions and feature discussion belong in GitHub Issues, where the answer stays searchable for the next person.