Skip to main content
Glama
SPSS-MCP

SPSS-MCP

SPSS-MCP

An MCP server that lets Claude (or any MCP client) run statistics on SPSS data files and report the results as SPSS-style tables.

Two ways to compute. By default (the Python backend), results are calculated in Python with the formulas SPSS uses. They are not produced by SPSS. If IBM SPSS Statistics is installed, switch on the SPSS backend and every procedure runs in SPSS itself. You also get .spv and .pdf output files. See Run in IBM SPSS.

  • Opens .sav, .zsav, .por, .csv and .tsv files, with variable labels, value labels and user-missing values.

  • Every analysis can select cases first: structured filters (like FILTER BY) and exclusion of straight-liners, with case counts before and after.

  • Shows the SPSS syntax for every result.

  • Locked down by design. See Security.

What it can do

Area

Tools

Explore

list_data_files, describe_dataset, preview_rows, server_info, check_spss

Describe

frequencies, descriptives, crosstabs (chi-square, Fisher's exact, phi, Cramér's V)

Compare means

t_test (one-sample, independent with Levene and Welch, paired), one_way_anova (Levene, Welch, Tukey HSD), general_linear_model (factorial ANOVA / ANCOVA, Type III)

Relationships

correlations (Pearson, Spearman, Kendall's tau-b), linear_regression (Beta, CI, VIF, Durbin-Watson), logistic_regression (binary)

Nonparametric

nonparametric_test: Mann-Whitney U, Wilcoxon signed ranks, Kruskal-Wallis, Friedman

Assumptions

normality_test (Kolmogorov-Smirnov with Lilliefors correction, Shapiro-Wilk)

Scales

reliability_analysis (Cronbach's alpha with a scale name; item, scale and inter-item statistics; squared multiple correlations), factor_analysis (PCA, KMO, Bartlett, varimax)

Prepare data

compute_scale_score, reverse_code, recode_values. Each one writes a new file and never changes the original.

Related MCP server: SPSS-MCP Extended

Install

You need Python 3.12 or newer.

git clone https://github.com/irfanabdulhameed/SPSS-MCP.git
cd SPSS-MCP
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/pip install .          # Windows: .venv\Scripts\pip install .

Tested on macOS with Python 3.12 and 3.15. Windows and Linux should work but haven't been fully tested yet. requirements.lock records the exact versions from the macOS test environment, for reference.

Connect it

Put your data files in one folder, for example ~/Documents/SPSS-MCP. The server can only see that folder.

Claude Desktop: open Settings → Developer → Edit Config and add:

{
  "mcpServers": {
    "spss": {
      "command": "/full/path/to/SPSS-MCP/.venv/bin/spss-mcp",
      "env": { "SPSS_MCP_DATA_DIRS": "/Users/you/Documents/SPSS-MCP" }
    }
  }
}

On Windows, use C:\\path\\to\\SPSS-MCP\\.venv\\Scripts\\spss-mcp.exe and a Windows folder path. Restart Claude Desktop afterwards.

Claude Code:

claude mcp add spss --env SPSS_MCP_DATA_DIRS="$HOME/Documents/SPSS-MCP" -- /full/path/to/SPSS-MCP/.venv/bin/spss-mcp

Then ask, for example: "Using survey.sav, keep only cases with consent = Yes and drop straight-liners on q1–q12, then give me Cronbach's alpha for each construct."

Run in IBM SPSS (SPSS backend)

Status: experimental. The full pipeline is tested on our side with a stand-in for SPSS's spss module: syntax building, the SPSS process, output capture and saved files. It has not yet been confirmed against a real SPSS installation, so please report how it goes.

Turn it on with two extra settings. SPSS ships its own Python, which can import spss and run syntax in the SPSS engine without opening the SPSS window:

"env": {
  "SPSS_MCP_DATA_DIRS": "C:\\Users\\you\\Documents\\SPSS-MCP",
  "SPSS_MCP_BACKEND": "spss",
  "SPSS_MCP_SPSS_PYTHON": "C:\\Program Files\\IBM\\SPSS Statistics\\Python3\\python.exe"
}

On Windows, find Python3\python.exe inside your SPSS installation folder. The server sets SPSS_HOME and PATH for it automatically. On a Mac, SPSS's Python is usually at <SPSS folder>/Resources/Python3/bin/python3; the Mac setup is unverified. Then ask Claude to run check_spss, which starts SPSS and reports its version.

With the SPSS backend:

  • Every analysis tool runs in SPSS. The server builds the syntax from checked variable names, opens the file with GET FILE, applies any case selection with FILTER BY, and runs the procedure.

  • Results come back through OMS. Every table is captured as text and shown as a Markdown table.

  • SPSS output is saved. .spv and .pdf files go into the output folder. Change this with SPSS_MCP_SPSS_SAVE (spv, pdf, spv,pdf or none).

  • The data file is only read. No syntax this server writes contains a SAVE command.

  • Only these file types. The SPSS backend opens .sav, .zsav and .por files. Save CSV data as .sav first.

  • Each call starts SPSS. Expect some start-up time per analysis: a few seconds, up to a minute on slower machines.

  • Case counts come from the server. The before-and-after counts are worked out by the server; SPSS applies the same selection with the syntax shown.

Data open in SPSS: the server reads files, not SPSS's open session. Save the dataset (File → Save As… → .sav) into the data folder and point the server at that file.

Selecting cases

Every analysis tool takes two optional inputs.

case_filter is a structured filter, never an expression:

{"all": [
  {"var": "consent",  "op": "eq", "value": "Yes"},
  {"var": "employed", "op": "eq", "value": "Yes"},
  {"any": [{"var": "age", "op": "ge", "value": 18}, {"var": "role", "op": "in", "values": [1, 2]}]}
]}
  • Groups: all means AND and any means OR. Groups can be nested.

  • Operators: eq, ne, gt, ge, lt, le, in and not_in (with values), missing, not_missing.

  • Value labels: a text value such as "Yes" is matched to its numeric code through the value labels.

  • Missing values: as with SPSS FILTER BY, a condition on a missing value excludes the case, except for missing and not_missing.

exclude_straightliners is a list of items. Cases that gave the same answer to every one of them (standard deviation 0) are excluded.

The output shows the case counts after each step, for example 41 in file → 37 after filter → 36 after excluding straight-liners. It also shows the matching syntax:

COMPUTE mcp_sd = SD(q1, q2, q3, q4).
COMPUTE mcp_filter = (consent = 1 AND employed = 1) AND (MISSING(mcp_sd) OR mcp_sd > 0).
FILTER BY mcp_filter.

Settings

Variable

Default

Meaning

SPSS_MCP_DATA_DIRS

~/Documents/SPSS-MCP

Folders the server may read. Separate several with : (macOS/Linux) or ; (Windows).

SPSS_MCP_OUTPUT_DIR

<first data folder>/output

Where new files are written. Must be inside a data folder.

SPSS_MCP_MAX_FILE_MB

200

Largest file the server will open.

SPSS_MCP_BACKEND

python

python, or spss to run procedures in IBM SPSS Statistics.

SPSS_MCP_SPSS_PYTHON

Path to the Python bundled with SPSS. Required for the SPSS backend.

SPSS_MCP_SPSS_SAVE

spv,pdf

SPSS output files to keep: spv, pdf, spv,pdf or none.

SPSS_MCP_SPSS_TIMEOUT

300

Seconds before an SPSS run is stopped.

Security

  • No free-form code or syntax. There is no "run syntax" or "run Python" tool, and no expression language. Filters are structured data. Each tool is a fixed procedure with typed, range-checked inputs.

  • Syntax built from checked parts only. For the SPSS backend, variable names must be plain SPSS names that exist in the file. Numbers must be finite. Text values and paths are single-quoted with quotes doubled, and line breaks are refused. The syntax this server writes never contains SAVE, HOST, INSERT, INCLUDE or BEGIN PROGRAM, and a test enforces that.

  • One fixed process. The SPSS backend starts only the configured SPSS Python with the package's own worker script: a fixed argument list, no shell, and a timeout. Nothing else in the server can start a process.

  • Folder sandbox. The server reads only inside the configured folders. Paths are resolved with symlinks followed before they are checked, so ../, absolute paths and symlinks that point outside are all refused. It also refuses unknown file types, oversized files and files that would expand too far in memory.

  • No overwrites. New files go only into the output folder, under plain file names. An existing file is never replaced.

  • Safe CSV export. Text cells that start with =, +, - or @ get a leading ', so a spreadsheet won't run them as formulas.

  • Untrusted text. Labels, column names and SPSS output text are cleaned and shortened before they reach the model. The model is also told to treat them as data, never instructions.

  • No network. The server uses stdio only. It opens no port and makes no outbound connections.

  • Limited data sharing. Analyses send summary tables to the model. Only preview_rows sends raw cases, at most 50 rows.

  • Checked automatically. The tests cover traversal, symlink escapes, overwrites, hostile names, labels and filter values, syntax injection and CSV injection. They fail if dangerous calls appear in the source. Bandit reports no issues, and pip-audit finds no known vulnerabilities in the pinned dependencies.

See SECURITY.md to report a problem.

Accuracy (Python backend)

tests/test_matches_spss.py checks results against IBM SPSS Statistics output for the same files:

  • paired t-test

  • Wilcoxon signed ranks

  • Mann-Whitney U

  • crosstabs with chi-square

  • Kruskal-Wallis

  • Cronbach's alpha

  • tests of normality

  • binary logistic regression

  • UNIANOVA (Type III)

  • principal components

Not yet checked against SPSS output: frequencies, descriptives, one-sample and independent t-tests, one-way ANOVA (Welch, Tukey), correlations, linear regression, Friedman, varimax rotation, and the newer reliability tables (scale statistics, inter-item correlations, squared multiple correlations). They use the standard SPSS formulas and pass internal consistency checks.

Details worth knowing:

  • User-defined missing values are treated as missing, as SPSS does.

  • Correlations use pairwise deletion. Regression, reliability and factor analysis use listwise deletion. These are the SPSS defaults.

  • Factor loadings can differ from SPSS in sign, because the sign of each component is arbitrary.

  • Exact p-values for small-sample nonparametric tests are not provided. The asymptotic p-values match SPSS.

When results must come from SPSS itself, use the SPSS backend.

Development

.venv/bin/pip install -e ".[test]"
.venv/bin/python -m pytest

Licence

MIT. See LICENSE. The sample data in tests/fixtures comes from another MIT-licensed project; see tests/fixtures/NOTICE.md.

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for safe batch execution of IBM SPSS Statistics syntax (.sps) via stats.exe Production mode, with static security checks and sandboxed output.
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to safely execute statistical analyses, parse results into Markdown and JSON, and generate publication-ready charts through a local IBM SPSS Statistics installation on macOS and Windows.
      51
      26 PyPI
      1
      MIT