Skip to main content
Glama
README.md
# Prism Windows MCP

[![CI](https://github.com/Yinghao-Fang/prism-windows-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/Yinghao-Fang/prism-windows-mcp/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Python 3.12 | 3.13](https://img.shields.io/badge/python-3.12%20%7C%203.13-3776AB.svg)](pyproject.toml)
[![Platform: Windows 10/11](https://img.shields.io/badge/platform-Windows%2010%2F11-0078D4.svg)](#requirements)

**Connect an MCP client to native GraphPad Prism 11.2 tables, statistics, graphs, layouts and exports on Windows.**

Prism Windows MCP is a local stdio server for **GraphPad Prism 11.2.0 build 346 on 64-bit Windows**. It supplies original observations, asks Prism to create and recalculate the native objects, verifies the saved archive, and exports figures through Prism itself. Prism does the statistics and the drawing; this server drives it and proves what happened.

The port keeps the native-object contract of the macOS `Prism Native MCP`: UUIDs from `prism_inspect`, revision hashes, run IDs, serialized mutations, quarantine after uncertain native execution, and evidence-based recovery.

- **Prism writes every document.** This server composes Prism scripts (`.pzc`), dispatches them through `prism.exe @"script"`, verifies Prism's own terminal log plus a per-run token, then reopens the resulting `.prism` archive read-only to check tables, analyses, graphs and layouts.
- **One seed, native families.** New documents start from a Windows-normalized Prism-created two-group Column seed and grow through `DuplicateFamily`, so every table keeps a bound violin graph and descriptive analysis.
- **All science is native.** No Python statistics engine substitutes for Prism, and plotted coordinates are never treated as observations.

![Architecture: MCP client to prism-windows-mcp to Prism, with a verification loop](docs/images/architecture.svg)

## Requirements

- **Windows 10 or 11 (x64).**
- **GraphPad Prism 11.2.0 build 346**, installed and licensed separately. The default probe is `D:\Prism\prism.exe`; `PRISM_MCP_APP` selects another installation of the same build.
- **Python 3.12 or 3.13** and [uv](https://docs.astral.sh/uv/).
- An MCP client that launches a local stdio server.
- Prism may already be running. The server uses the running instance (Prism's single-instance launcher forwards scripts to it) or starts it when needed.

No network service and no LLM dependency. Data returned through MCP is visible to the connected client.

### Other Prism versions

The native contract is accepted on **11.2.0 build 346** and the server refuses other builds by default. If you have a nearby build and accept the risk, set `PRISM_MCP_ALLOW_UNTESTED_VERSION=1`; `prism_capabilities` then reports `version_gate: "untested_override"`. Archive version checks still fail closed, and the unported UI tools stay unavailable. See [docs/PUBLISHING.md](docs/PUBLISHING.md) for the version policy.

## Install and connect

```powershell
cd C:\Tools\prism-windows-mcp
uv sync
uv run prism-windows capabilities
```

Configure the client to launch the installed server. With `uv`:

```json
{
  "mcpServers": {
    "prism-windows": {
      "command": "uv",
      "args": ["--directory", "C:\\Tools\\prism-windows-mcp", "run", "prism-windows-mcp"]
    }
  }
}
```

Or launch the project launcher directly:

```json
{
  "mcpServers": {
    "prism-windows": {
      "command": "C:\\Tools\\prism-windows-mcp\\bin\\prism-windows-mcp.cmd"
    }
  }
}
```

Call **`prism_capabilities` first**. Installed application, running instance, transport, and historical verification are separate states.

Diagnostic CLI:

```powershell
uv run prism-windows capabilities
uv run prism-windows inspect D:\data\experiment.prism --values
uv run prism-windows status <run_id>
```

## Create a document

`prism_create_document` needs a **new absolute `.prism` path in an existing directory** and one to sixteen two-group observation tables. Each group needs at least three numeric observations.

```json
{
  "path": "D:\\data\\example.prism",
  "tables": [
    {
      "name": "Synthetic example",
      "units": "a.u.",
      "columns": [
        {"label": "Control", "values": [1.5, 2.0, 3.25, 4.0]},
        {"label": "Treated", "values": [2.0, 3.5, 4.25, 5.0]}
      ]
    }
  ],
  "layout": true
}
```

This creates one native Column table, a bound violin graph, a descriptive-statistics analysis, and an optional grid layout. `layout: true` also produces a one-cell overview layout.

| Tool | Next step |
| --- | --- |
| `prism_inspect` | List native table, analysis, graph and layout UUIDs and relationships from the last saved archive. |
| `prism_read_table` / `prism_read_analysis` | Read saved observations or full-precision analysis results. |
| `prism_update_table` | Replace a table by UUID; linked analyses and layouts are recalculated and verified. |
| `prism_export` | Export every graph and layout to a fresh directory as PDF, SVG and/or PNG. |
| `prism_export_table` | Copy the exact saved observations of one table to CSV. |
| `prism_operation_status` | Check a run ID if completion is uncertain. |

## Tools

27 tools keep the upstream surface. 20 are fully script-backed on Windows.

| Group | Tools |
| --- | --- |
| Diagnostics | `prism_capabilities`, `prism_discover`, `prism_operation_status`, `prism_request_cancellation`, `prism_recover` |
| Inspection | `prism_inspect`, `prism_read_table`, `prism_read_analysis` |
| Document lifecycle | `prism_open_document`, `prism_save_document`, `prism_close_document` |
| Creation and mutation | `prism_create_document`, `prism_add_table`, `prism_update_table`, `prism_recalculate`, `prism_create_layout`, `prism_configure_analysis` |
| Graph and export | `prism_format_graph`, `prism_export`, `prism_export_table` |
| UI-dialog tools (not available on Windows in this release) | `prism_format_native_graph`, `prism_create_graph`, `prism_place_graph`, `prism_align_layout`, `prism_compose_overlay_layout`, `prism_resize_object`, `prism_annotate_layout` |

The seven dialog tools return `NATIVE_ADAPTER_UNAVAILABLE` without dispatching a partial operation. Script-backed formatting and grid layouts cover the repeatable workflow.

## Windows behavior

**An open document is refused for mutation.** Prism exposes no reliable saved/edited flag, so the server cannot prove an open document is saved. Every mutating tool reports `UNSAVED_CHANGES` until the document is saved and closed. Read-only inspection still works against the last saved archive, so unsaved edits in the open window are not visible. Use `prism_save_document` or `prism_close_document` explicitly.

**Controlled save and close preserve edits.** A script `Close` discards unsaved changes silently on Windows. `prism_save_document` saves and closes the target before verification; `prism_close_document` saves the current native state first. Neither publishes a partial result.

**Paths and text use the Windows ANSI code page in scripts.** Scripts are staged under `%LOCALAPPDATA%\PrismMCP\state` (ASCII), and the runtime writes them in the system code page so Prism decodes non-ASCII titles and paths correctly. Verified with Chinese document paths, table names, column labels and graph titles on this build.

**Native UI dialogs are not guessed.** Classic-graph dialogs, marquee grouping, OCR annotation and Resize depend on macOS Accessibility semantics. The Windows port does not invent control identities for them; those tools fail closed.

**Prism's terminal evidence is byte-identical to macOS.** Completion requires Prism's log to end with `COMPLETE! No Errors.` and the run token file to match. A script error is reported with Prism's log tail; an uncertain timeout quarantines later mutations until `prism_recover` verifies terminal evidence.

## Preserve documents and recover safely

Work on owned copies. Mutations share an operation lock and refuse an open target. Every run writes durable records under `%LOCALAPPDATA%\PrismMCP\state\runs\<run_id>`: the exact script, Prism's log, the completion token, expected-output hashes, checkpoints and the operation result.

A timeout can leave native work running. Preserve run IDs; check `prism_operation_status` and matching native evidence before retrying. `prism_recover` clears quarantine only when the recorded log, token and script fingerprint prove the script terminated; it never retries a mutation or marks it successful.

## Verification on this machine

Live acceptance against GraphPad Prism **11.2.0 (346)** at `D:\Prism\prism.exe`:

| Check | Result |
| --- | --- |
| Open macOS-authored seed in Windows Prism | opened, recalculated, saved as format `1-6-2` |
| `prism_create_document`, 2 tables + layout | 2 tables, 2 graphs, 2 analyses, 1 layout; exact observation match |
| `prism_add_table` | 1 new table, graph and analysis; existing tables unchanged |
| `prism_update_table` | exact numeric values; analyses and layouts preserved |
| `prism_create_layout` (1x3) | 3 linked graphs in one native layout |
| `prism_format_graph` | script-backed title/axis/limit path completed; observations unchanged |
| `prism_configure_analysis` | confidence 95, 10 significant digits; Prism reopened and recalculated |
| `prism_export` | PDF/SVG/PNG for 2 graphs and 1 layout (9 files, valid signatures) |
| `prism_export_table` | exact CSV bytes and saved precision |
| `prism_save_document` / `save_as` / `open` / `close` | verified through Prism window state and file hashes |
| Chinese document path, table/column/graph titles | created, inspected, opened and closed |
| MCP stdio `initialize` + `tools/list` | 27 tools returned |

Offline test suite: `uv run pytest` (11 passed, 1 live test skipped). The live acceptance test runs only with `PRISM_MCP_LIVE=1`.

<img src="docs/images/export-example.png" width="520" alt="Example native Prism layout exported through the MCP">

*Synthetic two-group data: one native Prism layout exported as PNG by `prism_export`. The graph, the statistics and the layout were produced and rendered by Prism; the server only supplied observations and verified the result.*

## Architecture and evidence

- `src/prism_windows_mcp/runtime.py` — Windows transport: app discovery, process/window observation, `.pzc` dispatch, terminal evidence, lock, quarantine, recovery.
- `backend.py` — the native operation contract (unchanged science logic from the macOS MCP; Windows lifecycle adjustments for open documents).
- `archive.py` — read-only `.prism` archive verification (`1-6-1` and `1-6-2`, `PCFFGRA4` classic graph payloads, CRC and JSON hardening).
- `analysis_settings.py` — the one byte-level repack (descriptive parameters) that Prism then reopens and recalculates.
- `native_style.py`, `native_ui.py`, `placement.py` — explicit Windows boundaries that fail closed.

Reverse-engineering and reconstruction records are under [`docs/`](docs/):

- [`docs/upstream-analysis.md`](docs/upstream-analysis.md) — upstream macOS MCP port specification.
- [`docs/rea-playbook.md`](docs/rea-playbook.md) — REA usage and provider reality on this machine.
- [`docs/reference/prism-script-commands.txt`](docs/reference/prism-script-commands.txt) — the installed Prism script reference card as text.
- [`docs/recognition/REA-EVIDENCE.md`](docs/recognition/REA-EVIDENCE.md) — REA static evidence captured from `D:\Prism`.
- [`docs/recognition/CRAFT-ANYTHING-EVIDENCE.md`](docs/recognition/CRAFT-ANYTHING-EVIDENCE.md) — Craft Anything deep-mode analysis.
- [`docs/RECONSTRUCTION.md`](docs/RECONSTRUCTION.md) — what was reconstructed and how it was checked.
- [`docs/CAPABILITIES.md`](docs/CAPABILITIES.md) — exact supported operations and limits.
- [`docs/OPERATIONS.md`](docs/OPERATIONS.md) — document-state rules, evidence, quarantine, recovery.
- [`docs/PUBLISHING.md`](docs/PUBLISHING.md) — GitHub/PyPI release steps and version policy.
- [`docs/VERIFICATION.md`](docs/VERIFICATION.md) — dated acceptance record.

## Development

```powershell
uv sync
uv run pytest
uv run prism-windows capabilities
```

Live acceptance (scratch document):

```powershell
$env:PRISM_MCP_LIVE = "1"
$env:PRISM_MCP_LIVE_TARGET = "D:\prism-test\acceptance.prism"
uv run pytest tests/test_live_acceptance.py -s
```

## Independence and license

This is an independent integration. It requires a separately licensed GraphPad Prism and is not affiliated with or endorsed by GraphPad Software. No Prism executable, license or vendor archive is distributed here. The bundled seed is a maintainer-created synthetic document normalized by Prism 11.2 on Windows.

Project source is MIT-licensed. GraphPad Prism and its dependencies retain their own terms.