hydroemu-mcp-server
hydroemu-mcp-server
一个MCP服务器,将HACC宇宙学流体动力学模拟仿真器——预训练的SEPIA高斯过程模型——作为工具暴露给任何LLM代理。
这个仓库教的一个核心理念
科学代码保持常规Python。MCP包装器只负责发布它。
tools/是一个普通的科学包。它从不导入MCP。仿真器工具位于tools/hydro_tools.py;核心SEPIA包装器位于tools/emulator.py。mcp_server/是一个约70行的通用包装器。它从pyproject.toml读取一行配置,导入科学包,并将其__all__中列出的每个函数注册为MCP工具。
[tool.mcp-server]
tool_modules = ["tools"]你的类型提示、Pydantic Field 约束和文档字符串成为代理看到的工具模式。要构建自己的服务器:将你的模块放入 tools/(或将那一行配置指向你自己的包),在 __all__ 中列出公共函数,完成。
Related MCP server: MCP Refana Server
布局
models/ Pre-trained SEPIA pickles (copy from CosmoHydro/models/)
tools/
emulator.py Core SEPIA wrapper: lazy load, predict, redshift interpolation
hydro_tools.py The 5 MCP tool functions + ArtifactResult contract
__init__.py __all__ — ONLY these names become tools
mcp_server/ Generic drop-in wrapper (FastMCP)
tests/test_tools.py Tools tested as plain Python, no MCP needed
docs/mcp-clients.md Multi-client setup guide参数
共7个参数(5个子网格 + 2个宇宙学):
参数 | 符号 | 范围 | 单位 |
AGN风耦合 | κ_w | [0.03, 3.0] | — |
AGN能量效率 | e_w | [0.001, 0.1] | — |
黑洞种子质量 | M_seed | [0.5, 50.0] | 10⁶ M☉ |
动能反馈速度 | v_kin | [0.1, 1.0] | 10⁴ km/s |
动能反馈效率 | ε_kin | [0.1, 1.0] | 10¹ |
物质密度 | ω_m | [0.12, 0.155] | — |
涨落幅度 | σ₈ | [0.7, 0.9] | — |
设计:来自拉丁超立方体设计的110次模拟(400 Mpc/h盒子)。
可观测量
可观测量 | 描述 | 快照数 | 红移范围 |
GSMF | 星系恒星质量函数 | 11 | 0–2 |
HMF | 暗晕质量函数 | 11 | 0–2 |
fGas | 星系团气体分数 | 7 | 0–1.0 |
CGD | 星系团气体密度轮廓 | 5 | 0–0.5 |
CGED | 星系团气体电子密度轮廓 | 5 | 0–0.5 |
CPP | 星系团气体压力轮廓 | 5 | 0–0.5 |
CTP | 星系团气体温度轮廓 | 5 | 0–0.5 |
CEP | 星系团气体熵轮廓 | 5 | 0–0.5 |
CEEP | 星系团电子熵轮廓 | 5 | 0–0.5 |
CMP | 星系团气体金属丰度轮廓 | 5 | 0–0.5 |
CYP | 星系团Compton-y (tSZ) 轮廓 | 5 | 0–0.5 |
工具
工具 | 功能 |
| 列出所有11个模拟可观测量及其元数据 |
| 7参数设计空间及其范围 |
| 在z=0处预测任意可观测量,写入CSV |
| 在任意红移处预测(插值) |
| 双面板图:可观测量 + 比率 |
值得复制到任何科学MCP服务器中的两个约定:
每个工具返回
{status, files, message, metadata}(ArtifactResult)。数组在工具之间以文件路径形式传递,绝不通过代理的上下文窗口。
安装
conda create -n hydroemu python=3.12 -y
conda activate hydroemu
pip install -e ".[dev]"
pytest # tests pass without SEPIA models (fixture data)预训练模型
将训练好的SEPIA pickle文件从 CosmoHydro/models/ 复制到 models/ 目录:
cp -r /path/to/CosmoHydro/models/GSMF_multiz models/
cp -r /path/to/CosmoHydro/models/HMF_multiz models/
# ... etc for each observable没有模型时,list_observables()、describe_parameters() 和 plot_observable_comparison() 仍然可用;只有 predict_observable 和 predict_observable_redshift 需要pickle文件。
运行服务器
可流式HTTP —— 服务器是一个带有URL的可见进程:
python -m mcp_server --transport streamable-http --port 8000客户端连接到 http://127.0.0.1:8000/mcp。使用 Ctrl+C 停止服务器(Ctrl+Z 只会挂起它,导致端口被占用——如果发生这种情况,只需重新启动服务器:它会检测到残留的 mcp_server 占用端口并自动清除)。
要从Claude Code、Claude桌面应用、Codex、Cursor或任何其他MCP客户端使用此服务器,请参阅 docs/mcp-clients.md;已检入的 .mcp.json 已将其接入Claude Code。
架构
此服务器遵循与 spectra-mcp-server 相同的架构:
仿真器图
参见 完整图库 获取来自CosmoHydro训练笔记本的24个验证、敏感性和对比图。亮点:
|
|
GSMF:仿真器与留出模拟的对比 | P(k) 抑制:每个参数的敏感性 |
架构(详细)
mcp_server/是一个通用即插即用的MCP包装器(可在仓库间复制)tools/包含领域特定的科学函数pyproject.toml中的[tool.mcp-server]配置将它们连接起来所有SEPIA导入都是惰性的(在函数内部,而非模块作用域)
模型在首次使用时加载,并在后续调用中缓存
This server cannot be deployed
Maintenance
Related MCP Connectors
214 tools for AI agents over one MCP endpoint: image, video, audio, 3D, data, storage, mail, GPUs.
Free public MCP for AI agents — 193 tools, 44 workflows. No API key.
MCP-Native LLM Orchestration Agent
Hosted MCP with 91 agent tools: X, domains, SEO, Maps, Trends, Search, YouTube, TikTok, and more.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides MCP tools for high-performance computing (HPC) and converged computing, enabling agentic interactions with HPC resources and workflows.6MIT
- FlicenseAqualityDmaintenanceEnables Mu2e analysis workflows by exposing event counting, cut analysis, sensitivity computation, and ML selection as MCP tools for agentic frameworks.10-
- AlicenseAqualityBmaintenanceExposes SwarmLabs physics-informed scientific experiment predictions as MCP tools, enabling agents to run predictions, list engines, and perform parameter sweeps with honesty-first uncertainty reporting.6MIT
- FlicenseNot gradedqualityCmaintenanceMCP server that exposes cosmology tools to LLM agents, including CLASS matter power spectrum computation, eBOSS DR14 Lyman-α forest data retrieval, and plotting capabilities.2-

