EPICS Channel Access

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

MCP server for EPICS Channel Access: read, monitor and guarded writes of process variables.

概览

AI 生成的概览

让助手通过 Channel Access 读取、监视并在明确授权时写入实验室控制系统中的 EPICS 过程变量。

可以做什么
连接 EPICS IOC 或设施 CA 网关,提供读取单个或多个过程变量及其元数据、报警级别和限值的工具,可订阅某个 PV 一段时间并返回统计结果,也可查看 PV 的连接与访问权限。受保护的写入工具可设置一个或多个 PV,并会校验允许列表、IOC 访问权限、类型和控制限值。安全工具可执行由科学家配置的安全状态,命令日志会记录已发送的内容。
适用场景
适用于加速器、光束线、望远镜、聚变或物理实验室场景,让助手查看实时 EPICS 数值、监视信号漂移,或执行范围明确获授权的设定值更改。建议先以只读方式运行;仅在负责科学家或控制室授权后才启用写入。
运行要求
以 Python 包形式本地运行(uvx labmcp-epics),使用 stdio,仅限桌面。需要能访问 IOC 或 CA 网关的网络:UDP 5064/5065 与 TCP 5064。地址来自常规 EPICS_CA_* 环境变量或 LABMCP_ADDRESS 设置。未声明身份验证。内置模拟器可在无硬件时测试。
安装前请注意
设施控制系统属于安全关键系统:写入可能移动电机、打开快门、调节磁铁或高压,并改变低温或真空系统。本服务器不是联锁或人员保护系统。除非获授权,否则以只读方式运行,并用写入允许列表加以限制;注意 apply_safe_state 在只读模式下也可用。LABMCP_LIMITS 与 LABMCP_SIMULATE 会改变行为;命令日志会记录写入。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

EPICS Channel Access — MCP Server

Let an AI agent read, monitor and, when you allow it, carefully write EPICS process variables (PVs) over Channel Access. EPICS is the control system behind most particle accelerators, synchrotron and neutron beamlines, large telescopes, fusion experiments and many physics labs. The server uses caproto, a pure-Python CA implementation, so there is nothing to compile and no libca to install.

⚠️ Facility control systems are safety-critical. Writing a PV can move motors and sample stages, open shutters, ramp magnets or high voltage, and change cryogenic or vacuum systems. Follow your facility's rules. Get authorisation from the responsible scientist or control-room staff before enabling writes, and run with --read-only unless writes are explicitly authorised. This server is not an interlock or a personnel-protection system and never replaces them. Where possible, connect through the facility's CA gateway with its access-security rules, and limit writes with --option put_allowlist=.

Packagelabmcp-epics
InstrumentsAny EPICS IOC serving Channel Access: EPICS Base 3.14–7.x soft/hard IOCs, areaDetector, motor, asyn, StreamDevice, caproto/pythonSoftIOC IOCs, CA gateways
InterfacesEthernet: CA search on UDP 5064, circuits on TCP 5064, repeater on UDP 5065
ProtocolEPICS Channel Access v4.13 (protocol specification, ao record: DRVH/DRVL, caproto threading client)
Status🧪 simulated: tested against an in-process caproto IOC (real CA over localhost), not yet verified at a facility. Report a hardware test

Try it without hardware

bash
uvx labmcp-epics --simulate --check

The simulator is a real Channel Access server running in-process. It is bound to 127.0.0.1 on random free ports, and the client is pointed only at that address (auto address list off), so it neither broadcasts on nor answers your network. It serves SIM:TEMP (°C, with alarm limits, following SIM:TEMP:SP while SIM:HEATER is On), SIM:MTR (a motor whose put-callback completes only when the move is done, with SIM:MTR:RBV, :DMOV, :STOP and :VELO), SIM:DET:FRAMES, SIM:SAMPLE (string), SIM:SPECTRUM (a 512-point waveform), SIM:BEAM:CURRENT and SIM:STATUS.

Connect to your control system

  1. Network: your computer must reach the IOCs, or the facility's CA gateway: UDP 5064/5065 and TCP 5064 through any firewall. Most facilities put control networks behind a gateway, so ask your controls group for its address.
  2. Address list: Channel Access finds PVs by UDP search. Either use your usual EPICS environment (EPICS_CA_ADDR_LIST, EPICS_CA_AUTO_ADDR_LIST), or pass it explicitly:
    bash
    uvx labmcp-epics --read-only --address 10.0.1.20 --option check_pv=SR:CURRENT --check   # one IOC / gatewayuvx labmcp-epics --read-only --option ca_addr_list="gw1.facility.org 10.0.1.21:5064" --option check_pv=BL7:RING:I --checkuvx labmcp-epics --read-only --option check_pv=BL7:RING:I --check                        # use the environment as-is
    Passing an address list switches the automatic (broadcast) list off unless you add --option auto_addr_list=yes. With --option check_pv=<a PV you know exists>, --check reads that PV and prints its value, or the reason it can't be reached. Without it, --check only confirms that the CA client starts.

Add to your MCP client

Claude Code (read-only, recommended)

bash
claude mcp add epics -- uvx labmcp-epics --read-only --address gw1.facility.org

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

json
{  "mcpServers": {    "epics": {      "command": "uvx",      "args": ["labmcp-epics", "--read-only", "--address", "gw1.facility.org"]    }  }}

Authorised writes (example: a beamline scientist lets the agent move only the sample stage and the filter wheel, and configures an emergency safe state):

bash
uvx labmcp-epics --address 10.0.7.10 \  --option put_allowlist='BL7:(SAMPLE:(X|Y)|FILTER:POS)' \  --option require_ctrl_limits=true \  --option safe_state='BL7:SAMPLE:X.STOP=1;BL7:SAMPLE:Y.STOP=1;BL7:SHUTTER:CMD=Close'

Tools

ToolKindDescription
apply_safe_state🛑 safetyEmergency action: write the scientist-configured safe-state PVs (--option safe_state, e.g. motor STOP fields, shutter close, HV off), all of them even if one fails. Available in read-only mode. It does not replace the facility's own interlocks and stop buttons.
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_pv👁 readRead one PV with its metadata: value, units, precision, alarm severity/status, IOC timestamp and age, display/alarm/warning/control limits and enum state names. Waveforms come back downsampled with min/max/mean statistics.
get_pvs👁 readRead many PVs at once (e.g. all motors or vacuum gauges of a beamline). PVs that cannot be reached are listed in errors instead of failing the whole call.
monitor_pv👁 readSubscribe to a PV and collect every value change for duration_s seconds (or until max_updates), then return statistics (min/max/mean/std, drift rate) and the updates.
put_pv⚠️ hazardWrite a PV. This can move motors, open shutters, change magnet or high-voltage setpoints and heat or cool samples: tell the user exactly what will change first. The write is refused unless the PV matches the put allow-list, the IOC grants write access, and the value has the right type and lies within the PV's control limits (DRVL/DRVH). Returns the read-back value.
put_pvs⚠️ hazardWrite several PVs in order (e.g. set both slit blades). Every write is validated first (allow- list, access rights, type, control limits); if any is invalid nothing is written. Writing stops at the first failure and the rest are reported as not written. The whole batch must finish within an hour: writes that would start later are not sent.
pv_info👁 readConnection details of a PV: serving IOC host:port, native type, element count, and whether this client has read/write access (EPICS access security) and passes the put allow-list.
reconnect🛑 safetyClose and re-open the connection to the instrument (e.g. after it was power cycled or a cable was re-plugged).

Safety limits

LimitDefaultMeaning
max_monitor_duration_s60 sLongest monitor_pv collection
max_put_batch10 PVsMost PVs one put_pvs call may write
max_put_wait_s60 sLongest wait for one put-callback (completion)

Override at launch, e.g. --limit max_put_batch=4. The main write guards are options, not numeric limits:

GuardHow
Read-only mode--read-only hides put_pv and put_pvs entirely
Allow-list--option put_allowlist=<regex>: a PV name must fully match it to be written. Prefer patterns that exclude record fields (BL7:SAMPLE:[^.]* rather than BL7:SAMPLE:.*)
Limit fieldswrites to the fields that set the limits (.DRVH, .DRVL, .HOPR, .LOPR, and the motor record's .HLM, .LLM, .DHLM, .DLLM) are refused, so a write can't raise a limit and then pass it. --option allow_limit_field_writes=true permits them
EPICS access securitywrites are refused up front if the IOC or gateway grants this client read-only access
Control limitsnumeric writes outside the PV's control limits are refused. For output records these are DRVL/DRVH, which the IOC would otherwise silently clip to. A NaN limit means no limit on that side
No limits configuredallowed with a warning, or refused with --option require_ctrl_limits=true
Type checksenum states must be valid names or indices, integers must be integral and in range, 32-bit FLOAT values must fit, strings are at most 39 latin-1 characters, arrays must fit the element count
PV namesno whitespace or quotes, and record names of at most 59 characters (EPICS 3.14+); anything else is refused before a search is sent
Batchesput_pvs validates every write before sending any, stops at the first failure, and sends no write once its one-hour budget (inside the tool timeout) is used up
Put-completionput_pv waits for the IOC's put-callback. On timeout it says the IOC may still be processing and not to repeat blindly
Safe stateapply_safe_state (SAFETY, available even in read-only mode) writes only the PVs the scientist configured with --option safe_state

Example prompts

  • "What is the storage-ring current, and are any of the BL7 vacuum gauges in alarm?"
  • "Read BL7:MONO:ENERGY and its readback, and tell me the units and control limits."
  • "Monitor the sample temperature for 30 s and tell me whether it is still drifting."
  • "Move the sample stage X to 12.5 mm and confirm the readback when the move is done."
  • "Record the detector spectrum waveform and tell me where the peak is."
  • "Stop everything: apply the safe state."

Notes

  • Setpoint versus readback: for motor records, NAME (VAL) is the target and NAME.RBV is the actual position. put_pv returns the value read back from the PV you wrote, so read the readback PV separately to confirm physical motion.
  • Control limits come from the CA DBR_CTRL response. EPICS convention treats equal low and high limits (normally 0/0) as "not configured", and those PVs are only type-checked.
  • NaN and infinity: JSON has neither. A NaN or infinite scalar value comes back as the text "nan", "inf" or "-inf", array elements as null, a limit that is NaN (EPICS 3.16+ reports unset alarm limits that way) as null, and waveform and monitor statistics leave such values out and count them (non_finite, non_finite_updates).
  • Alarms: every reading includes severity (NO_ALARM, MINOR_ALARM, MAJOR_ALARM, INVALID_ALARM), status (HIHI, LOLO, UDF, COMM, …) and age_s, the time since the IOC timestamp, so stale values stand out.
  • Waveforms are downsampled by block averaging to max_elements, with min/max/mean/argmax statistics. CHAR waveforms are also decoded to text (as_string), the usual EPICS long-string convention. When writing, a text value is accepted for CHAR waveforms.
  • pvAccess: only Channel Access is supported. caproto 1.x implements CA only, and pvAccess would need p4p, a compiled EPICS Base binding that is deliberately not a dependency. EPICS 7 IOCs serve their records over both CA and PVA, so this covers normal records. PVA-only data (for example NTNDArray images from areaDetector's PVA plugin, or QSRV group PVs) can't be read.
  • The CA client is configured through EPICS_CA_* environment variables, as in EPICS Base. The server sets them for its own process from --address/--option and restores them on disconnect. If put_allowlist holds a comma, pass it on the command line or give LABMCP_OPTIONS in its JSON form ({"put_allowlist": "BL7:(A|B){1,2}"}), because the a=1,b=2 form splits on commas.
  • get_command_log records every write (caput -c NAME value) and its read-back.

Hardware verification

Facility / IOCEPICS versionInterfaceVerified byDate
none yet: be the first

来源:servers/protocols/epics/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 分