originpro-mcp
by gabzsi
README.md
# originpro-mcp
Windows MCP (Model Context Protocol) server for OriginPro 2025 automation via the official `originpro` (`OriginExt`) Python package and COM.
## Features
- **Safe COM serialization**: Dedicated worker thread with `pythoncom.CoInitialize()` / `CoUninitialize()`, bounded timeouts, and an unknown-outcome lock hold so mutating calls never overlap.
- **Non-intrusive startup**: `origin_status` never launches OriginPro; `ensure_origin` attaches to a running instance or launches `Origin64.exe` without stealing focus.
- **Lock-free dialog diagnostics**: `get_origin_state` and `get_origin_dialogs` inspect Origin processes and modal dialogs via Win32 without acquiring COM or worker locks. `dismiss_origin_dialogs` only clicks `Cancel`/`Close` (or `OK` if requested) or posts `WM_CLOSE`—never `Save`, `Yes`, or `Delete`.
- **Progress heartbeats**: Long-running tools emit 2-second MCP progress notifications when a `progressToken` is supplied.
- **Bundled Markdown knowledge**: Deterministic heading-aware search and bounded document reader, plus `scripts/update_knowledge.py` to refresh local OriginPro reference manuals into `.local/knowledge/`.
- **PowerPoint OLE export**: `copy_graph_ole` copies a graph to the clipboard as an editable OLE object, and `send_graphs_to_powerpoint` inserts up to 30 graphs as centered, aspect-ratio-preserved OLE slides in Microsoft PowerPoint.
- **Session memory**: Bounded, sanitized JSONL tool-call logging and explicit Markdown session summaries.
## Prerequisites
- **Windows** (COM automation via `originpro` and `pywin32`)
- **Python 3.10+**
- **OriginPro 2025** (or compatible OriginPro installation with Python `originpro` support)
- **Microsoft PowerPoint** (optional, required only for `send_graphs_to_powerpoint`)
## Setup (Windows)
Run the setup script from PowerShell:
```powershell
.\setup.ps1
```
This creates `.venv`, installs `originpro-mcp` in editable mode (`pip install -e .`), builds the local knowledge corpus in `.local/knowledge/` (pass `-SkipKnowledge` to skip), and generates `.local/mcp-config.example.json` and `.local/mcp-config.codex.toml`.
To install into your system Python instead (or specify a custom Python executable):
```powershell
.\setup.ps1 -UseSystemPython
# or
.\setup.ps1 -PythonExe "C:\Path\To\python.exe"
```
## MCP Client Configuration
Add the following to your MCP client configuration (see `.local/mcp-config.example.json` generated by `setup.ps1`):
```json
{
"mcpServers": {
"originpro": {
"command": "C:\\Users\\<you>\\Desktop\\originpro-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "originpro_mcp"],
"env": {
"ORIGIN_TOOL_PROFILE": "full"
}
}
}
}
```
Or run via the installed console script: `originpro-mcp`.
## Environment Variables
| Variable | Default | Description |
| --- | --- | --- |
| `ORIGIN_PRO_EXE` | Auto-detected under `C:\Program Files\OriginLab` | Explicit path to `Origin64.exe` or `Origin.exe`. |
| `ORIGIN_TOOL_PROFILE` | `full` | `full` exposes all tools; `core` hides optional tools (`search_session_memory`, `read_session_memory`, `capture_session`). |
| `ORIGIN_KNOWLEDGE_DIR` | `.local/knowledge` (if `manifest.json` exists) or `knowledge/` | Override directory for Markdown knowledge documents and `manifest.json`. |
| `ORIGIN_SESSION_DIR` | `%LOCALAPPDATA%\originpro-mcp\sessions` | Override directory for JSONL tool-call logs and Markdown session summaries. |
| `ORIGIN_PREFERENCES_PATH` | `%LOCALAPPDATA%\originpro-mcp\preferences.json` | Override path for persistent figure defaults and publication color palettes. |
## Tool Overview (41 tools in `full`, 38 in `core`)
- **Control & Execution**: `ensure_origin`, `origin_status`, `execute_labtalk`, `run_xfunction`, `open_project`, `save_project`, `import_delimited_text`, `import_multiple_files`
- **Inspection & Data**: `inspect_project`, `list_workbooks`, `manage_sheet`, `list_matrices`, `list_columns`, `get_column_data`, `set_column_data`, `read_variable`, `list_windows`, `capture_window`, `get_system_information`
- **Graphing & Analysis**: `create_graph`, `set_graph_axes`, `inspect_graph`, `linear_fit`, `nonlinear_fit`
- **Preferences**: `get_user_preferences`, `set_user_preferences`
- **PowerPoint / OLE Export**: `copy_graph_ole`, `send_graphs_to_powerpoint`
- **Notes**: `list_notes`, `read_note`, `write_note`
- **Dialogs & Diagnostics**: `get_origin_state`, `get_origin_dialogs` (supports `include_uia=True`), `dismiss_origin_dialogs`
- **Knowledge**: `search_origin_knowledge`, `query_origin_help`, `read_origin_document`, `list_origin_guides`
- **Session Memory** (`full` profile): `search_session_memory`, `read_session_memory`, `capture_session`
## Refreshing Local Knowledge Manuals
Run `scripts/update_knowledge.py` to populate or update `.local/knowledge/` with OriginPro reference manuals (queried via `query_origin_help`):
```powershell
.\.venv\Scripts\python.exe scripts\update_knowledge.py
```
## Running Tests
Run the unit test suite (uses mocks for COM/OriginPro so it runs without OriginPro open):
```powershell
.\.venv\Scripts\python.exe -B -m unittest discover -s tests -v
```
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues