Thorlabs Optical Power Meter

io.github.K-Dense-AI由 GitHub 账号 K-Dense-AI 发布v0.1.2更新于 Oct 24, 2026

MCP server for Thorlabs optical power meters (PM100 family, PM400, PM101, PM5020) over SCPI.

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

通过 SCPI 控制 Thorlabs 光功率计,让助手读取激光功率、记录稳定性并调整波长、平均次数和量程。

可以做什么
  • 单次读取光功率,并读取传感器温度与设备、探头信息
  • 按时间记录功率序列,给出均值、标准差、RMS、峰峰值稳定度与漂移,可另存为新的 CSV 文件
  • 设置校正波长、平均次数与功率量程(自动或固定)
  • 对传感器做暗电流归零,并在断电重启后重新连接
  • 查看连接信息、当前安全限制与原始 SCPI 命令日志
适用场景
适用于光学或光子学实验室:台面上有 Thorlabs PM100D、PM100A、PM100USB 或 PM400 功率计时,可让助手取读数、表征激光预热或漂移、测量滤光片透过率。也可用内置模拟器在没有硬件时试用。
运行要求
以 Python 包(uvx labmcp-thorlabs-pm)通过 stdio 在本机运行。需要经 VISA/USBTMC 访问的 Thorlabs 功率计,并以地址形式提供资源字符串;Windows 需安装 NI-VISA 运行时并用 Thorlabs 驱动切换工具,Linux 需为厂商 0x1313 配置 udev 权限,macOS 需 libusb。可选环境变量 LABMCP_ADDRESS、LABMCP_LIMITS、LABMCP_READ_ONLY、LABMCP_SIMULATE。
安装前请注意
会改变仪器状态的工具包括设置波长、平均次数、量程和传感器归零;若传感器上有光时归零,会破坏之后的读数,因此必须先遮挡光束。可用 LABMCP_READ_ONLY 禁用这些操作。记录序列受时长上限约束,save_path 不会覆盖已有文件。该服务器仅在模拟器上测试,尚未在真实硬件上验证,PM101/PM5020 支持也未验证。激光安全仍由使用者负责。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Thorlabs Optical Power Meter,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Thorlabs Optical Power Meter — MCP Server

Let an AI agent read laser power, log stability and warm-up drift, set the wavelength correction, averaging and range, and dark-zero the sensor on Thorlabs optical power meters through their documented SCPI command set over USB (USBTMC / VISA).

Packagelabmcp-thorlabs-pm
InstrumentsPM100D, PM100A, PM100USB, PM400 consoles with C-series photodiode and thermal sensors. PM101 and PM5020 use the same documented commands but are unverified (see Notes)
InterfacesUSB (USBTMC, via VISA)
ProtocolSCPI: PM100D Operation Manual 17654-D02 §6.4, PM100USB Operation Manual 19570-D02 §6.3, PM400 Operating Manual v1.1 §5.5, and Thorlabs' per-model SCPI command references
Status🧪 simulated: tested against a wire-level SCPI simulator, not yet verified on hardware. Report a hardware test

Try it without hardware

bash
uvx labmcp-thorlabs-pm --simulate --checkuvx labmcp-thorlabs-pm --simulate --option sim_sensor=S302C --check   # thermal sensor head

The simulator is a PM100D with an S120C photodiode (or S302C thermopile) looking at a 1.234 mW, 632.8 nm HeNe laser. Setting the wrong wavelength on the photodiode gives a proportionally wrong reading, as on the real bench.

Connect your power meter

  1. Driver. Thorlabs meters enumerate as USB Test & Measurement Class (USBTMC) devices, vendor ID 0x1313.
    • Windows: the Thorlabs driver (TLPM / Thorlabs VISA) is not visible to PyVISA. Install the free NI-VISA runtime, then switch the meter to the NI-VISA driver with the Thorlabs Driver Switcher (installed with the Thorlabs Optical Power Monitor software), and start the server with ?backend=@ivi (see below). This is the route Thorlabs documents for PyVISA.
    • Linux: pyvisa-py talks USBTMC directly (installed with this package). Give your user access to the device, e.g. /etc/udev/rules.d/99-thorlabs-pm.rules:
      SUBSYSTEM=="usb", ATTR{idVendor}=="1313", MODE="0666"
      then sudo udevadm control --reload-rules and re-plug the meter. NI-VISA also works (?backend=@ivi).
    • macOS: pyvisa-py + libusb (brew install libusb); NI-VISA is an alternative.
  2. Find the resource string: uvx labmcp ports (or python -m pyvisa info). It looks like USB0::0x1313::0x8078::P0012345::INSTR (the product ID depends on the model: PM100D 0x8078, PM100USB 0x8072).
  3. Test the connection:
    bash
    uvx labmcp-thorlabs-pm --address USB0::0x1313::0x8078::P0012345::INSTR --checkuvx labmcp-thorlabs-pm --address "visa://USB0::0x1313::0x8078::P0012345::INSTR?backend=@ivi" --check   # NI-VISA
    For the second input of a PM5020 add --option channel=2.

Add to your MCP client

Claude Code

bash
claude mcp add power-meter -- uvx labmcp-thorlabs-pm --address USB0::0x1313::0x8078::P0012345::INSTR

Claude Desktop / Cursor / Windsurf (claude_desktop_config.json, .cursor/mcp.json, …)

json
{  "mcpServers": {    "power-meter": {      "command": "uvx",      "args": ["labmcp-thorlabs-pm", "--address", "USB0::0x1313::0x8078::P0012345::INSTR"]    }  }}

Add --read-only to allow readings but block wavelength, averaging, range and zero changes. For other clients, generate the snippet with uvx labmcp config thorlabs-pm --address <resource> --client vscode (also cursor, codex, claude-code).

Tools

ToolKindDescription
get_command_log👁 readReturn the most recent raw commands sent to / replies received from the instrument (newest last). Useful for debugging and for recording what was done.
get_connection_info👁 readReport which instrument is connected (identity, address, simulated or real), whether the server is read-only, and the active safety limits. Call this first.
get_device_info👁 readIdentify the meter console and the attached sensor head (model, serial, type, wavelength range, power ranges), and report the present wavelength, averaging, range and zero value.
log_power_series👁 readLog a series of power readings to characterise laser stability, warm-up or drift. Returns mean, stdev, min/max, RMS and peak-to-peak stability (%) and drift (%/min), plus the readings (downsampled to max_points; use save_path, a new .csv file, to keep all of them).
read_power👁 readRead the optical power once (in W, plus dBm and a formatted string). The reading uses the configured correction wavelength and averaging; set the wavelength first.
read_sensor_temperature👁 readRead the sensor head temperature in °C (thermal sensors and other heads with a built-in temperature sensor only).
reconnect🛑 safetyClose and re-open the connection to the instrument (e.g. after it was power cycled or a cable was re-plugged).
set_averaging🎛 controlSet how many samples the meter averages for each reading. More averaging lowers noise but slows each reading (PM100 series: ~3 ms per sample; PM400/PM101/PM5020: 1 ms).
set_range🎛 controlSelect auto-ranging, or a fixed power range that fits range_w (the meter picks the most sensitive range that can hold that power). A fixed range reports over-range if exceeded.
set_wavelength🎛 controlSet the correction wavelength (nm) the meter uses to convert sensor signal to power. Must be within the sensor's calibrated range (see get_device_info); sent as a whole number of nm.
zero_sensor🎛 controlDark-zero the sensor (removes dark current / thermal offset). BEFORE calling, ask the user to block the beam and cover the sensor aperture completely, and wait for them to confirm: zeroing with light on the sensor corrupts all later readings. Takes a few seconds.

get_connection_info, get_command_log and reconnect are built into every LabMCP server.

A power meter only measures, so this server has no hazard tools. Your laser is the hazard: wear the right eyewear and never exceed the sensor's rated power or power density.

Safety limits

LimitDefaultMeaning
max_series_duration_s600 sLongest power-logging series an agent may start, estimated as count × max(interval, reading time), where a reading takes averaging × 3 ms plus ~10 ms

Override at launch: --limit max_series_duration_s=3600. One call can log at most 3640 s (the tool's timeout minus a margin): longer estimates are refused, and a series that runs slower than estimated stops early and returns what it measured (completed: false). save_path must end in .csv and must not exist yet (an existing file is never overwritten); it is checked before logging starts.

Example prompts

  • "Set the meter to 1064 nm and tell me the power after the objective."
  • "Log the laser power every 2 s for 10 minutes and report the RMS and peak-to-peak stability. Save the data to ~/data/laser_warmup.csv."
  • "I've capped the sensor. Zero it, then I'll remove the cap and you read the power."
  • "Measure the transmission of this ND filter: read the power without it, then again after I insert it, and give me the optical density."
  • "Is the thermal sensor head still warming up? Read its temperature every minute until it's stable."

Notes

  • Wavelength matters. Photodiode responsivity varies by a factor of several across the sensor's range, so a wrong wavelength setting gives a wrong power. The server sends whole nanometres (the PM400/PM101/PM5020 references specify an integer), so 632.8 nm is set as 633 nm. That changes the responsivity by far less than the sensor's calibration uncertainty.
  • Units. MEAS:POW? answers in the meter's configured unit (W or dBm). The driver reads SENS:POW:UNIT? first and always returns watts, so a front-panel unit change can't mislead the agent.
  • Out of range. The meter answers INFINITY / 9.9E37 when the signal exceeds a manually selected range. The server reports this as an error that suggests auto-ranging.
  • Zeroing (SENS:CORR:COLL:ZERO) runs in the background. The server polls …:ZERO:STAT?, checks the error queue, and returns the zero value (…:ZERO:MAGN?). Zero values are lost when the meter reboots.
  • Energy (pyroelectric) sensors are recognised but not supported: single-pulse energy measurement needs a trigger/fetch workflow that this server doesn't implement yet.
  • Averaging is SENS:AVER:COUN. One sample takes ~3 ms on the PM100 series and 1 ms on the PM400/PM101/PM5020. The reply timeout scales with the averaging count.
  • PM101 and PM5020: Thorlabs' command references for these list exactly the commands used here. The PM5020 adds a channel suffix (SENS2, MEAS2, SYST:SENS2:IDN?), selected with --option channel=2. Neither has been tested yet, and PM5020 LAN/serial connections have not been tried. The PM100D's Windows TLPM DLL driver is not used; this server speaks SCPI only.
  • The simulator's error replies for out-of-range values (-222,"Data out of range") use the standard SCPI code. The Thorlabs documents only list -113,"Undefined header" explicitly.

Hardware verification

ModelFirmwareInterfaceVerified byDate
none yet: be the first

来源:servers/physics/thorlabs-power-meter/README.md,提交 46545ea

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

2
  1. v0.1.2最新Sep 27, 2026
  2. v0.1.0Sep 26, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分