Metadata-Version: 2.5
Name: capstone-mcp
Version: 0.1.2
Summary: Cross-platform physics analysis and Windows UI automation MCP for PASCO Capstone
Project-URL: Homepage, https://github.com/ji5zi5/capstone-mcp
Project-URL: Repository, https://github.com/ji5zi5/capstone-mcp
Project-URL: Issues, https://github.com/ji5zi5/capstone-mcp/issues
Project-URL: Documentation, https://github.com/ji5zi5/capstone-mcp/blob/main/docs/usage.md
Author: ji5zi5
License-Expression: MIT
License-File: LICENSE
Keywords: automation,capstone,lab,mcp,pasco,physics
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.12
Requires-Dist: anyio<5,>=4
Requires-Dist: defusedxml<0.8,>=0.7.1
Requires-Dist: httpx2[brotli,http2,zstd]
Requires-Dist: mcp<2,>=1.20
Requires-Dist: pillow>=11
Requires-Dist: psutil<9,>=7
Requires-Dist: pydantic<3,>=2
Requires-Dist: pywin32>=305; sys_platform == 'win32'
Requires-Dist: pywinauto<0.7,>=0.6.9; sys_platform == 'win32'
Requires-Dist: websockets<18,>=15
Description-Content-Type: text/markdown

<!-- mcp-name: io.github.ji5zi5/capstone-mcp -->

<h1 align="center">PASCO Capstone MCP</h1>

<p align="center">Control Capstone experiments and analyze physics data through your AI assistant.</p>

<p align="center">
  <a href="https://pypi.org/project/capstone-mcp/"><img src="https://img.shields.io/pypi/v/capstone-mcp.svg" alt="PyPI"></a>
  <a href="https://registry.modelcontextprotocol.io/v0/servers?search=capstone-mcp"><img src="https://img.shields.io/badge/MCP%20Registry-io.github.ji5zi5%2Fcapstone--mcp-1f6feb.svg" alt="MCP Registry"></a>
  <a href="https://github.com/ji5zi5/capstone-mcp/actions/workflows/ci.yml"><img src="https://github.com/ji5zi5/capstone-mcp/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
  <a href="https://github.com/ji5zi5/capstone-mcp/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
  <img src="https://img.shields.io/badge/python-3.12%2B-blue.svg" alt="Python 3.12+">
</p>

<p align="center"><a href="https://github.com/ji5zi5/capstone-mcp/blob/main/README.md">한국어</a> · <strong>English</strong></p>

<p align="center">
  <a href="#getting-started">Getting started</a> &nbsp;·&nbsp;
  <a href="#example-requests">Example requests</a> &nbsp;·&nbsp;
  <a href="https://github.com/ji5zi5/capstone-mcp/blob/main/docs/usage.md">User guide (Korean)</a> &nbsp;·&nbsp;
  <a href="https://github.com/ji5zi5/capstone-mcp/blob/main/PRIVACY.md">Privacy Policy</a>
</p>

---

PASCO Capstone MCP is an unofficial Model Context Protocol (MCP) server for **operating PASCO Capstone, extracting `.cap`/CSV experiment data, running numerical/spectral analysis, and generating physics lab reports**.

- **Offline file & physics analysis (cross-platform: Windows / macOS / Linux)**: Reading `.cap` archives and CSV files, linear/weighted regression, FFT power spectra, experiment recipes, and Markdown/HTML reports run on any OS without launching Capstone.
- **Live desktop automation (Windows only)**: Window control, file Open/Save/CSV export, graph/calculator automation, and live sensor polling integrate with PASCO Capstone running on Windows.

## What can it do?

| Task | Capabilities |
| :--- | :--- |
| Read saved experiments | Inspect settings, runs, units, and saved graphs in `.cap` files, and parse strict ISO 8601 CSV time axes safely. |
| Analyze measurements | Plot paired samples, run OLS and inverse-variance weighted linear regression, Cook's distance, and Hann/rectangular FFT power spectra. |
| Operate Capstone UI | Inspect windows/controls, capture screenshots, dismiss delayed software update prompts safely, and drive Windows 11 Open/Save/Export dialogs. |
| Displays & calculator | Manage graphs (axes, 23 built-in fits, ownership-checked `Copy Display`), pages/tables/Digits/Scope/FFT layouts, and `CalcEntryWidget` formulas & units. |
| Work with instruments | Poll live sensor/measurement channels over local CDP (`127.0.0.1:9222`), configure rates, timers, or manual samples. (Physical 850/550 equipment requires real-device verification.) |
| Analyze physics experiments | Analyze photoelectric, polarization (Malus's law), RLC, forced oscillation, adiabatic gas, and single/double-slit diffraction (with GUM uncertainty) data, and render Markdown/HTML lab reports. |

## Getting started

### 1. Prerequisites

You need [uv](https://docs.astral.sh/uv/) and an MCP-compatible AI client. (`uvx` provisions Python 3.12+ automatically—no local repository clone required.)

To drive the live desktop app, PASCO Capstone must be installed on Windows. By default the server looks for Capstone at the standard install path below; set `CAPSTONE_EXECUTABLE` to an absolute `.exe` path to override it:

```text
C:/Program Files/PASCO scientific/Capstone/Capstone.exe
```

### 2. Connect your AI client (recommended via PyPI)

Add this entry to the `mcpServers` config of any MCP-compatible client (Claude Desktop, Cursor, Antigravity, etc.) to launch the published `capstone-mcp` PyPI package directly with `uvx`:

```json
{
  "mcpServers": {
    "capstone": {
      "command": "uvx",
      "args": ["capstone-mcp"]
    }
  }
}
```

Apply the configuration or restart the client and verify that the 22 `capstone_*` tools (such as `capstone_file_datasets` and `capstone_manage_graph`) appear. Your client launches the `stdio` server automatically.

<details>
<summary><strong>Custom Capstone executable path (<code>CAPSTONE_EXECUTABLE</code>)</strong></summary>

If PASCO Capstone is installed in a non-default location on Windows, pass `CAPSTONE_EXECUTABLE` in `env`:

```json
{
  "mcpServers": {
    "capstone": {
      "command": "uvx",
      "args": ["capstone-mcp"],
      "env": {
        "CAPSTONE_EXECUTABLE": "D:/Apps/PASCO/Capstone/Capstone.exe"
      }
    }
  }
}
```

</details>

<details>
<summary><strong>Using Streamable HTTP instead</strong></summary>

Run the HTTP server from a terminal:

```powershell
uvx --from capstone-mcp capstone-mcp-http
```

Register `http://127.0.0.1:8766/mcp` as the MCP server URL in your client and keep the terminal running. The server listens strictly on local loopback (`127.0.0.1`). See the [user guide (Korean)](https://github.com/ji5zi5/capstone-mcp/blob/main/docs/usage.md#http-연결) for details.

</details>

<details>
<summary><strong>Running from a local clone (for developers)</strong></summary>

Clone the repository, install dependencies, and point your MCP client to the local folder with `--directory`:

```powershell
git clone https://github.com/ji5zi5/capstone-mcp.git
cd capstone-mcp
uv sync --python 3.12
```

```json
{
  "mcpServers": {
    "capstone": {
      "command": "uv",
      "args": [
        "--directory", "C:/Projects/capstone-mcp",
        "run", "--no-sync", "capstone-mcp"
      ]
    }
  }
}
```

</details>

### 3. Try your first request

Ask your assistant to inspect a local experiment file:

> Show me the datasets in `C:/Experiments/momentum.cap`, including their names, unit information, and sample counts.

To operate the live app on Windows, open an experiment in Capstone and ask: “Connect to the running Capstone app and show me its current windows.”

## Example requests

- **Saved experiment** — “Show the runs and units, then give me the first 20 paired time and velocity samples from a recorded run.”
- **Graphs** — “Read the axes, run and fit coefficients from the second saved graph.” When changing an open graph, observe the window first and verify native fit status afterward.
- **Export before saving** — “Export this experiment to a new file, `C:/Experiments/current.csv`, and show the first 20 rows.”
- **Polarization / diffraction** — “Fit Malus’s law (`cos²θ`) to my angle (`deg`) and intensity arrays and generate an HTML lab report.”
- **Live readings** — “Read the current value and unit from the connected force sensor.” Live measurement polling requires the Capstone process to expose the local debugging port. [Setup in Korean](https://github.com/ji5zi5/capstone-mcp/blob/main/docs/usage.md#실시간-조회)

## Things to know

- UI automation may bring Capstone to the foreground. Use an unlocked Windows desktop and avoid simultaneous control from multiple clients. Pass `--no-sync` to `uv run` if another background `capstone-mcp` process holds a lock on Windows.
- Saving and exporting never overwrite existing files. CSV exports follow Capstone's display precision; extract from `.cap` archives when full stored numerical precision is required.
- Read saved graphs directly from `.cap` files. For unsaved graphs, the server verifies clipboard ownership and generation around native `Copy Display` and restores prior clipboard formats.
- Sensorless live workflows are verified on PASCO Capstone `2.13.4` + Windows 11, while custom-rendered `.PageView` Table/Digits internals and physical PASCO 850/550 hardware acquisition remain bounded by UIA exposure and hardware availability.

Detailed tool references and troubleshooting are in the **[user guide (Korean)](https://github.com/ji5zi5/capstone-mcp/blob/main/docs/usage.md)**.

## Development & checks

```powershell
uv run --no-sync ruff check src tests
uv run --no-sync basedpyright src
uv run --no-sync pytest -q
```

## Privacy Policy

`capstone-mcp` executes strictly on your local machine without telemetry or third-party data transmission. See [PRIVACY.md](https://github.com/ji5zi5/capstone-mcp/blob/main/PRIVACY.md) for details.
