Vmd Hydrate Mcp

io.github.wjgoarxiv由 GitHub 账号 wjgoarxiv 发布v0.2.0更新于 Oct 24, 2026

Drive VMD for GROMACS/LAMMPS analysis + clathrate-hydrate cage science (needs a local VMD)

概览

AI 生成的概览

一个本地 MCP 服务器,驱动 VMD 会话加载分子动力学结构、渲染图像并分析笼形水合物笼。

可以做什么
在持久 VMD 会话中加载并查看 GROMACS、LAMMPS、PDB、DCD、mmCIF 等结构与轨迹,列出已加载分子并检查选择与原子数。设置、叠加和清除表示方式,并通过旋转、缩放、重置控制视角。以无头方式将当前视图渲染为 PNG 图像。测量距离、角度、二面角和回转半径等几何量。计算水合物序参数(F3/F4)与水分子氢键网络。识别并分类笼形水合物笼(5¹²、5¹²6⁴ 等),判定 sI/sII/sH 结构,并按请求筛选或改色渲染笼。
适用场景
适合分子动力学工作:通过对话检查 GROMACS 或 LAMMPS 轨迹、测量几何量,并分析笼形水合物的结构与有序度。适合已在本机安装 VMD、希望无需写脚本即可获得可复现的无头渲染或笼分析的研究人员。
运行要求
作为本地 Python 进程运行(Python 3.10+),通常通过 uvx 从 PyPI 包启动。可视化与渲染需要本机安装 VMD(2.0b1 或 1.9.4+);若 vmd 不在 PATH 中需设置 VMD_BIN。测量与选择工具需要 MDAnalysis。需设置 VMD_HYDRATE_MCP_ALLOW_DIR 指定可读取的目录。可选 VMD_HYDRATE_MCP_DISPLAY=gui 打开可见的 VMD 窗口。TGA 转 PNG 需要 sips、ImageMagick 或 Pillow。
安装前请注意
服务器会读取本机文件,VMD_HYDRATE_MCP_ALLOW_DIR 的允许列表应尽量收窄,列表之外的路径会被拒绝。它会通过本机回环、带令牌的套接字启动并控制 VMD 进程,GUI 模式会打开可见窗口。它会改变会话状态(已加载分子、表示方式、视角),并写出渲染图像文件。未声明任何身份验证或凭据。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[图片]

vmd-hydrate-mcp

Drive VMD from any LLM — render GROMACS/LAMMPS trajectories and analyze clathrate-hydrate cages through the Model Context Protocol.

Quick Start · Features · MCP Tools · Usage · 한국어

[图片] [图片] [图片] [图片] [图片]


[!NOTE] An MCP server that lets Claude (or any MCP client) control VMD directly — load GROMACS/LAMMPS trajectories, identify clathrate-hydrate cages (sI/sII/sH), script headless renders, and compute order parameters (F3/F4) and H-bond networks — turning molecular-dynamics analysis into a conversation. Unlike the existing VMD MCP, it keeps a stateful VMD session, is secure by default, and owns the one thing no other MCP does: hydrate cage science.

See it in action

[vmd-hydrate-mcp identifying and rendering sII hydrate cages in VMD]

Every frame is a real headless VMD (Tachyon) render, driven entirely through the MCP server. The sII cages — 128 × 5¹² + 60 × 5¹²6⁴ — are identified by this repo, not mocked. · ▶ full-quality MP4

Features

  • Clathrate Cage Identification -- find and classify hydrate cages (5¹², 5¹²6², 5¹²6⁴, …) from the H-bond network and label the crystal structure (sI/sII/sH). Validated on the sII benchmark (128 small cages, exact).
  • Photorealistic, Style-by-Prompt Cage Rendering -- cages render with ambient occlusion + shadows, orthographic by default, each cage type in ONE unified color (a curated palette: 5¹²=cyan, 5¹²6⁴=red, …). Just ask: "show only the sII large cages in magenta with emphasized width" and the MCP filters, recolors, and thickens them.
  • Stateful VMD Session -- a persistent VMD process (Tcl socket server) keeps your molecules, selections, and camera alive across tool calls -- no reloading on every command.
  • Hydrate Order Parameters -- F3 (tetrahedrality) and F4 (⟨cos 3φ⟩) computed in pure NumPy, validated to the reference to 6 decimals (F4 = 0.926698 on the sII benchmark).
  • H-bond Networks -- water–water hydrogen-bond graph with coordination stats, the substrate for cage identification.
  • Headless Rendering -- CPU Tachyon ray-traced PNGs with no display or GPU, returned inline as images. Works on laptops, servers, and HPC.
  • Attended (GUI) Mode -- run fully offscreen (default), or set VMD_HYDRATE_MCP_DISPLAY=gui to open a visible VMD window and watch Claude load, color, rotate, and render your system live.
  • GROMACS + LAMMPS -- one server ingests .gro/.xtc/.trr, LAMMPS .data/dump, PDB, DCD, mmCIF.
  • Secure by Default -- filesystem allowlist + a Tcl command allowlist (not a bypassable denylist) + a loopback, token-gated control socket. No run_tcl foot-gun exposed.
  • MCP-Native -- clean English tool names and typed outputs; works in Claude Desktop, Claude Code, and any MCP client.

Quick Start

[!IMPORTANT] Requires a local VMD install (2.0b1 or 1.9.4+) — this server drives your VMD; no registry or package ships it. On macOS, VMD lives inside a .app, so set VMD_BIN if vmd isn't on your PATH. (The pure hydrate/measure tools still work without VMD.)

Install

Zero-install via uvx (recommended):

bash
uvx vmd-hydrate-mcp                                  # run the serveruvx --from 'vmd-hydrate-mcp[mda]' vmd-hydrate-mcp    # + MDAnalysis for measures/selection

Or from source:

bash
git clone https://github.com/wjgoarxiv/vmd-hydrate-mcp.gitcd vmd-hydrate-mcp && uv pip install -e ".[mda]"

Register with an MCP client

Claude Code — one command:

bash
claude mcp add vmd-hydrate -- uvx vmd-hydrate-mcp

Claude Desktop / any client — add to the mcpServers config (or commit a project .mcp.json):

json
{  "mcpServers": {    "vmd-hydrate": {      "command": "uvx",      "args": ["vmd-hydrate-mcp"],      "env": { "VMD_HYDRATE_MCP_ALLOW_DIR": "/path/to/your/data" }    }  }}

[!IMPORTANT] Set VMD_HYDRATE_MCP_ALLOW_DIR (os-path-separated) to the directories the server may read. All file arguments are realpath-checked against this allowlist — paths outside it are refused.

Attended (GUI) mode

By default the server drives VMD headless (offscreen). To instead open a real VMD window you can watch while Claude controls it live, add VMD_HYDRATE_MCP_DISPLAY=gui to the server's env:

json
{ "mcpServers": { "vmd-hydrate": {  "command": "uvx", "args": ["vmd-hydrate-mcp"],  "env": { "VMD_HYDRATE_MCP_DISPLAY": "gui", "VMD_HYDRATE_MCP_ALLOW_DIR": "/path/to/data" }}}}

Then ask things like "load prod.gro, show water as points and the surfactant as VDW, then slowly rotate it" — the window updates in real time via load_structure → add_representation → rotate_view. (Requires a local desktop session; the same Tcl socket drives both modes.)

MCP Tools

ToolPurposeBackend
vmd_statusVMD version + molecules loaded in the live sessionVMD
load_structureLoad a structure/trajectory (returns a molid)VMD
list_moleculesList loaded moleculesVMD
set_representationStyle/color/material/selection for a molecule (replaces reps)VMD
add_representationLayer another representation (multi-rep views)VMD
clear_representationsRemove all representationsVMD
rotate_view / zoom_view / reset_viewLive camera control (visible in GUI mode)VMD
renderHeadless PNG of the current viewVMD + Tachyon
resolve_selectionAtom count for a selection (catches the 0-atom .gro trap)MDAnalysis
measure_geometryDistance / angle / dihedral by atom indexMDAnalysis
radius_of_gyrationRg of a selectionMDAnalysis
hydrate_order_paramsF3 + F4 water order parametersNumPy
hbond_networkWater H-bond network + coordinationNumPy
identify_cagesCage counts (5¹²/5¹²6⁴/…) + sI/sII/sH structureNumPy
render_cagesPhotorealistic cage render (AO+shadows, ortho); filter / recolor / emphasize cages by promptVMD + NumPy

Usage

1. Analyze hydrate order in a trajectory frame

Compute the F3/F4 order parameters for hydrate.gro

Returns f4_overall, f3_overall, water count, and a plain-language interpretation (crystalline / hydrate-like / liquid / ice).

2. Render a structure

Load hydrate.gro, show the water oxygens as VDW spheres, and render it

Produces an inline PNG rendered headlessly with CPU Tachyon.

3. Inspect the H-bond network

Build the water hydrogen-bond network for hydrate.gro at frame 0

Returns bond count and average coordination (≈4 for a well-formed clathrate).

4. Style hydrate cages by prompt

Load hydrate.gro and show only the sII large cages in magenta with emphasized width

Renders a photorealistic, orthographic image of just the 5¹²6⁴ cages in magenta with thicker edges — the MCP maps this to render_cages(cage_types=["51264"], highlight_color="magenta", emphasis=True). Omit the filters and every cage type is drawn in its palette color (5¹²=cyan, 5¹²6⁴=red, …).

Does it really drive VMD?

Yes — and you can confirm it in one command. examples/verify.py runs the same code the MCP server exposes on a bundled sII CO₂-hydrate example: it pings the real VMD binary, identifies the cages, and renders them headlessly.

bash
python examples/verify.py

Expected output:

text
[1] VMD found : /Applications/VMD2b1.app/.../vmd_MACOSXARM64    ping      : pong 2.0b1 MACOSXARM64[2] Identifying cages in a real sII CO2 hydrate (1088 waters)...    cage counts : {'51264': 60, '512': 128}    structure   : sII  (confidence 0.93)    F4 order    : 0.965  (highly ordered (crystalline hydrate / ice-like))[3] Rendering cages headlessly (blue = 5^12, red = 5^12 6^4)...    saved       : examples/output/cages.png (362495 bytes)OK — vmd-hydrate-mcp drove VMD and identified the cages above.

The images below are real, unretouched VMD renders from that pipeline (not illustrations):

[图片]
sII crystal — cages colored by type (cyan 5¹², red 5¹²6⁴), photorealistic Tachyon
[图片]
a single 5¹² dodecahedron, unwrapped across PBC (ambient occlusion + shadows)

The demo video at the top is assembled from frames like these — see video/build_frames.py (drives VMD) and video/remotion/ (Remotion compositing). Rebuild it with python video/build_frames.py && cd video/remotion && npm i && npm run gif.

How It Works

  [.gro / .xtc / LAMMPS dump]            |            v     MCP client (Claude)  --stdio-->  vmd-hydrate-mcp (FastMCP)                                          |            |                          numbers  <------+            +------>  visualization                     MDAnalysis + NumPy                     persistent VMD session                   (F3/F4, H-bonds, Rg)                    (Tcl socket, 127.0.0.1)                          |                                         |                          v                                         v                  structured JSON                         Tachyon --> PNG image

Numeric science runs in Python (no display, unit-testable in CI). Visualization and rendering run in a long-lived, token-gated VMD process. The two never mix units: hydrate math is nanometers, VMD/MDAnalysis measures are Ångström.

Requirements

DependencyRequiredPurpose
VMD 2.0b1 or 1.9.4+for viz/renderthe visualization engine
Python 3.10+yesthe server
mcpyesModel Context Protocol SDK
MDAnalysis ([mda])for measures/selectiontopology-aware loading
sips / ImageMagick / Pillowfor renderTGA→PNG conversion

[!WARNING] On macOS, VMD ships as a .app and its CLI binary lives inside the bundle. If vmd is not on your PATH, set VMD_BIN to the binary (e.g. /Applications/VMD*.app/Contents/vmd*/vmd_MACOSXARM64). Pure hydrate/measure tools work without VMD.

Contributing

  1. Fork and branch (git checkout -b feature/x).
  2. uv pip install -e ".[dev,mda]" and keep pytest green (science tests need no VMD).
  3. Commit, push, open a PR. Found a bug? Open an issue.

License

MIT — see LICENSE.

来源:README.md,提交 1a477e7

工具

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

版本历史

1
  1. v0.2.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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