explaingit

ghollyer/amadeus

2PythonAudience · researcherComplexity · 5/5ActiveSetup · hard

TLDR

MCP server that lets an AI agent drive an electron microscope, moving the stage, taking images, and running spectrum imaging through a ZMQ bridge.

Mindmap

mindmap
  root((AMADEUS))
    Inputs
      MCP commands
      Stage moves
      Image requests
    Outputs
      NumPy images
      JSON metadata
      Analysis results
    Use Cases
      Automate STEM
      Run EDS maps
      Remote control
    Tech Stack
      Python
      ZMQ
      DigitalMicrograph

Things people build with this

USE CASE 1

Let an AI agent automate STEM imaging and EDS quantification on an electron microscope

USE CASE 2

Run focus, magnification, and stage moves from MCP tool calls instead of clicking the vendor GUI

USE CASE 3

Capture and store images with metadata for later FFT and segmentation analysis

USE CASE 4

Operate the microscope side through dm_gui.py when no agent is in the loop

Tech stack

PythonZMQMCPNumPy

Getting it running

Difficulty · hard Time to first run · 1day+

Needs a real microscope VM running DigitalMicrograph plus a separate client computer, with ZMQ between them on port 9876.

In plain English

AMADEUS, short for Addressable Microscope And Detector Experiment Unified Scripting, is a Python project for driving an electron microscope from an AI agent or other MCP client. It exposes microscope automation as a set of MCP tools, so a language model that speaks the Model Context Protocol can move the stage, take images, run spectrum imaging experiments, and analyse the results, instead of a human clicking around in the vendor software. The code is split into two runtime components. The client side runs on the operator's control computer and is the actual MCP server that the AI agent talks to. It holds the experiment state, an image store, a map of points of interest, an experimental plan, operational preferences, and analysis routines such as FFT, lattice spacing extraction, and segmentation. The dm_server side runs inside the microscope vendor's own Python environment, on the computer wired to the instrument. It is intentionally stateless: it receives one command, calls the matching helper for the microscope, stage, camera, STEM detector, spectrum imaging unit, EDS detector, or local file system, and returns either JSON metadata or a raw NumPy image. The two sides communicate over ZMQ on TCP port 9876 using JSON messages, with image producing commands sending metadata plus a multipart binary payload. Installation uses uv pip install with the dev extra. The client is launched with amadeus-server, pointing at a ZMQ address such as tcp://localhost:9876 for local development or the IP of the microscope VM in production, along with a data directory for the image store. The microscope side is started by opening the vendor's Python console and running exec on dm_server/server.py. A separate dm_gui.py script gives a manual control GUI for the microscope side when an agent is not in the loop. The MCP tool list is grouped by area: focus and magnification, beam and stigmation, stage moves and saved locations, STEM and camera imaging, spectrum imaging start and stop, EDS point and map acquisition with elemental quantification, remote file listing and fetching, FFT and segmentation, a map of objects, an experimental plan, sample metadata, and a shutdown command. The test suite runs offline with pytest and pytest-asyncio against mocks, so contributors can work on it without a live microscope. The README notes the project is not affiliated with Gatan Inc., the maker of DigitalMicrograph.

Copy-paste prompts

Prompt 1
Install AMADEUS with uv pip install and start amadeus-server pointing at tcp://localhost:9876
Prompt 2
Walk me through the ZMQ wire format and how a STEM image command returns its multipart payload
Prompt 3
Add a new MCP tool that records a tilt series across a stage range
Prompt 4
Help me write pytest-asyncio tests that mock the dm_server side for offline development
Prompt 5
Explain how to launch dm_server inside the DigitalMicrograph Python console
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.