Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
# The MCP server must import on a core-only install (the camera and
# SDK stacks are lazy imports) - fail the build if that regresses.
# (tests/test_mcp_server.py goes further and actually runs it.)
- run: python -c "import mcp_server.server_loop, timelapse.scheduler"
- run: python -c "import mcp_server.baumer_ti2.baumer_ti2_server, timelapse.scheduler"
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,60 @@ Format follows [Keep a Changelog](https://keepachangelog.com/); versions follow

## [Unreleased]

### Removed
- Everything NIS-Elements. The `nis-elements-mcp` package (with its history)
moved to [BioNanomics/nis-elements-mcp](https://github.com/BioNanomics/nis-elements-mcp),
under `bridge/`. Gone from here: `packages/`, `mcp_server/nis/`,
`acquisition/_nis_settings.py`, `acquisition/nis_events.py`,
`acquisition/nis_monitor.py`, `acquisition/backends/nis_bridge.py`,
`acquisition/calibration/nis_port_probe.py`, `docs/nis-bridge.md`, the
`confocal-mcp-nis` command and the package's CI job. `nis_sdk.py` and
`nis_mock.py` stay: they drive the Ti2 stage, not NIS-Elements.
- `acquisition/estop.py` and `acquisition/estop_panel.py` are real modules
again (not forwarders to the package), with their tests in `tests/`. They
keep the same e-stop file (`NIS_ESTOP_FILE`, else `~/.nis-mcp/ESTOP`) and
panel mutex as nis-elements-mcp, so one STOP still stops both. A stop left
in the pre-2026-10-30 file `~/.confocal-mcp/ESTOP` is no longer moved over.

### Changed
- The two MCP servers now live in folders named after what they drive:
`mcp_server/baumer_ti2/` (`baumer_ti2_server.py`, `baumer_ti2_tools.py`;
was `server_loop.py`, `loop_tools.py`) and `mcp_server/nis/`
(`nis_server.py`, `nis_tools.py`; was `server_nis.py`, `nis_tools.py`).
New commands `baumer-ti2-mcp` and `nis-mcp`; the old `confocal-mcp` and
`confocal-mcp-nis` still work. Tool names are unchanged.
- The NIS-Elements MCP server is now its own package, `nis-elements-mcp`, in
`packages/nis-elements-mcp/` (server, tools, bridge client, bridge job,
e-stop and STOP panel, event log, monitor, and their tests). This repo
depends on it from that folder. The old modules (`acquisition/estop.py`,
`acquisition/nis_*.py`, `acquisition/backends/nis_bridge.py`,
`acquisition/nis_bridge/bridge_job.py`, `mcp_server/nis/`) forward to the
package, so imports and `python -m` commands are unchanged; this repo keeps
its NIS logs and captures in `logs/nis` and `data/NIS/captures`.
**Paste `packages/nis-elements-mcp/src/nis_elements_mcp/nis_bridge_job.py`
into the NIS JOBS task from now on.** `nis-mcp` now comes from the package.
- `nis-elements-mcp` reads all its settings from `NIS_*` environment variables
(`settings.py`): `NIS_BRIDGE_HOST/PORT`, `NIS_CAPTURE_DIR`, `NIS_LOG_DIR`,
`NIS_ESTOP_FILE`, `NIS_ALLOWED_OBJECTIVES` (default 4,10),
`NIS_ALLOWED_EXPERIMENTS` (new: optional list of ND experiment names),
`NIS_MAX_STEP_UM` (default 1000), `NIS_NO_ESTOP_PANEL`, `NIS_NO_MONITOR`.
The limits are now also checked in the client before a request is sent.
**The e-stop file moved to `~/.nis-mcp/ESTOP`** for every process here and
for the bridge job; a stop engaged in the old `~/.confocal-mcp/ESTOP` is
moved there on first start. The old `CONFOCAL_*` switch names still work
in this repo. `nis_port_probe.py` no longer hard-codes a user path.
- `nis-elements-mcp` 0.1.0 has its own README (setup in NIS, install into
another project, safety rules, settings), CHANGELOG and MIT LICENSE, and the
commands `nis-mcp-bridge` (with `job-file`), `nis-mcp-estop` and
`nis-mcp-monitor`. CI installs the package on its own and tests it on
Windows and Ubuntu.

### Removed
- `acquisition/nis_bridge/` (the old `bridge_job.py` forwarder). It looked
like the bridge job but failed inside NIS when pasted. The only bridge job
is now `packages/nis-elements-mcp/src/nis_elements_mcp/nis_bridge_job.py`
(`nis-mcp-bridge job-file` prints the path).

### Added
- `analysis/worm_short.py` - C. elegans Short from an AML18 time-lapse
surveyed by `aml18_survey`: neurons-only opening, brightfield with RFP glow,
Expand Down
50 changes: 16 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ identifying that specific capture.

`backend` is `"mock"` (default, safe, simulated) or `"sdk"` (real
hardware - `move()`/`get_image()` require `confirm=True` for anything
that touches real hardware). See `mcp_server/loop_tools.py`'s header
that touches real hardware). See `mcp_server/baumer_ti2/baumer_ti2_tools.py`'s header
comment for the full design rationale (why no `get_time()`, why no
`stage_revision` yet, etc.).

Expand All @@ -69,31 +69,13 @@ python -m timelapse.scheduler --backend mock --model-trigger ... # Claude judg
python -m timelapse.frame_audit FRAME_DIR --timestamps times.csv --around 25h --window 1h
```

## NIS bridge (`confocal-mcp-nis`) - not yet tested on the scope
## NIS-Elements

A separate MCP server for what only NIS-Elements can do: the AX confocal
lasers and saved ND experiments. A JOBS Python task inside NIS
(`acquisition/nis_bridge/bridge_job.py`) serves NIS macro calls on
`127.0.0.1:8766`. The `confocal-mcp-nis` server talks to it and adds a
confirm gate, the e-stop and a capture-folder rule. `server_loop` is
unchanged. Setup, safety rules and the on-scope test plan:
[docs/nis-bridge.md](docs/nis-bridge.md).

```
python -m acquisition.backends.nis_bridge status # by hand, while the bridge job runs
python -m acquisition.nis_monitor # live view: status + every action (logs/nis/)
confocal-mcp-nis # the MCP server
python -m mcp_server.server_nis # same, from a source checkout
```

MCP client config for a source checkout (adjust the path to this repo's venv):

```json
{ "mcpServers": { "confocal-nis": {
"command": "D:\\path\\to\\microscope-agent\\.venv\\Scripts\\python.exe",
"args": ["-m", "mcp_server.server_nis"],
"cwd": "D:\\path\\to\\microscope-agent" } } }
```
Not in this repo. The MCP servers for NIS-Elements (the AX confocal lasers,
saved ND experiments) live in
[BioNanomics/nis-elements-mcp](https://github.com/BioNanomics/nis-elements-mcp).
They share this repo's e-stop file (`NIS_ESTOP_FILE`, else `~/.nis-mcp/ESTOP`)
and STOP panel, so one STOP button stops both.

## Tests

Expand Down Expand Up @@ -148,24 +130,24 @@ machine. Not needed for `backend="mock"`.
## Run

```
confocal-mcp # installed console script
python -m mcp_server.server_loop # equivalent, from a source checkout
baumer-ti2-mcp # installed console script (old name: confocal-mcp)
python -m mcp_server.baumer_ti2.baumer_ti2_server # equivalent, from a source checkout
```

Point an MCP client at it - Claude Desktop's `claude_desktop_config.json`, or a
project-level `.mcp.json` for Claude Code:

```json
{ "mcpServers": { "confocal": { "command": "confocal-mcp" } } }
{ "mcpServers": { "baumer-ti2": { "command": "baumer-ti2-mcp" } } }
```

Data (captures, move/frame history logs, saved positions) is written under the
current working directory - so launch the server from a stable location, or set
`CONFOCAL_MCP_DATA_DIR` to pin it explicitly:

```json
{ "mcpServers": { "confocal": {
"command": "confocal-mcp",
{ "mcpServers": { "baumer-ti2": {
"command": "baumer-ti2-mcp",
"env": { "CONFOCAL_MCP_DATA_DIR": "D:\\path\\to\\your\\data" }
} } }
```
Expand All @@ -180,8 +162,8 @@ stderr rather than failing at the first capture.

A second, independent way to drive the same tools - a small interactive
CLI that calls Claude (Anthropic API) directly with tool use, importing
`mcp_server/loop_tools.py`'s functions in-process rather than going
through `server_loop.py`'s MCP/stdio protocol. `server_loop.py` is
`mcp_server/baumer_ti2/baumer_ti2_tools.py`'s functions in-process rather than going
through `baumer_ti2_server.py`'s MCP/stdio protocol. `baumer_ti2_server.py` is
unaffected either way - use whichever fits: MCP for Claude Desktop/Code,
this loop for a standalone script.

Expand All @@ -203,8 +185,8 @@ python -m harness.agent
## MCP client harness (`harness/mcp_agent.py`)

A third way to drive the same tools - the real-MCP-protocol counterpart
to `harness/agent.py`. Instead of importing `loop_tools.py` in-process,
this one spawns `server_loop.py` as a separate subprocess and talks to
to `harness/agent.py`. Instead of importing `baumer_ti2_tools.py` in-process,
this one spawns `baumer_ti2_server.py` as a separate subprocess and talks to
it exactly the way Claude Desktop/Code do: real MCP over stdio, using
the current MCP SDK (`mcp==2.0.0`, protocol version `2026-07-28`). Same
`.env`/`ANTHROPIC_API_KEY` setup, same live "y/N" real-hardware approval
Expand Down
4 changes: 2 additions & 2 deletions acquisition/backends/baumer_genicam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#
# 2026-08-17: now the PRIMARY capture path by deliberate decision - the
# team decided against capturing through NIS-Elements/Jobs at all (see
# mcp_server/loop_tools.py's header comment), so this module's capture()
# is what mcp_server.loop_tools.get_image() actually calls. Whatever is
# mcp_server/baumer_ti2/baumer_ti2_tools.py's header comment), so this module's capture()
# is what mcp_server.baumer_ti2.baumer_ti2_tools.get_image() actually calls. Whatever is
# optically coupled to wherever this camera is physically mounted is
# what gets captured - that's a hardware/alignment decision made outside
# this code, not something this module controls.
Expand Down
163 changes: 0 additions & 163 deletions acquisition/backends/nis_bridge.py

This file was deleted.

4 changes: 2 additions & 2 deletions acquisition/backends/nis_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# So: X/Y properties are in units of 0.1um ("decimicrons"), Z is in units
# of 0.01um ("centimicrons"). XY_GetPosition/XY_Move/Z_GetPosition/Z_Move
# below convert to/from plain microns at their boundary so callers
# (StagePositionManager, mcp_server/loop_tools.py) never see raw counts.
# (StagePositionManager, mcp_server/baumer_ti2/baumer_ti2_tools.py) never see raw counts.
# ------------------------------------------------------------

import queue
Expand Down Expand Up @@ -170,7 +170,7 @@ class NISSdk:

Every instance shares the same underlying COM connection (see
_ComThread above) - constructing NISSdk() repeatedly (once per MCP
tool call, as mcp_server/loop_tools.py does) is cheap and does not open a
tool call, as mcp_server/baumer_ti2/baumer_ti2_tools.py does) is cheap and does not open a
new connection each time.
"""

Expand Down
Loading
Loading