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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.png binary
*.ico binary
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm test
- run: npm run build
- name: End-to-end with the synthetic camera
run: node scripts/e2e.mjs --fake
- uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-output
path: test-output/fake
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
dist/
release/
.worktrees/
*.log
.DS_Store
test-output/
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# Electroscope
Electronics microscope companion: live camera viewer for humans, on-demand snapshots for AI over MCP.

<p align="center"><img src="build/icon-256.png" alt="Electroscope icon" width="128" /></p>

A live viewer for your electronics microscope that Claude can look through, over MCP.

A camera can usually be opened by one app at a time. If you are watching the microscope, Claude cannot also have a stream. Electroscope owns the camera, shows you the live view in a native window, and hands Claude still frames only when it asks. You keep looking at your board; Claude can still look at it too.

![Electroscope showing an ESP32 module, with the frames Claude has captured](docs/screenshot.png)

## What you get

- **Live view** with wheel-zoom, drag-pan, grid and crosshair overlays, freeze, rotate and mirror, and a live **sharpness meter** to find best focus.
- **Every camera on the machine**, listed and switchable. Hardware controls (focus, zoom, exposure and so on) appear when the camera supports them.
- **An MCP server** with tools to capture a frame, take a sequence, crop a full-resolution close-up of any region, look at exactly what you have zoomed to, and adjust the camera.
- **Visible and in your control.** A switch pauses Claude's access. Every frame Claude takes shows up in a strip under the viewer, and the live view flashes when it captures.
- **Share with Claude**: pin a frame with a note ("U3 gets hot right after power-on") and ask Claude to look at it.

## Install and run

Electroscope is an Electron app. Windows 11 is the primary target; macOS builds from the same code.

```bash
git clone https://github.com/UnlikeOtherAI/Electroscope.git
cd Electroscope
npm install
npm start
```

Then connect Claude Code:

```bash
claude mcp add --transport http electroscope http://127.0.0.1:47821/mcp
```

Ask Claude something like "look at the board under the microscope and tell me if the solder joints on U2 look bridged". See [docs/mcp.md](docs/mcp.md) for the tools, arguments and security model, and for connecting other clients.

If the app says the camera is busy, another program has it. Close the Windows Camera app, Teams, or a browser tab using the camera. Electroscope keeps retrying and connects as soon as it is free.

### Build a package

```bash
npm run dist # unpacked app in release/win-unpacked
npm run dist:installer # NSIS installer and portable exe
```

Builds are unsigned.

## Develop

```bash
npm run typecheck
npm test # unit tests for the MCP server, transport, settings and bridge
npm run test:e2e # launches the app and drives it over MCP with your real camera
node scripts/e2e.mjs --fake # same, with Chromium's synthetic camera (what CI runs)
npm run icons # re-render build/icon.* from build/icon.svg
```

The end-to-end script writes the app window and every image Claude would receive to `test-output/`.

How it fits together:

- `src/main`: Electron main process and the MCP server (`mcp/tools.ts` defines the tools, `mcp/http.ts` is the Streamable HTTP transport).
- `src/renderer`: the window. It owns the camera, draws the live view, and answers capture and control requests from the main process.
- `src/shared`: types and IPC channel names used by both.

## Status

Tested on Windows 11 with a UVC microscope camera (end to end over MCP, 16 checks) and with the synthetic camera. The macOS build is configured but has not been run on a Mac yet.

## License

[MIT](LICENSE)
10 changes: 10 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
</dict>
</plist>
Binary file added build/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icon.ico
Binary file not shown.
Binary file added build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions build/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions docs/mcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Electroscope MCP reference

Electroscope runs an MCP server inside the app, over Streamable HTTP, on `http://127.0.0.1:47821/mcp`.
If that port is taken it tries the next nine; the live address is always shown in the app. You can change the port in Settings.

The app owns the camera. Claude never opens it, so the live view in the window keeps running while Claude asks for stills.

## Connect a client

```bash
# Claude Code
claude mcp add --transport http electroscope http://127.0.0.1:47821/mcp
```

Any client that speaks Streamable HTTP can use the same URL. For clients that only launch local stdio servers (Claude Desktop), bridge it:

```json
{
"mcpServers": {
"electroscope": { "command": "npx", "args": ["-y", "mcp-remote", "http://127.0.0.1:47821/mcp"] }
}
}
```

## Tools

| Tool | What it does |
| --- | --- |
| `get_status` | Active camera, resolution, fps, orientation, live focus score, adjustable controls with ranges, and whether the human has paused Claude. Works even while paused. |
| `list_cameras` | Rescans and lists every camera on the machine. Works even while paused. |
| `capture_snapshot` | One still frame, returned as an image plus metrics and hints. |
| `capture_sequence` | 2-6 frames at a fixed interval, to watch an LED blink or a part heat up. |
| `select_camera` | Switch the live view to another camera, optionally at a given resolution. |
| `set_camera_controls` | Set focus, zoom, exposure, brightness and so on, where the camera supports them. |
| `set_orientation` | Rotate (0/90/180/270) and/or mirror. Affects the human's view and Claude's captures. |
| `get_shared_frames` | Frames the human pinned with **Share with Claude**, with their notes. |

### `capture_snapshot` arguments

| Argument | Default | Meaning |
| --- | --- | --- |
| `camera` | active camera | Camera id or part of its name. A non-active camera is opened just long enough for one frame. |
| `max_width` | 1280 | Longest-edge budget in pixels (160-3840). Never upscales. |
| `format` | `jpeg` | `jpeg` or `png`. |
| `quality` | 85 | JPEG quality (30-100). |
| `region` | whole frame | `{x, y, width, height}`, normalised 0..1 in the oriented frame. The crop is taken from the full-resolution frame, so a small region is a real close-up, not an upscale. |
| `follow_user_view` | false | Capture exactly the area the human has zoomed and panned to in the window. Overrides `region`. |

The text part of the result carries:

- `focus_score`: variance of the Laplacian on a normalised copy of the image. Higher is sharper. Compare scores of the same scene, not across scenes.
- `brightness` (0-255), `overexposed_fraction`, `underexposed_fraction`.
- `source_resolution`, `region`, `orientation`, `captured_at`, `saved_to` (the file on disk).
- `hints`: plain-language warnings such as blown highlights, a dark image, or very low focus.

### Controls

`get_status` lists the controls the camera exposes, for example `focusMode`, `focusDistance`, `zoom`, `exposureMode`, `exposureTime`, `brightness`, `contrast`, `saturation`, `sharpness`, `colorTemperature`, `torch`. Setting a manual value (`focusDistance`, `exposureTime`, `colorTemperature`) switches the matching mode to manual first.

Many inexpensive UVC microscope cameras accept a control without applying it. Electroscope reads the value back; if the camera ignored the change, the tool reports that in `rejected` and marks the control `"responsive": false` in `get_status`.

## What the human controls

- **Claude access** switch (also the pill in the title bar). When off, every tool except `get_status` and `list_cameras` returns an error telling Claude to ask the human to resume.
- **Claude's view** strip lists every frame Claude captured, with time, camera and size. Click a frame to open the saved file. A coral ring and flash show on the live view whenever Claude captures.
- **Share with Claude** pins the current frame (or the zoomed view) with a note. Claude picks it up with `get_shared_frames`.

## Security model

- The server binds to `127.0.0.1` only.
- Requests whose `Host` is not localhost, or whose `Origin` is not a localhost origin, get `403`. This blocks DNS-rebinding and drive-by requests from web pages.
- Only the app's bundled page can use the camera. The renderer is sandboxed with context isolation and a strict content security policy.
- Claude's captures are saved under the app data folder (`%APPDATA%\Electroscope\captures` on Windows) and pruned to the newest 200. Frames you shared are kept separately. Photos you save yourself go to `Pictures\Electroscope`.
- There is no authentication token. Anything running as you on this machine can reach the port. Pause Claude access when you do not want frames available.
Binary file added docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading