Skip to content
Back to search

tooluniverse

MarketplaceWorks with Claude CodeGitHubIncomplete

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 14 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/mims-harvard/tooluniverse with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/mims-harvard/tooluniverse'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/mims-harvard-tooluniverse/badge.svg)](/listings/mims-harvard-tooluniverse)

HTML

<a href="/listings/mims-harvard-tooluniverse"><img src="/api/listings/mims-harvard-tooluniverse/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

> [!IMPORTANT] > **Claude Desktop extension showing "Failed — Server disconnected"?** The copy of ToolUniverse in > Claude Desktop's built-in Extensions directory is an old build that cannot start. Remove it, then > use either option below — both install a working version. > Details and status: [#585](https://github.com/mims-harvard/ToolUniverse/issues/585)

**AI agent (recommended)** — open your AI agent and run:

Read https://aiscientist.tools/setup.md and set up ToolUniverse for me.

The agent will walk you through MCP configuration, API keys, skill installation, and validation.

<details> <summary>or set up manually</summary>

Add to your MCP config file:

{
  "mcpServers": {
    "tooluniverse": {
      "command": "uvx",
      "args": ["--refresh", "tooluniverse"],
      "env": {"PYTHONIOENCODING": "utf-8"}
    }
  }
}

`--refresh` checks PyPI for the newest release on every launch. Drop it (`"args": ["tooluniverse"]`) to start faster from `uv`'s cache — then upgrade with `uv cache clean tooluniverse`.

Install agent skills:

npx skills add mims-harvard/ToolUniverse

</details>

**Claude Code users** — one line, no config file:

claude plugin marketplace add mims-harvard/ToolUniverse
claude plugin install tooluniverse@tooluniverse

**Python developers** — install the SDK. Install [`uv`](https://docs.astral.sh/uv/) first and **do not use system `pip`**: on a current Mac, `pip install tooluniverse` fails with `externally-managed-environment` (PEP 668) and `python3 -m venv` can fail at `ensurepip`. `uv` manages its own Python and avoids both.

curl -LsSf https://astral.sh/uv/install.sh | sh   # if you don't have uv
uv venv --python 3.12 && source .venv/bin/activate
uv pip install tooluniverse

Needs Python 3.10 or newer. On an Apple Silicon Mac it also needs **macOS 14 or newer**: `faiss-cpu`, which backs the vector-search tools, publishes no arm64 wheel older than `macosx_14_0`, so macOS 13 and earlier would have to compile it. Intel Macs, Windows and Linux have no such floor.

The base install covers the API and database tools. Local ML, cheminformatics, and plotting tools need extras — `uv pip install 'tooluniverse[all]'`, or a single group such as `[ml]`, `[visualization]`, `[bioinformatics]`. Note `[all]` excludes `pdf`, `singlecell`, `smolagents`, `client`, and `build`, which install by name. Run `tooluniverse-doctor` to see which groups are missing.

**[`tu` CLI](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tu_cli.html)** — discover, inspect, run, and test tools from the terminal. **[Python SDK](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/python_guide.html)** — programmatic access for building AI scientist systems.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 20 lines
  1. {
  2. "name": "tooluniverse",
  3. "owner": {
  4. "name": "Shanghua Gao",
  5. "url": "https://shgao.site"
  6. },
  7. "metadata": {
  8. "description": "ToolUniverse marketplace \u2014 2,700+ scientific research tools and 160+ specialized skills for biology, chemistry, medicine, and data science.",
  9. "version": "1.5.10"
  10. },
  11. "plugins": [
  12. {
  13. "name": "tooluniverse",
  14. "source": "./plugin",
  15. "description": "2,700+ scientific tools (PubMed, UniProt, PubChem, TCGA, FAERS, ClinicalTrials.gov, etc.) + 160+ research skills + MCP server + research slash commands.",
  16. "category": "science",
  17. "strict": false
  18. }
  19. ]
  20. }
README.md · README · 168 lines
  1. # <img src="docs/_static/logo.png" alt="ToolUniverse Logo" height="28" style="vertical-align: middle; margin-right: 8px;" /> ToolUniverse: Democratizing AI scientists
  2. [![Documentation](https://img.shields.io/badge/Documentation-Available-green)](https://zitniklab.hms.harvard.edu/ToolUniverse/)
  3. [![Paper](https://img.shields.io/badge/Paper-Arxiv-blue)](https://arxiv.org/abs/2509.23426)
  4. [![PyPI version](https://badge.fury.io/py/tooluniverse.svg)](https://badge.fury.io/py/tooluniverse)
  5. [![MCP Registry](https://img.shields.io/badge/MCP_Registry-Listed-blue)](https://registry.modelcontextprotocol.io)
  6. [![Website](https://img.shields.io/badge/Website-aiscientist.tools-blue)](https://aiscientist.tools)
  7. [![Slack](https://img.shields.io/badge/Slack-Join_Community-orange)](https://join.slack.com/t/tooluniversehq/shared_invite/zt-3dic3eoio-5xxoJch7TLNibNQn5_AREQ)
  8. [![WeChat](https://img.shields.io/badge/WeChat-Community-07C160)](https://aiscientist.tools/wechat)
  9. [![LinkedIn](https://img.shields.io/badge/LinkedIn-Follow-0077B5)](https://www.linkedin.com/in/shanghua-gao-96b0b3168/)
  10. [![X](https://img.shields.io/badge/X-Follow-000000)](https://x.com/ScientistTools)
  11. [![PyPI Downloads](https://static.pepy.tech/personalized-badge/tooluniverse?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=BLACK&left_text=downloads)](https://pepy.tech/projects/tooluniverse)
  12. [//]: # (mcp-name: io.github.mims-harvard/tooluniverse)
  13. ## Install
  14. > [!IMPORTANT]
  15. > **Claude Desktop extension showing "Failed — Server disconnected"?** The copy of ToolUniverse in
  16. > Claude Desktop's built-in Extensions directory is an old build that cannot start. Remove it, then
  17. > use either option below — both install a working version.
  18. > Details and status: [#585](https://github.com/mims-harvard/ToolUniverse/issues/585)
  19. **AI agent (recommended)** — open your AI agent and run:
  20. ```
  21. Read https://aiscientist.tools/setup.md and set up ToolUniverse for me.
  22. ```
  23. The agent will walk you through MCP configuration, API keys, skill installation, and validation.
  24. <details>
  25. <summary>or set up manually</summary>
  26. Add to your MCP config file:
  27. ```json
  28. {
  29. "mcpServers": {
  30. "tooluniverse": {
  31. "command": "uvx",
  32. "args": ["--refresh", "tooluniverse"],
  33. "env": {"PYTHONIOENCODING": "utf-8"}
  34. }
  35. }
  36. }
  37. ```
  38. `--refresh` checks PyPI for the newest release on every launch. Drop it
  39. (`"args": ["tooluniverse"]`) to start faster from `uv`'s cache — then upgrade
  40. with `uv cache clean tooluniverse`.
  41. Install agent skills:
  42. ```bash
  43. npx skills add mims-harvard/ToolUniverse
  44. ```
  45. </details>
  46. **Claude Code users** — one line, no config file:
  47. ```bash
  48. claude plugin marketplace add mims-harvard/ToolUniverse
  49. claude plugin install tooluniverse@tooluniverse
  50. ```
  51. **Python developers** — install the SDK. Install [`uv`](https://docs.astral.sh/uv/) first and **do not use system `pip`**: on a current Mac, `pip install tooluniverse` fails with `externally-managed-environment` (PEP 668) and `python3 -m venv` can fail at `ensurepip`. `uv` manages its own Python and avoids both.
  52. ```bash
  53. curl -LsSf https://astral.sh/uv/install.sh | sh # if you don't have uv
  54. uv venv --python 3.12 && source .venv/bin/activate
  55. uv pip install tooluniverse
  56. ```
  57. Needs Python 3.10 or newer. On an Apple Silicon Mac it also needs **macOS 14 or newer**: `faiss-cpu`, which backs the vector-search tools, publishes no arm64 wheel older than `macosx_14_0`, so macOS 13 and earlier would have to compile it. Intel Macs, Windows and Linux have no such floor.
  58. The base install covers the API and database tools. Local ML, cheminformatics, and plotting tools need extras — `uv pip install 'tooluniverse[all]'`, or a single group such as `[ml]`, `[visualization]`, `[bioinformatics]`. Note `[all]` excludes `pdf`, `singlecell`, `smolagents`, `client`, and `build`, which install by name. Run `tooluniverse-doctor` to see which groups are missing.
  59. **[`tu` CLI](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tu_cli.html)** — discover, inspect, run, and test tools from the terminal.
  60. **[Python SDK](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/python_guide.html)** — programmatic access for building AI scientist systems.
  61. ## Building AI Scientists with ToolUniverse
  62. <p align="center">
  63. <a href="https://www.youtube.com/watch?v=fManSJlSs60">
  64. <img src="https://github.com/user-attachments/assets/13ddb54c-4fcc-4507-8695-1c58e7bc1e68" width="600" />
  65. </a>
  66. </p>
  67. *Click to watch the demo* [(YouTube)](https://www.youtube.com/watch?v=fManSJlSs60) [(Bilibili)](https://www.bilibili.com/video/BV1GynhzjEos/?share_source=copy_web&vd_source=b398f13447281e748f5c41057a2c6858)
  68. ## What is ToolUniverse?
  69. ToolUniverse is an ecosystem for creating AI scientist systems from any large language model. Powered by the AI-Tool Interaction Protocol, it standardizes how LLMs identify and call tools, integrating more than **2,700 machine learning models, datasets, APIs, and scientific packages** for data analysis, knowledge retrieval, and experimental design.
  70. **Key features:**
  71. - [**AI-Tool Interaction Protocol**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/interaction_protocol.html): Standardized interface governing how AI scientists issue tool requests and receive results
  72. - [**Universal AI Model Support**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/building_ai_scientists/index.html): Works with Claude, GPT, Gemini, Qwen, Deepseek, and open models
  73. - [**MCP Integration**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/building_ai_scientists/mcp_support.html): Native Model Context Protocol server with configurable transport and tool selection
  74. - [**Async Operations**](https://zitniklab.hms.harvard.edu/ToolUniverse/expand_tooluniverse/async_tools_guide.html): Long-running tasks (protein docking, molecular simulations) with progress tracking and parallel execution
  75. - [**Tool Composition**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tool_composition.html): Chain tools for sequential or parallel execution in self-directed workflows
  76. - [**Compact Mode**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/building_ai_scientists/compact_mode.html): Reduces 2,700+ tools to 4-5 core discovery tools, saving ~99% context window
  77. - [**CLI (`tu`)**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tu_cli.html): Discover, inspect, run, and test tools directly from the terminal — 14 subcommands for interactive and scripted workflows
  78. - [**Agent Skills**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/skills_showcase.html): 153 pre-built research skills for drug discovery, precision oncology, rare disease diagnosis, pharmacovigilance, and more, plus 63 that install a GPU-backed model locally
  79. - [**Literature Search**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/literature_search_tools_tutorial.html): Unified search across PubMed, Semantic Scholar, ArXiv, BioRxiv, Europe PMC, and more
  80. - [**Two-Tier Result Caching**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/cache_system.html): In-memory LRU + SQLite persistence with per-tool fingerprinting for 10x speedup, offline support, and reproducibility
  81. - [**Continuous Expansion**](https://zitniklab.hms.harvard.edu/ToolUniverse/expand_tooluniverse/index.html): Register new tools locally or remotely without additional configuration
  82. <p align="center">
  83. <img src="https://github.com/user-attachments/assets/eb15bd7c-4e73-464b-8d65-733877c96a51" width="888" />
  84. </p>
  85. ## AI Scientists Powered by ToolUniverse
  86. *Building your project with ToolUniverse? Submit via [GitHub Pull Request](https://github.com/mims-harvard/ToolUniverse/pulls) or contact us.*
  87. **TxAgent: AI Agent for Therapeutic Reasoning** [[Project]](https://zitniklab.hms.harvard.edu/TxAgent) [[Paper]](https://arxiv.org/pdf/2503.10970) [[PyPI]](https://pypi.org/project/txagent/) [[GitHub]](https://github.com/mims-harvard/TxAgent) [[HuggingFace]](https://huggingface.co/collections/mims-harvard/txagent-67c8e54a9d03a429bb0c622c)
  88. > TxAgent leverages ToolUniverse's scientific tool ecosystem to solve complex therapeutic reasoning tasks.
  89. ---
  90. **Medea: An Omics AI Agent for Therapeutic Discovery** [[Project]](https://medea.openscientist.ai) [[Paper]](https://www.biorxiv.org/content/early/2026/01/20/2026.01.16.696667) [[GitHub]](https://github.com/mims-harvard/Medea)
  91. > Medea integrates ToolUniverse tools for multi-omics analysis to identify therapeutic targets and predict drug responses across cancer, autoimmune, and other diseases.
  92. ## Workshops and Education
  93. **[Building AI Co-Scientists with ToolUniverse](https://github.com/ccb-hms/tooluniverse-ai-workshop)**
  94. > Materials from the October 8, 2026 workshop in the Core for Computational Biomedicine (CCB) AI Seminar & Workshop Series at Harvard Medical School. Includes the ToolUniverse workshop slides, CCB introduction slides, and a follow-along Markdown guide for using ToolUniverse live with clinical and genetics examples.
  95. ## Documentation
  96. Full documentation: [zitniklab.hms.harvard.edu/ToolUniverse](https://zitniklab.hms.harvard.edu/ToolUniverse/)
  97. - [CLI Reference (`tu`)](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tu_cli.html)
  98. - [Python Developer Guide](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/python_guide.html)
  99. - [AI Agent Setup](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/building_ai_scientists/index.html)
  100. - [Agent Skills](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/skills_showcase.html)
  101. - [Expand ToolUniverse](https://zitniklab.hms.harvard.edu/ToolUniverse/expand_tooluniverse/index.html)
  102. - [API Reference](https://zitniklab.hms.harvard.edu/ToolUniverse/api/modules.html)
  103. ## Community
  104. **[Shanghua Gao](https://shgao.site)**, the lead creator of this project, is currently on the job market.
  105. [Slack](https://join.slack.com/t/tooluniversehq/shared_invite/zt-3dic3eoio-5xxoJch7TLNibNQn5_AREQ) · [GitHub Issues](https://github.com/mims-harvard/ToolUniverse/issues) · [Shanghua Gao](mailto:shanghuagao@gmail.com) · [Marinka Zitnik](mailto:marinka@hms.harvard.edu)
  106. **Leaders:** [Shanghua Gao](https://shgao.site) · [Marinka Zitnik](https://zitniklab.hms.harvard.edu/)
  107. **Contributors:** [Shanghua Gao](https://shgao.site) · [Richard Zhu](https://www.linkedin.com/in/richard-zhu-4236901a7/) · [Pengwei Sui](https://psui3905.github.io/) · [Zhenglun Kong](https://zlkong.github.io/homepage/) · [Sufian Aldogom](mailto:saldogom@mit.edu) · [Yepeng Huang](https://yepeng.notion.site/Yepeng-Huang-16ad8dd1740080c28d4bd3e3d7c1080c) · [Ayush Noori](https://www.ayushnoori.com/) · [Reza Shamji](mailto:reza_shamji@hms.harvard.edu) · [Krishna Parvataneni](mailto:krishna_parvataneni@hms.harvard.edu) · [Theodoros Tsiligkaridis](https://sites.google.com/view/theo-t) · [Marinka Zitnik](https://zitniklab.hms.harvard.edu/)
  108. ## Privacy Policy
  109. ToolUniverse runs locally and collects nothing: no telemetry, no analytics, no
  110. conversation data. When you run a tool, that tool's arguments are sent to that
  111. tool's data provider (UniProt, openFDA, Open Targets and so on) so it can
  112. answer, and nothing else leaves your machine. API keys stay local and are sent
  113. only to the service they belong to. Full policy:
  114. https://github.com/mims-harvard/ToolUniverse/blob/main/PRIVACY.md
  115. ## Citation
  116. ```
  117. @article{gao2025democratizingaiscientistsusing,
  118. title={Democratizing AI scientists using ToolUniverse},
  119. author={Shanghua Gao and Richard Zhu and Pengwei Sui and Zhenglun Kong and Sufian Aldogom and Yepeng Huang and Ayush Noori and Reza Shamji and Krishna Parvataneni and Theodoros Tsiligkaridis and Marinka Zitnik},
  120. year={2025},
  121. eprint={2509.23426},
  122. archivePrefix={arXiv},
  123. primaryClass={cs.AI},
  124. url={https://arxiv.org/abs/2509.23426},
  125. }
  126. ```
plugin/hooks/hooks.json · Bundled script · 18 lines · 1 finding marked
  1. {
  2. "hooks": {
  3. "SessionStart": [
  4. {
  5. "hooks": [
  6. {
  7. "type": "command",
  8. "command": "if [ ! -f ~/.claude/.tooluniverse-plugin-cleanup-done ] && ls ~/.claude/skills/tooluniverse-* 1>/dev/null 2>&1; then rm -rf ~/.claude/skills/tooluniverse-* ~/.claude/skills/create-tooluniverse-skill ~/.claude/skills/setup-tooluniverse 2>/dev/null; touch ~/.claude/.tooluniverse-plugin-cleanup-done; echo 'ToolUniverse plugin: cleaned up legacy global skills (one-time, replaced by plugin)'; fi"
  9. },
  10. {
  11. "type": "command",
  12. "command": "command -v uvx >/dev/null 2>&1 || echo 'ToolUniverse: uv/uvx was not found, so the tooluniverse MCP server cannot start and its tools will be unavailable. Install uv with: curl -LsSf https://astral.sh/uv/install.sh | sh then restart Claude Code. Docs: https://docs.astral.sh/uv/getting-started/installation/'"
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 12 on GitHub
  13. }
  14. ]
  15. }
  16. ]
  17. }
  18. }
plugin/skills/tooluniverse-nfcore-pipelines/scripts/check_environment.py · Bundled script · 185 lines · 1 finding marked
  1. #!/usr/bin/env python3
  2. """Preflight environment check for running nf-core pipelines.
  3. Checks Docker, Nextflow, Java (required) and sra-tools (optional, only
  4. needed for SRA-accession downloads). Never fabricates a result: every check
  5. either passes with real evidence (a version string actually printed by the
  6. tool) or fails with a concrete fix instruction. Exits non-zero if any
  7. REQUIRED check fails.
  8. """
  9. import platform
  10. import re
  11. import shutil
  12. import subprocess
  13. import sys
  14. MIN_NEXTFLOW = (23, 4)
  15. MIN_JAVA = 11
  16. def run(cmd):
  17. """Run a command, return (rc, stdout+stderr) without raising."""
  18. try:
  19. p = subprocess.run(
  20. cmd, capture_output=True, text=True, timeout=30, check=False
  21. )
  22. return p.returncode, (p.stdout + p.stderr).strip()
  23. except FileNotFoundError:
  24. return 127, ""
  25. except subprocess.TimeoutExpired:
  26. return 124, "(timed out)"
  27. def is_linux():
  28. return platform.system() == "Linux"
  29. def check_docker():
  30. path = shutil.which("docker")
  31. if not path:
  32. return False, "Docker is not installed.", docker_install_hint()
  33. rc, out = run(["docker", "info"])
  34. if rc != 0:
  35. return (
  36. False,
  37. "Docker binary found but the daemon is not reachable.",
  38. "Daemon not running or no permission:\n"
  39. " sudo systemctl start docker\n"
  40. " # if 'permission denied' talking to the docker socket:\n"
  41. " sudo usermod -aG docker $USER # then log out and back in\n"
  42. f"(docker info said: {out.splitlines()[0] if out else '<no output>'})",
  43. )
  44. return True, f"Docker OK ({path}), daemon reachable.", None
  45. def docker_install_hint():
  46. if is_linux():
  47. return (
  48. "Install Docker Engine (Linux):\n"
  49. " curl -fsSL https://get.docker.com | sh\n"
  50. " sudo usermod -aG docker $USER # then log out and back in\n"
  51. "See https://docs.docker.com/engine/install/ for distro-specific steps.\n"
  52. "If you cannot get root/sudo (e.g. a locked-down sandbox), Docker cannot "
  53. "be installed here — this skill cannot run a real pipeline in that case."
  54. )
  55. return "Install Docker Desktop: https://docs.docker.com/get-docker/"
  56. def check_nextflow():
  57. path = shutil.which("nextflow")
  58. if not path:
  59. return (
  60. False,
  61. "Nextflow is not installed.",
  62. "Install Nextflow:\n"
  63. " curl -s https://get.nextflow.io | bash\n"
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 76 on GitHub
  64. " mkdir -p ~/bin && mv nextflow ~/bin/\n"
  65. " export PATH=\"$HOME/bin:$PATH\" # add to ~/.bashrc too",
  66. )
  67. rc, out = run(["nextflow", "-version"])
  68. m = re.search(r"version\s+(\d+)\.(\d+)", out)
  69. if not m:
  70. return (
  71. False,
  72. f"Nextflow found ({path}) but version could not be parsed from: {out!r}",
  73. "Try: nextflow self-update",
  74. )
  75. ver = (int(m.group(1)), int(m.group(2)))
  76. if ver < MIN_NEXTFLOW:
  77. return (
  78. False,
  79. f"Nextflow {ver[0]}.{ver[1]:02d} found, but >= "
  80. f"{MIN_NEXTFLOW[0]}.{MIN_NEXTFLOW[1]:02d} is required.",
  81. "Update: nextflow self-update",
  82. )
  83. return True, f"Nextflow {ver[0]}.{ver[1]:02d} OK ({path}).", None
  84. def check_java():
  85. path = shutil.which("java")
  86. if not path:
  87. return (
  88. False,
  89. "Java is not installed (required by Nextflow).",
  90. "Install OpenJDK 11+ (Linux, Debian/Ubuntu):\n"
  91. " sudo apt-get update && sudo apt-get install -y openjdk-17-jre-headless\n"
  92. "Other distros: use your package manager to install a JRE >= 11, "
  93. "or a user-local install via https://adoptium.net/ if you lack sudo.",
  94. )
  95. rc, out = run(["java", "-version"])
  96. # java -version prints to stderr, format varies: 'openjdk version "17.0.9"'
  97. m = re.search(r'version "(\d+)(?:\.(\d+))?', out)
  98. if not m:
  99. return (
  100. False,
  101. f"Java found ({path}) but version could not be parsed from: {out!r}",
  102. "Verify manually with: java -version",
  103. )
  104. major = int(m.group(1))
  105. # legacy versioning: "1.8.0_xxx" reports major=1 -> treat second group as major
  106. if major == 1 and m.group(2):
  107. major = int(m.group(2))
  108. if major < MIN_JAVA:
  109. return (
  110. False,
  111. f"Java {major} found, but >= {MIN_JAVA} is required.",
  112. "Install a newer JRE (see Docker/Nextflow install notes above) and "
  113. "ensure it is first on PATH, or set NXF_JAVA_HOME.",
  114. )
  115. return True, f"Java {major} OK ({path}).", None
  116. def check_sra_tools():
  117. prefetch = shutil.which("prefetch")
  118. fasterq = shutil.which("fasterq-dump")
  119. if prefetch and fasterq:
  120. return True, f"sra-tools OK (prefetch={prefetch}, fasterq-dump={fasterq}).", None
  121. return (
  122. False,
  123. "sra-tools (prefetch / fasterq-dump) not found.",
  124. "Only needed if downloading SRA data BY ACCESSION rather than by direct "
  125. "URL (see references/geo_sra_acquisition.md). Install via bioconda:\n"
  126. " mamba install -c bioconda -c conda-forge sra-tools\n"
  127. " # or conda install -c bioconda -c conda-forge sra-tools",
  128. )
  129. def main():
  130. checks = [
  131. ("Docker", check_docker, True),
  132. ("Nextflow", check_nextflow, True),
  133. ("Java", check_java, True),
  134. ("sra-tools (optional)", check_sra_tools, False),
  135. ]
  136. print(f"Platform: {platform.system()} {platform.release()} ({platform.machine()})")
  137. print("-" * 60)
  138. all_required_pass = True
  139. for label, fn, required in checks:
  140. ok, msg, fix = fn()
  141. status = "PASS" if ok else ("FAIL" if required else "WARN (optional)")
  142. print(f"[{status}] {label}: {msg}")
  143. if not ok and fix:
  144. print(" Fix:")
  145. for line in fix.splitlines():
  146. print(f" {line}")
  147. if not ok and required:
  148. all_required_pass = False
  149. print()
  150. print("-" * 60)
  151. if all_required_pass:
  152. print("All required checks passed. Safe to proceed to Step 2 (select pipeline).")
  153. return 0
  154. print(
  155. "One or more REQUIRED checks failed. Do NOT proceed to run a pipeline — "
  156. "fix the issues above first. Report this status to the user verbatim; "
  157. "do not simulate or estimate pipeline output in this state."
  158. )
  159. return 1
  160. if __name__ == "__main__":
  161. sys.exit(main())
plugin/skills/tooluniverse-protein-design-campaign/scripts/preflight_submission.py · Bundled script · 224 lines · 1 finding marked
  1. #!/usr/bin/env python3
  2. """Read-only CSV/methods preflight; no network or eligibility attestation."""
  3. import argparse
  4. import csv
  5. import hashlib
  6. import io
  7. import json
  8. import re
  9. from pathlib import Path
  10. AMINO_ACIDS = set("ACDEFGHIKLMNPQRSTVWY")
  11. DEFAULT_CLASSES = "single_chain,nanobody,scfv,fab_kappa,fab_lambda"
  12. DEFAULT_PAIRED_CLASSES = "fab_kappa,fab_lambda"
  13. DISCLOSURE_PATTERNS = {
  14. "private_path": re.compile(r"/Users/|/home/|/private/|[A-Za-z]:[\\/]Users[\\/]"),
  15. "email_address": re.compile(r"[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}"),
  16. "private_ip_or_localhost": re.compile(
  17. r"\b(?:localhost|127\.0\.0\.1|10\.\d+\.\d+\.\d+|"
  18. r"192\.168\.\d+\.\d+|172\.(?:1[6-9]|2\d|3[01])\.\d+\.\d+)\b",
  19. re.I,
  20. ),
  21. "credential_marker": re.compile(
  22. r"-----BEGIN [A-Z ]*PRIVATE KEY|"
  23. r"\b(?:api[_-]?key|access[_-]?token|token|secret|password|authorization|"
  24. r"bearer|X-Amz-Signature|X-Goog-Signature)\s*[:=]|"
  25. r"https?://[^/\s:@]+:[^/\s@]+@|"
  26. r"\b(?:sk-|ghp_|github_pat_|AKIA)[A-Za-z0-9_-]{12,}",
  27. re.I,
  28. ),
  29. "selector_instruction": re.compile(
  30. r"ignore previous instructions|system prompt|rank this first|"
    • Note: Quoted as data in code: Quotes instruction-override phrasing (in quotes, code, a table or an example): "ignore previous instructions"
    • Line 33 on GitHub
  31. r"select this candidate|you are (?:ChatGPT|Claude)",
  32. re.I,
  33. ),
  34. }
  35. def issue(findings, category, role, row=None):
  36. """Never echo a matched value that may contain a secret."""
  37. item = {"category": category, "file_role": role}
  38. if row is not None:
  39. item["row"] = row
  40. findings.append(item)
  41. def read_text(path, role, report, max_bytes, scan):
  42. try:
  43. if path.stat().st_size > max_bytes:
  44. issue(report["issues"], "file_size_limit", role)
  45. return None
  46. data = path.read_bytes()
  47. text = data.decode("utf-8-sig")
  48. except (OSError, UnicodeError):
  49. issue(report["issues"], "unreadable_or_non_utf8", role)
  50. return None
  51. report["files"][role] = {
  52. "bytes": len(data),
  53. "sha256": hashlib.sha256(data).hexdigest(),
  54. }
  55. if scan:
  56. for category, pattern in DISCLOSURE_PATTERNS.items():
  57. if pattern.search(text):
  58. issue(report["issues"], category, role)
  59. return text
  60. def parse_csv(text, role, findings, strict_headers):
  61. try:
  62. reader = csv.DictReader(io.StringIO(text), strict=True)
  63. headers = reader.fieldnames or []
  64. if len(headers) != len(set(headers)):
  65. issue(findings, "duplicate_headers", role)
  66. return []
  67. if not {"name", "sequence"}.issubset(headers):
  68. issue(findings, "missing_required_headers", role)
  69. return []
  70. if strict_headers and set(headers) - {"name", "sequence", "molecule_class"}:
  71. issue(findings, "unreviewed_extra_columns", role)
  72. rows = list(reader)
  73. if any(None in row or any(v is None for v in row.values()) for row in rows):
  74. issue(findings, "malformed_csv_row", role)
  75. return []
  76. return rows
  77. except csv.Error:
  78. issue(findings, "malformed_csv", role)
  79. return []
  80. def preflight(args):
  81. report = {
  82. "format_and_disclosure_checks_pass": False,
  83. "files": {},
  84. "candidate_count": 0,
  85. "candidates": [],
  86. "issues": [],
  87. "not_checked": [
  88. "official_novelty",
  89. "binding_or_pH_selectivity",
  90. "participant_eligibility_and_track",
  91. "intellectual_property_and_institutional_permissions",
  92. "actual_human_scientific_review",
  93. "all_possible_sensitive_information",
  94. ],
  95. }
  96. if (
  97. args.min_length < 1
  98. or args.max_length < args.min_length
  99. or args.max_designs < 1
  100. or args.max_bytes < 1
  101. ):
  102. issue(report["issues"], "invalid_limits", "configuration")
  103. return report
  104. classes = {c.strip() for c in args.classes.split(",") if c.strip()}
  105. paired_classes = {c.strip() for c in args.paired_classes.split(",") if c.strip()}
  106. if not classes:
  107. issue(report["issues"], "empty_class_vocabulary", "configuration")
  108. return report
  109. text = read_text(args.csv, "submission", report, args.max_bytes, scan=True)
  110. if args.methods:
  111. read_text(args.methods, "methods", report, args.max_bytes, scan=True)
  112. if text is None:
  113. return report
  114. rows = parse_csv(text, "submission", report["issues"], strict_headers=True)
  115. report["candidate_count"] = len(rows)
  116. if not rows or len(rows) > args.max_designs:
  117. issue(report["issues"], "candidate_count_limit", "submission")
  118. sources = None
  119. if args.source_csv:
  120. source = read_text(
  121. args.source_csv, "source", report, args.max_bytes, scan=False
  122. )
  123. source_rows = (
  124. parse_csv(source, "source", report["issues"], strict_headers=False)
  125. if source is not None
  126. else []
  127. )
  128. sources = {}
  129. for r in source_rows:
  130. if r["name"] in sources:
  131. issue(report["issues"], "duplicate_source_name", "source")
  132. sources[r["name"]] = r
  133. names, sequences = set(), set()
  134. for row_number, row in enumerate(rows, start=2):
  135. name, seq = row["name"], row["sequence"]
  136. cls = row.get("molecule_class") or args.default_class
  137. # Only hashes, counts and row numbers are emitted, never the sequence/name.
  138. report["candidates"].append(
  139. {
  140. "csv_row": row_number,
  141. "sequence_sha256": hashlib.sha256(seq.encode()).hexdigest(),
  142. "chain_lengths": [len(c) for c in seq.split(":")],
  143. }
  144. )
  145. if any(
  146. value.lstrip().startswith(("=", "+", "-", "@")) for value in row.values()
  147. ):
  148. issue(
  149. report["issues"], "spreadsheet_formula_cell", "submission", row_number
  150. )
  151. if not name or name != name.strip() or any(ord(c) < 32 for c in name):
  152. issue(report["issues"], "invalid_name", "submission", row_number)
  153. if name in names:
  154. issue(report["issues"], "duplicate_name", "submission", row_number)
  155. if seq in sequences:
  156. issue(report["issues"], "duplicate_sequence", "submission", row_number)
  157. names.add(name)
  158. sequences.add(seq)
  159. if cls not in classes:
  160. issue(
  161. report["issues"], "unsupported_molecule_class", "submission", row_number
  162. )
  163. chains = seq.split(":")
  164. expected_chains = 2 if cls in paired_classes else 1
  165. if len(chains) != expected_chains:
  166. issue(report["issues"], "chain_format", "submission", row_number)
  167. if any(not c or set(c) - AMINO_ACIDS for c in chains):
  168. issue(report["issues"], "invalid_amino_acids", "submission", row_number)
  169. if any(not args.min_length <= len(c) <= args.max_length for c in chains):
  170. issue(report["issues"], "chain_length_limit", "submission", row_number)
  171. if sources is not None:
  172. original = sources.get(name)
  173. if (
  174. original is None
  175. or original["sequence"] != seq
  176. or (original.get("molecule_class") or args.default_class) != cls
  177. ):
  178. issue(
  179. report["issues"],
  180. "source_identity_mismatch",
  181. "submission",
  182. row_number,
  183. )
  184. report["format_and_disclosure_checks_pass"] = not report["issues"]
  185. return report
  186. def main():
  187. parser = argparse.ArgumentParser(description=__doc__)
  188. parser.add_argument("csv", type=Path)
  189. parser.add_argument("--methods", type=Path)
  190. parser.add_argument("--source-csv", type=Path)
  191. parser.add_argument("--min-length", type=int, default=10)
  192. parser.add_argument("--max-length", type=int, default=250)
  193. parser.add_argument("--max-designs", type=int, default=20)
  194. parser.add_argument("--max-bytes", type=int, default=5_000_000)
  195. parser.add_argument("--classes", default=DEFAULT_CLASSES)
  196. parser.add_argument(
  197. "--paired-classes",
  198. default=DEFAULT_PAIRED_CLASSES,
  199. help="Comma-separated class labels requiring two colon-separated chains; configure from portal rules.",
  200. )
  201. parser.add_argument("--default-class", default="single_chain")
  202. args = parser.parse_args()
  203. report = preflight(args)
  204. print(json.dumps(report, indent=2))
  205. return 0 if report["format_and_disclosure_checks_pass"] else 2
  206. if __name__ == "__main__":
  207. raise SystemExit(main())

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.