Skip to main content
Glama
mplus-mcp
by Ian3738

mplus-mcp

test License: MIT Python 3.12+ Mplus 8

An MCP server that drives Mplus: it prepares data, writes and runs input files, and reads the output back as tables instead of several hundred lines of fixed-width text.

Works with the licensed executable and with Mplus Demo (which caps the model at 6 dependent and 2 independent variables).

繁體中文說明請見 README.zh-TW.md。


Tools

Tool

What it does

mplus_status

Which executable is in use, its version, demo limits

syntax_help

Syntax reference by topic (model, mixture, invariance, errors …)

data_prepare

CSV/Excel/SPSS/Stata → an Mplus .dat plus the VARIABLE block

build_syntax

Input syntax for cfa, efa, path, sem, mediation, growth, lpa, lca, invariance, twolevel

run_syntax

Write syntax to a file, run it, summarise the output

run_file

Run an existing .inp

output_summary

Re-read any .out: fit, estimates, warnings

output_section

One section verbatim (TECH1, residuals, random starts …)

compare_fit

Fit indices side by side, with a scaled chi-square difference test

savedata_read

Read back factor scores / class probabilities, optionally as CSV

Related MCP server: JeffersonStats

Install

Needs uv and an installation of Mplus. The demo build works too.

Claude Code

claude mcp add mplus -- uvx --from git+https://github.com/Ian3738/mplus-mcp mplus-mcp

Claude Desktop

Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/, Windows: %APPDATA%\Claude\):

{
  "mcpServers": {
    "mplus": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/Ian3738/mplus-mcp", "mplus-mcp"]
    }
  }
}

If the client cannot find uvx, give the absolute path (which uvx).

From a clone

git clone https://github.com/Ian3738/mplus-mcp
cd mplus-mcp
uv sync
claude mcp add mplus -- "$(pwd)/run-server.sh"

run-server.sh exists for two situations a bare uv run does not handle: GUI clients that start without uv on PATH, and clones inside iCloud Drive, where the virtualenv has to live outside the synced folder.

Configuration

Variable

Default

Purpose

MPLUS_MCP_BINARY

first executable found (see below)

Path to the Mplus executable. Set it to prefer a licensed copy over the demo.

MPLUS_MCP_WORKDIR

~/Mplus-MCP

Where runs go when no folder is given

Searched automatically: mplus / mpdemo on PATH, /Applications/Mplus/mplus, /Applications/MplusDemo/mpdemo, /usr/local/bin/mplus, /opt/mplus/mplus, C:\Program Files\Mplus\Mplus.exe.

Reading .sav files needs one extra package: add --extra spss to uv sync, or use uvx --from "git+https://github.com/Ian3738/mplus-mcp[spss]" mplus-mcp.

Verify the setup by asking the model to call mplus_status.

How a session goes

data_prepare(path="ses.csv")
  → writes ses.dat, reports that `motivation` became `motivat`, hands back
    NAMES = id sex y1 y2 y3 y4 x1 x2; MISSING = ALL (-999);

build_syntax(model_type="cfa", data_file="ses.dat",
             names="id sex y1-y4 x1 x2",
             factors={"F1": ["y1", "y2", "y3", "y4"]})
  → the input file as text

run_syntax(syntax=..., workdir="/path/holding/ses.dat", name="cfa1")
  → status, fit table, parameter estimates, any warnings, and cfa1.out on disk

compare_fit(out_paths=["cfa1.out", "cfa2.out"], chisq_diff=True)

Notes on Mplus itself

  • Data files are resolved relative to the folder the input file runs in, so the server always runs with the working directory set to the .inp folder and refers to data by its bare file name. That is what makes folder names with spaces work.

  • Input lines are capped at 90 characters; run_syntax folds longer ones.

  • Variable names are capped at 8 characters; data_prepare renames and reports.

  • A run that fails still writes an .out, so the error is parsed and returned with the well-known causes attached where they apply.

Licence

MIT

Available Tools

10 tools
build_syntaxA

Write Mplus input syntax for a standard model family (cfa, efa, path, sem, mediation, growth, lpa, lca, invariance, twolevel, custom). Returns the syntax as text - it does not run it. Read it, adjust it, then pass it to run_syntax. Anything the template does not cover goes in model_extra, analysis_extra or model_constraint.

Inputs: names (required), data_file (required), model_type (required), x, +36 more.

compare_fitA

Put the fit statistics of several .out files side by side - class enumeration, measurement invariance, nested model comparisons. With chisq_diff it also runs the chi-square difference test between consecutive models, scaled for MLR when Mplus reported a scaling correction factor.

Inputs: out_paths (required), labels, chisq_diff.

data_prepareA

Convert a CSV, Excel, SPSS (.sav), Stata (.dta) or parquet file into an Mplus .dat file: numeric only, no header, missing values flagged, names cut to 8 characters. Returns the DATA and VARIABLE block to paste into an input file, plus a per-variable summary and a note of anything that was renamed or recoded.

Inputs: path (required), sep, sheet, header, +8 more.

mplus_statusA

Report which Mplus executable will be used, its version, and any demo-version limits. Call this first when a run fails for reasons that look like the installation rather than the model.

Inputs: no named parameters.

output_sectionA

Return one section of an .out file verbatim, for anything the summary does not parse - TECH1, TECH4, residuals, sample statistics, random-start loglikelihoods. Call without section to list the sections in the file.

Inputs: out_path (required), section, max_chars.

output_summaryA

Summarise an Mplus .out file that already exists: status, warnings, fit, parameter estimates, and whatever else include asks for. Use it on output produced outside this server, or to re-read a run without repeating it.

Inputs: out_path (required), include, max_rows.

run_fileA

Run an Mplus input file that already exists on disk and summarise the output. Use this for .inp files written by hand or by the Mplus editor.

Inputs: inp_path (required), include, timeout, max_rows.

run_syntaxA

Write Mplus input syntax to a file, run it, and summarise the output. Long lines are folded to the 90-character limit first. The .inp and .out stay on disk. Use include to ask for more of the output than the default fit table, parameter estimates and warnings.

Inputs: syntax (required), name, include, timeout, +2 more.

savedata_readA

Read the file a SAVEDATA command wrote - factor scores, class probabilities, most likely class membership - using the column layout Mplus recorded at the end of the .out file. Optionally write it out as a CSV for use in R or Excel.

Inputs: out_path (required), rows, to_csv.

syntax_helpA

Mplus syntax reference by topic: overview, data, variable, analysis, model, mediation, cfa, invariance, growth, mixture, multilevel, output, fit, montecarlo, errors, demo. Call with no topic to list them. Use it before writing syntax for a model family you have not written recently.

Inputs: topic.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool has a clearly distinct role in the Mplus workflow: installation status, syntax reference, data conversion, syntax generation, execution from text versus file, parsed output summarization versus raw sections, cross-file comparison, and savedata ingestion. No two tools overlap enough to cause selection ambiguity.

    Naming Consistency3/5

    All names are lowercase snake_case and readable, but they mix verb-first forms (build_syntax, run_syntax, run_file, compare_fit), output_* prefixed forms, and noun-verb forms (data_prepare, savedata_read). The functional prefixes help, but the ordering is not consistent enough for a higher score.

    Tool Count5/5

    Ten tools is well within the ideal range and each one maps to a distinct stage of the Mplus analysis lifecycle. None of the tools feel redundant or unnecessary for the server's stated purpose.

    Completeness5/5

    The set covers the full workflow: checking installation, syntax help, data preparation, syntax generation, running new or existing input files, summarizing output, retrieving raw output sections, comparing model fits, and reading SAVEDATA files. There are no obvious dead ends or significant missing operations.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables comprehensive statistical analysis including descriptive statistics, hypothesis testing, regression, and more via a FastMCP-based API.
      3
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI-native statistical analysis and reproducible research workflows through MCP, including natural language planning, protocol-based analysis, Python/R cross-validation, and publication-ready figure generation.
      MIT