Skip to main content
Glama
README.md
# jamovi-ai-workflow

**English** | [中文](#中文) | [日本語](#日本語)

Let an AI assistant run your own jamovi (built-in analyses and installed modules) through a local MCP server. Every run is logged, every result comes with the click-by-click steps to repeat it in jamovi, and causal methods (RD, IV, DiD, ...) must pass their diagnostics before an effect is reported. Output follows the language set in jamovi (English, Chinese, Japanese). Nothing leaves your computer.

Status: first public version. Windows + jamovi 2.x only so far. Not affiliated with the jamovi project.

## Install

1. Install jamovi, and any modules you want, in the normal way.
2. `pip install -r requirements.txt` (Python 3.10+).
3. Register the server. Claude Code: `claude mcp add jamovi -- python D:/path/to/jamovi-ai-workflow/server/server.py`. Claude Desktop: add the same command under `mcpServers` in `claude_desktop_config.json`, then restart.
4. Optional but recommended: upload `dist/jamovi-analysis-workflow.zip` as a skill (Claude Desktop: Settings > Capabilities > Skills). It holds the workflow, routing tables and stop rules.
5. Full guide (what to ask, how to read results, troubleshooting): `docs/USAGE.md`. Sample project with a report: `examples/sample-project/`.
6. Try it: put `examples/rd_scholarship.csv` in a folder and ask "A scholarship goes to students with score x >= 0. y is later earnings. Estimate its effect."

## What you get

- Tables, plots, and LaTeX/CSV files for every analysis; a report (`report.md`, `report.tex`) built from all runs.
- A project folder (01 design ... 08 admin) filled automatically: data profile, R scripts, run log, references, module versions.
- For learners: plain-words explanations and "open menu X, put variable Y here" steps, so each number can be checked by hand in jamovi.
- For causal work: the agent must confirm the design with you, pre-specify, run diagnostics first, and stop and ask when one fails. See `evals/` for how this was tested (12 checks, 6 simulated chats; limits are listed there).

## Limits

Only catalogued analyses run (no arbitrary R). 62 of 227 analyses have not been run automatically (see `docs/SUPPORT_MATRIX.md`). Tested with one model family. The stop rules catch obvious violations; borderline data still needs your judgment. Estimates are only as valid as the design assumptions you confirm.

## License

MIT (see `LICENSE`). Author: Mingchao Sun <mingchao.sun@hotmail.com>. Example data in `examples/` is synthetic.

---

## 中文

让 AI 助手通过本地 MCP 服务器运行你自己电脑上的 jamovi(内置分析与已安装模块)。每次运行都有记录,每个结果都附带可在 jamovi 中逐步复现的点击步骤;因果方法(RD、IV、DiD 等)必须先通过诊断才会报告效应。输出语言跟随 jamovi 的语言设置(英/中/日)。数据不会离开你的电脑。

安装:先安装 jamovi 和所需模块;`pip install -r requirements.txt`;用 `claude mcp add jamovi -- python <路径>/server/server.py` 注册(Claude Desktop 则在 `claude_desktop_config.json` 的 `mcpServers` 中添加同样的命令并重启);建议再上传 `dist/jamovi-analysis-workflow.zip` 作为技能。示例数据在 `examples/`。

局限:目前仅支持 Windows;只能运行目录中收录的分析;停止规则只能发现明显的违反;估计值的有效性取决于你确认的设计假设。许可证:MIT。与 jamovi 项目无隶属关系。

## 日本語

AI アシスタントがローカルの MCP サーバー経由で、お使いの jamovi(標準の分析とインストール済みモジュール)を実行します。すべての実行が記録され、結果ごとに jamovi 上で再現するクリック手順が付きます。因果推論の手法(RD、IV、DiD など)は診断に合格するまで効果を報告しません。出力言語は jamovi の言語設定(英・中・日)に従います。データは PC の外に出ません。

導入:jamovi と必要なモジュールをインストール、`pip install -r requirements.txt`、`claude mcp add jamovi -- python <パス>/server/server.py` で登録(Claude Desktop は `claude_desktop_config.json` の `mcpServers` に同じコマンドを追加して再起動)。`dist/jamovi-analysis-workflow.zip` をスキルとして追加するのがおすすめです。サンプルデータは `examples/` にあります。

制限:現状は Windows のみ。実行できるのはカタログにある分析だけです。停止ルールが検出できるのは明らかな違反だけで、推定値の妥当性は確認した設計の前提に依存します。ライセンス:MIT。jamovi プロジェクトとは無関係です。

---

# Technical reference

## What is here

| Path | Purpose |
|---|---|
| `scripts/jmv_run.R`, `scripts/jmv_lib.R` | Headless runner. One call = one analysis; writes `results.json` (tables, notes, plots as PNG, versions, warnings, errors). |
| `scripts/jmvenv.py` | Finds jamovi's own R and sets the library path the installed modules see. |
| `scripts/gen_catalog.py` | Builds a catalog of every analysis and option of every installed module from `jamovi-full.yaml`. |
| `scripts/smoke_all.py`, `smoke_module.R` | Runs every analysis with auto-filled variables on synthetic data and records what works. |
| `scripts/scaffold.py` | Creates the project folder skeleton with a pre-specification template. |
| `scripts/gen_catalog_docs.py` | Writes the per-module option reference used by the skill. |
| `skills/jamovi-analysis-workflow/` | Agent skill: workflow, routing by design and variable type, diagnostics and stop rules per method, reporting rules. |
| `docs/PLAN.md` | Plan, decisions, results (Chinese). |

## Quick start

```powershell
python scripts\jmvenv.py scripts\jmv_run.R --module jmv --analysis ttestIS --options opts.json --data data.csv --out out
```

`opts.json` holds the analysis options, for example `{"vars":["y1"],"group":"g2","welchs":true}`. Options you do not give take the analysis default; required ones with no default are passed as NULL.

Exit code 0 means the analysis ran. On failure `results.json` is still written, with `status`, `error` and `error_class` (`analysis_error`, `bad_options`, `missing_dependency`, `timeout`, `extraction_error`).

## MCP server

`server/server.py` is a local stdio MCP server (Python, `pip install mcp`). Register it, for example in Claude Code:

```powershell
claude mcp add jamovi -- python D:/path/to/jamovi-ai-workflow/server/server.py
```

Tools: `jamovi_env_check`, `list_modules`, `list_analyses`, `describe_analysis`, `init_project`, `read_dataset`, `run_analysis`, `get_result`, `export_table`, `build_report`.
Each run returns the tables, the plots as images, click-by-click steps to repeat the analysis in the jamovi window, and the equivalent R call, and saves `report.md` plus every table as `.tex` and `.csv` (`05_analysis_output/tables/`).
Every run is stored under `<project>/05_analysis_output/runs/run_NNN_*` (options.json, results.json, plots) and appended to `05_analysis_output/logs/run_log.md`, failed runs included.
Options are checked against the catalog before anything runs (unknown names, types, ranges, allowed values, column names). Data files must be inside the project folder (or a folder listed in `JAMOVI_AI_ALLOW_DIRS`). No arbitrary R code can be run.

## Notes
- Data is read from `.csv` (text columns become factors) or `.omv`.
- Nothing is sent anywhere; everything runs locally in jamovi's own R.
- jamovi and the modules are not included. They are used as installed on your machine.