breedsim-mcp

io.github.musharna由 GitHub 账号 musharna 发布v0.6.1更新于 Oct 26, 2026

Breeding-scheme simulation via AlphaSimR. Needs R, AlphaSimR and libtirpc-dev on the host.

已验证STDIO仅桌面数据与分析AI 与机器学习

概览

AI 生成的概览

在本地运行 AlphaSimR 育种方案模拟,返回重复运行的分布与配对比较,而非单次随机结果。

可以做什么
  • 查看引擎信息:列出方法、版本、群体生成器、选择方法、重复次数下限与规模上限
  • 建立基础群体,返回会话 ID、奠基者来源、可重复性状态与实测连锁不平衡
  • 按重复运行育种方案,读取每周期的均值、标准差与 95% 置信区间
  • 在同一批种子上比较两个方案,读取带置信区间的配对差值
  • 描述会话的来源、性状结构与已运行周期
适用场景
适用于数量遗传学及动植物育种工作:需要助手运行明确的 AlphaSimR 选择方案并给出带不确定性的预期遗传增益,或在相同种子上比较两个方案。
运行要求
通过 uvx 从 PyPI 安装的本地 stdio 进程。主机需 R 4.3 及以上并带 libR.so、从源码编译的 AlphaSimR、libtirpc-dev、低于 3.6 的 rpy2 以及 mcp 2.x。需使用系统或 uv 管理的 Python,conda 的 Python 会失败。若 AlphaSimR 装在用户库中可能需设置 R_LIBS_USER。无需认证。
安装前请注意
调用在单个 R 解释器中串行执行,一次超大规模的调用会阻塞其他调用;规模上限由 list_methods 列出。会话保存在内存中,最多 8 个,重启即丢失。基因组选择需用 runMacs,而它在长期运行的进程中不可重复;可重复的 quickHaplo 生成器则没有连锁不平衡。覆盖 OMP_NUM_THREADS 会使结果不可重复。README 称其成本高于让模型自行编写 AlphaSimR 脚本,且相对后者没有可测量的准确率提升。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

breedsim-mcp

breedsim-mcp is an MCP server that lets AI agents run AlphaSimR breeding-program simulations. It returns the spread over replicates, never a single stochastic run, so an agent can say what a selection scheme would gain and how sure that is.

[CI] [PyPI] [Python] [License] [DOI] [Glama]

Why replicates

A single simulation run is not a result, and this API will not return one. Five seeds of an identical three-cycle program gave mean genetic gain [1.151, 1.841, 1.424, 1.429, 1.473], sd 0.247, on the very number being reported (measured once on AlphaSimR 2.1.0 while building v0.1.0, 2026-07-29). So run_program enforces a replicate floor and returns a per-cycle mean, sd and confidence interval. No flag collapses it to a point estimate.

Install

This needs more than uv pip install:

  • R ≥ 4.3 with a shared library (libR.so)
  • AlphaSimR, an Rcpp/RcppArmadillo compile that takes minutes
  • libtirpc-dev, or rpy2 fails to link (cannot find -ltirpc)
  • rpy2 <3.6, because 3.6 binds R_getVar, which needs R ≥ 4.4
bash
sudo apt-get install -y r-base r-base-dev libtirpc-devR -e 'install.packages("AlphaSimR", repos="https://cloud.r-project.org")'uv add breedsim-mcp

Do not use a conda Python: rpy2 then fails to load libR.so with GLIBCXX_3.4.30 not found, because conda ships an older libstdc++ than the system libicuuc requires. Use a system or uv-managed interpreter. Requires mcp 2.x.

Configure your MCP client

The server speaks stdio through the breedsim-mcp console script.

Claude Code

bash
claude mcp add breedsim -- breedsim-mcp

Claude Desktop (claude_desktop_config.json):

json
{  "mcpServers": {    "breedsim": {      "command": "breedsim-mcp"    }  }}

If the executable is not on your PATH, or AlphaSimR lives in a user library, run it through uv and pass the library path:

json
{  "mcpServers": {    "breedsim": {      "command": "uv",      "args": ["run", "--directory", "/path/to/breedsim-mcp", "breedsim-mcp"],      "env": { "R_LIBS_USER": "/home/you/R/library" }    }  }}

Check it with list_methods(), which reports the engine versions and whether this process can currently produce reproducible results.

What the benchmark shows

Claude with the server was compared with Claude writing its own AlphaSimR scripts, with R and AlphaSimR installed for it, on 34 breeding-simulation questions, 3 runs each. A tie means the server matches that result without you setting up R and AlphaSimR. Questions right in every run, server against Claude's own scripts: Claude Haiku 5.5 34 against 33, Sonnet 5.5 28 against 33, Opus 5.5 34 against 34 (re-run 2026-10-18). None is separated (pre-registered; Holm-adjusted McNemar p = 1.0 on Haiku, 0.25 on Sonnet). Sonnet's gap is runs where it answered from breeder's-equation theory instead of running the simulation. The server was cheaper with Haiku (on 26 of 34 questions) and dearer with Sonnet and Opus. Opus with no tools got 51 of 102 answers right.

[Stacked bar chart of right and wrong answers to 34 breeding-simulation questions, 3 runs each. Claude alone: 51 right, 51 wrong. Claude with Bash, R and web: 99 right, 3 wrong. Claude with breedsim-mcp: 102 right, 0 wrong. No-LLM baselines, one answer per question: one constant per kind of question, 12 right and 22 wrong; best closed form per question, 15 right and 19 wrong.]

The chart is the first Opus 5.5 run, keyed by AlphaSimR run directly; the best named formula lands in only 15 of 34. With this server Claude got 102 of 102 answers right, with its own R and AlphaSimR 99 of 102 (not separated, exact McNemar p = 1.0), and alone 51 of 102 (both tool setups beat it, p < 1e-6). The re-run, with an unreleased commit that cut the server's instructions and rounded its outputs, got 102 of 102 in both setups and lowered the server's median cost per answer from $0.051 to $0.033; Claude's own scripts cost $0.027, cheaper on all 34 questions (p = 1e-10). Time is not separated.

Each question spells out the AlphaSimR calls, so this tests running a stated simulation, not designing one unaided. We wrote the questions and ran the benchmark ourselves; an outside re-run is welcome. Method, controls, other limitations, and six probability questions reported separately are in benchmarks/agent_qa; the Haiku and Sonnet runs: 2026-10-20 re-run.

Tools

ToolReturns
list_methodsengine versions, generators, selection methods, replicate floor
found_populationsession_id, founder provenance, reproducible, measured LD
run_programper-cycle distributions: mean, sd, 95% CI
compare_programsthe paired difference between two programs, with a CI
describe_sessionprovenance, trait architecture, cycles run

Typical loop: found_population → run_program → read the CI and the warnings. To compare two schemes: found_population → compare_programs → read difference. run_program takes selection_method="phenotypic" or "genomic"; compare_programs takes one per arm.

docs/REFERENCE.md has the full tool signatures, example outputs, the warnings table, and the measurements behind the points below.

  • Compare with compare_programs, not two run_program calls. It runs both arms on the same seeds and differences them within each pair, so shared luck cancels. Two overlapping per-program intervals do not imply no difference; the paired interval can still exclude zero (warning overlap_but_different). favours is null when the paired interval contains zero.
  • Genomic selection needs linkage disequilibrium. selection_method="genomic" fits RRBLUP to a SNP chip set at founding (n_snp_per_chr). quickHaplo, the default and the only reproducible generator, has no LD, so use runMacs, which does not reproduce in a long-lived process. On this engine you cannot have both. found_population measures LD and warns (no_linkage_disequilibrium) when the markers are uninformative.
  • Reproducibility. The server pins OMP_NUM_THREADS=1 at import, before R starts; without it the same seed gives different results. The runMacs RNG is seeded once per R session and advances across calls, so a repeat call in this long-lived process differs (reproducible: false).
  • Warnings explain; none of them withhold results.
  • Multi-trait selection. Pass h2 as a list and index_weights to select on a weighted index. trait_correlation must be a real correlation matrix (for n equally correlated traits, not below −1/(n−1)); an invalid one is refused, not replaced by the nearest valid matrix. Genomic selection fits one RRBLUP model per trait, applies the index to the estimated breeding values, and reports prediction_accuracy in each traits entry.
  • Species. species applies only to runMacs, which has demographic histories for GENERIC, CATTLE, WHEAT and MAIZE; anything else is refused. The default is MAIZE, but this is not a plant-only simulator.
  • Limits. Every size parameter has a ceiling, listed by list_methods() under limits. R is a single interpreter and calls are serialized, so one oversized call would block every other. For large jobs, drive AlphaSimR directly.

Testing

CI installs R and compiles AlphaSimR, so the suite runs against the real engine on Python 3.11, 3.12 and 3.13. One test checks the R engine layer against the breeder's equation R = h²S (docs/EVAL.md); it does not test this server's founding or selection code against an outside reference. docs/MUTATION-CHECKS.md records 25 deliberate mutants: 24 turned a test red, and one survives because it is equivalent. tests/test_perf_ratchet.py gates each tool on exact counts of package-function calls and R evaluations, not on time.

Limitations

  • compare_programs is single-trait: one paired verdict needs one criterion, and with several traits that is the index, for which AlphaSimR reports no gain.
  • No G×E, optimal contribution selection, crossing-block optimization or genotype-matrix export.
  • Genomic selection is RRBLUP only. RRBLUP_D, _GCA and _SCA estimate dominance and combining-ability effects that the additive-only addTraitA architecture does not have.
  • Sessions are in memory, capped at 8 (LRU), and do not survive a restart.

License

GPL-3.0-or-later, because this imports rpy2, which is GPLv2+. AlphaSimR itself is MIT. Unofficial: not affiliated with, endorsed by, or sponsored by the AlphaSimR authors, the University of Edinburgh, or the R Foundation. See NOTICE.

CHANGELOG.md records what changed and why.

来源:README.md,提交 8beb3cd

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:软件包安装失败。

版本历史

6
  1. v0.6.1最新Oct 20, 2026
  2. v0.6.0Oct 20, 2026
  3. v0.5.1Sep 26, 2026
  4. v0.5.0Sep 23, 2026
  5. v0.4.2Sep 16, 2026
  6. v0.4.1Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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