tooluniverse
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
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
Markdown
[](/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
- {
- "name": "tooluniverse",
- "owner": {
- "name": "Shanghua Gao",
- "url": "https://shgao.site"
- },
- "metadata": {
- "description": "ToolUniverse marketplace \u2014 2,700+ scientific research tools and 160+ specialized skills for biology, chemistry, medicine, and data science.",
- "version": "1.5.10"
- },
- "plugins": [
- {
- "name": "tooluniverse",
- "source": "./plugin",
- "description": "2,700+ scientific tools (PubMed, UniProt, PubChem, TCGA, FAERS, ClinicalTrials.gov, etc.) + 160+ research skills + MCP server + research slash commands.",
- "category": "science",
- "strict": false
- }
- ]
- }
README.md · README · 168 lines
- # <img src="docs/_static/logo.png" alt="ToolUniverse Logo" height="28" style="vertical-align: middle; margin-right: 8px;" /> ToolUniverse: Democratizing AI scientists
- [](https://zitniklab.hms.harvard.edu/ToolUniverse/)
- [](https://arxiv.org/abs/2509.23426)
- [](https://badge.fury.io/py/tooluniverse)
- [](https://registry.modelcontextprotocol.io)
- [](https://aiscientist.tools)
- [](https://join.slack.com/t/tooluniversehq/shared_invite/zt-3dic3eoio-5xxoJch7TLNibNQn5_AREQ)
- [](https://aiscientist.tools/wechat)
- [](https://www.linkedin.com/in/shanghua-gao-96b0b3168/)
- [](https://x.com/ScientistTools)
- [](https://pepy.tech/projects/tooluniverse)
- [//]: # (mcp-name: io.github.mims-harvard/tooluniverse)
- ## Install
- > [!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:
- ```json
- {
- "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:
- ```bash
- npx skills add mims-harvard/ToolUniverse
- ```
- </details>
- **Claude Code users** — one line, no config file:
- ```bash
- 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.
- ```bash
- 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.
- ## Building AI Scientists with ToolUniverse
- <p align="center">
- <a href="https://www.youtube.com/watch?v=fManSJlSs60">
- <img src="https://github.com/user-attachments/assets/13ddb54c-4fcc-4507-8695-1c58e7bc1e68" width="600" />
- </a>
- </p>
- *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)
- ## What is ToolUniverse?
- 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.
- **Key features:**
- - [**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
- - [**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
- - [**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
- - [**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
- - [**Tool Composition**](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tool_composition.html): Chain tools for sequential or parallel execution in self-directed workflows
- - [**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
- - [**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
- - [**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
- - [**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
- - [**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
- - [**Continuous Expansion**](https://zitniklab.hms.harvard.edu/ToolUniverse/expand_tooluniverse/index.html): Register new tools locally or remotely without additional configuration
- <p align="center">
- <img src="https://github.com/user-attachments/assets/eb15bd7c-4e73-464b-8d65-733877c96a51" width="888" />
- </p>
- ## AI Scientists Powered by ToolUniverse
- *Building your project with ToolUniverse? Submit via [GitHub Pull Request](https://github.com/mims-harvard/ToolUniverse/pulls) or contact us.*
- **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)
- > TxAgent leverages ToolUniverse's scientific tool ecosystem to solve complex therapeutic reasoning tasks.
- ---
- **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)
- > Medea integrates ToolUniverse tools for multi-omics analysis to identify therapeutic targets and predict drug responses across cancer, autoimmune, and other diseases.
- ## Workshops and Education
- **[Building AI Co-Scientists with ToolUniverse](https://github.com/ccb-hms/tooluniverse-ai-workshop)**
- > 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.
- ## Documentation
- Full documentation: [zitniklab.hms.harvard.edu/ToolUniverse](https://zitniklab.hms.harvard.edu/ToolUniverse/)
- - [CLI Reference (`tu`)](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/tu_cli.html)
- - [Python Developer Guide](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/python_guide.html)
- - [AI Agent Setup](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/building_ai_scientists/index.html)
- - [Agent Skills](https://zitniklab.hms.harvard.edu/ToolUniverse/guide/skills_showcase.html)
- - [Expand ToolUniverse](https://zitniklab.hms.harvard.edu/ToolUniverse/expand_tooluniverse/index.html)
- - [API Reference](https://zitniklab.hms.harvard.edu/ToolUniverse/api/modules.html)
- ## Community
- **[Shanghua Gao](https://shgao.site)**, the lead creator of this project, is currently on the job market.
- [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)
- **Leaders:** [Shanghua Gao](https://shgao.site) · [Marinka Zitnik](https://zitniklab.hms.harvard.edu/)
- **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/)
- ## Privacy Policy
- ToolUniverse runs locally and collects nothing: no telemetry, no analytics, no
- conversation data. When you run a tool, that tool's arguments are sent to that
- tool's data provider (UniProt, openFDA, Open Targets and so on) so it can
- answer, and nothing else leaves your machine. API keys stay local and are sent
- only to the service they belong to. Full policy:
- https://github.com/mims-harvard/ToolUniverse/blob/main/PRIVACY.md
- ## Citation
- ```
- @article{gao2025democratizingaiscientistsusing,
- title={Democratizing AI scientists using ToolUniverse},
- 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},
- year={2025},
- eprint={2509.23426},
- archivePrefix={arXiv},
- primaryClass={cs.AI},
- url={https://arxiv.org/abs/2509.23426},
- }
- ```
plugin/hooks/hooks.json · Bundled script · 18 lines · 1 finding marked
- {
- "hooks": {
- "SessionStart": [
- {
- "hooks": [
- {
- "type": "command",
- "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"
- },
- {
- "type": "command",
- "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
- }
- ]
- }
- ]
- }
- }
plugin/skills/tooluniverse-nfcore-pipelines/scripts/check_environment.py · Bundled script · 185 lines · 1 finding marked
- #!/usr/bin/env python3
- """Preflight environment check for running nf-core pipelines.
- Checks Docker, Nextflow, Java (required) and sra-tools (optional, only
- needed for SRA-accession downloads). Never fabricates a result: every check
- either passes with real evidence (a version string actually printed by the
- tool) or fails with a concrete fix instruction. Exits non-zero if any
- REQUIRED check fails.
- """
- import platform
- import re
- import shutil
- import subprocess
- import sys
- MIN_NEXTFLOW = (23, 4)
- MIN_JAVA = 11
- def run(cmd):
- """Run a command, return (rc, stdout+stderr) without raising."""
- try:
- p = subprocess.run(
- cmd, capture_output=True, text=True, timeout=30, check=False
- )
- return p.returncode, (p.stdout + p.stderr).strip()
- except FileNotFoundError:
- return 127, ""
- except subprocess.TimeoutExpired:
- return 124, "(timed out)"
- def is_linux():
- return platform.system() == "Linux"
- def check_docker():
- path = shutil.which("docker")
- if not path:
- return False, "Docker is not installed.", docker_install_hint()
- rc, out = run(["docker", "info"])
- if rc != 0:
- return (
- False,
- "Docker binary found but the daemon is not reachable.",
- "Daemon not running or no permission:\n"
- " sudo systemctl start docker\n"
- " # if 'permission denied' talking to the docker socket:\n"
- " sudo usermod -aG docker $USER # then log out and back in\n"
- f"(docker info said: {out.splitlines()[0] if out else '<no output>'})",
- )
- return True, f"Docker OK ({path}), daemon reachable.", None
- def docker_install_hint():
- if is_linux():
- return (
- "Install Docker Engine (Linux):\n"
- " curl -fsSL https://get.docker.com | sh\n"
- " sudo usermod -aG docker $USER # then log out and back in\n"
- "See https://docs.docker.com/engine/install/ for distro-specific steps.\n"
- "If you cannot get root/sudo (e.g. a locked-down sandbox), Docker cannot "
- "be installed here — this skill cannot run a real pipeline in that case."
- )
- return "Install Docker Desktop: https://docs.docker.com/get-docker/"
- def check_nextflow():
- path = shutil.which("nextflow")
- if not path:
- return (
- False,
- "Nextflow is not installed.",
- "Install Nextflow:\n"
- " 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
- " mkdir -p ~/bin && mv nextflow ~/bin/\n"
- " export PATH=\"$HOME/bin:$PATH\" # add to ~/.bashrc too",
- )
- rc, out = run(["nextflow", "-version"])
- m = re.search(r"version\s+(\d+)\.(\d+)", out)
- if not m:
- return (
- False,
- f"Nextflow found ({path}) but version could not be parsed from: {out!r}",
- "Try: nextflow self-update",
- )
- ver = (int(m.group(1)), int(m.group(2)))
- if ver < MIN_NEXTFLOW:
- return (
- False,
- f"Nextflow {ver[0]}.{ver[1]:02d} found, but >= "
- f"{MIN_NEXTFLOW[0]}.{MIN_NEXTFLOW[1]:02d} is required.",
- "Update: nextflow self-update",
- )
- return True, f"Nextflow {ver[0]}.{ver[1]:02d} OK ({path}).", None
- def check_java():
- path = shutil.which("java")
- if not path:
- return (
- False,
- "Java is not installed (required by Nextflow).",
- "Install OpenJDK 11+ (Linux, Debian/Ubuntu):\n"
- " sudo apt-get update && sudo apt-get install -y openjdk-17-jre-headless\n"
- "Other distros: use your package manager to install a JRE >= 11, "
- "or a user-local install via https://adoptium.net/ if you lack sudo.",
- )
- rc, out = run(["java", "-version"])
- # java -version prints to stderr, format varies: 'openjdk version "17.0.9"'
- m = re.search(r'version "(\d+)(?:\.(\d+))?', out)
- if not m:
- return (
- False,
- f"Java found ({path}) but version could not be parsed from: {out!r}",
- "Verify manually with: java -version",
- )
- major = int(m.group(1))
- # legacy versioning: "1.8.0_xxx" reports major=1 -> treat second group as major
- if major == 1 and m.group(2):
- major = int(m.group(2))
- if major < MIN_JAVA:
- return (
- False,
- f"Java {major} found, but >= {MIN_JAVA} is required.",
- "Install a newer JRE (see Docker/Nextflow install notes above) and "
- "ensure it is first on PATH, or set NXF_JAVA_HOME.",
- )
- return True, f"Java {major} OK ({path}).", None
- def check_sra_tools():
- prefetch = shutil.which("prefetch")
- fasterq = shutil.which("fasterq-dump")
- if prefetch and fasterq:
- return True, f"sra-tools OK (prefetch={prefetch}, fasterq-dump={fasterq}).", None
- return (
- False,
- "sra-tools (prefetch / fasterq-dump) not found.",
- "Only needed if downloading SRA data BY ACCESSION rather than by direct "
- "URL (see references/geo_sra_acquisition.md). Install via bioconda:\n"
- " mamba install -c bioconda -c conda-forge sra-tools\n"
- " # or conda install -c bioconda -c conda-forge sra-tools",
- )
- def main():
- checks = [
- ("Docker", check_docker, True),
- ("Nextflow", check_nextflow, True),
- ("Java", check_java, True),
- ("sra-tools (optional)", check_sra_tools, False),
- ]
- print(f"Platform: {platform.system()} {platform.release()} ({platform.machine()})")
- print("-" * 60)
- all_required_pass = True
- for label, fn, required in checks:
- ok, msg, fix = fn()
- status = "PASS" if ok else ("FAIL" if required else "WARN (optional)")
- print(f"[{status}] {label}: {msg}")
- if not ok and fix:
- print(" Fix:")
- for line in fix.splitlines():
- print(f" {line}")
- if not ok and required:
- all_required_pass = False
- print()
- print("-" * 60)
- if all_required_pass:
- print("All required checks passed. Safe to proceed to Step 2 (select pipeline).")
- return 0
- print(
- "One or more REQUIRED checks failed. Do NOT proceed to run a pipeline — "
- "fix the issues above first. Report this status to the user verbatim; "
- "do not simulate or estimate pipeline output in this state."
- )
- return 1
- if __name__ == "__main__":
- sys.exit(main())
plugin/skills/tooluniverse-protein-design-campaign/scripts/preflight_submission.py · Bundled script · 224 lines · 1 finding marked
- #!/usr/bin/env python3
- """Read-only CSV/methods preflight; no network or eligibility attestation."""
- import argparse
- import csv
- import hashlib
- import io
- import json
- import re
- from pathlib import Path
- AMINO_ACIDS = set("ACDEFGHIKLMNPQRSTVWY")
- DEFAULT_CLASSES = "single_chain,nanobody,scfv,fab_kappa,fab_lambda"
- DEFAULT_PAIRED_CLASSES = "fab_kappa,fab_lambda"
- DISCLOSURE_PATTERNS = {
- "private_path": re.compile(r"/Users/|/home/|/private/|[A-Za-z]:[\\/]Users[\\/]"),
- "email_address": re.compile(r"[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}"),
- "private_ip_or_localhost": re.compile(
- r"\b(?:localhost|127\.0\.0\.1|10\.\d+\.\d+\.\d+|"
- r"192\.168\.\d+\.\d+|172\.(?:1[6-9]|2\d|3[01])\.\d+\.\d+)\b",
- re.I,
- ),
- "credential_marker": re.compile(
- r"-----BEGIN [A-Z ]*PRIVATE KEY|"
- r"\b(?:api[_-]?key|access[_-]?token|token|secret|password|authorization|"
- r"bearer|X-Amz-Signature|X-Goog-Signature)\s*[:=]|"
- r"https?://[^/\s:@]+:[^/\s@]+@|"
- r"\b(?:sk-|ghp_|github_pat_|AKIA)[A-Za-z0-9_-]{12,}",
- re.I,
- ),
- "selector_instruction": re.compile(
- 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
- r"select this candidate|you are (?:ChatGPT|Claude)",
- re.I,
- ),
- }
- def issue(findings, category, role, row=None):
- """Never echo a matched value that may contain a secret."""
- item = {"category": category, "file_role": role}
- if row is not None:
- item["row"] = row
- findings.append(item)
- def read_text(path, role, report, max_bytes, scan):
- try:
- if path.stat().st_size > max_bytes:
- issue(report["issues"], "file_size_limit", role)
- return None
- data = path.read_bytes()
- text = data.decode("utf-8-sig")
- except (OSError, UnicodeError):
- issue(report["issues"], "unreadable_or_non_utf8", role)
- return None
- report["files"][role] = {
- "bytes": len(data),
- "sha256": hashlib.sha256(data).hexdigest(),
- }
- if scan:
- for category, pattern in DISCLOSURE_PATTERNS.items():
- if pattern.search(text):
- issue(report["issues"], category, role)
- return text
- def parse_csv(text, role, findings, strict_headers):
- try:
- reader = csv.DictReader(io.StringIO(text), strict=True)
- headers = reader.fieldnames or []
- if len(headers) != len(set(headers)):
- issue(findings, "duplicate_headers", role)
- return []
- if not {"name", "sequence"}.issubset(headers):
- issue(findings, "missing_required_headers", role)
- return []
- if strict_headers and set(headers) - {"name", "sequence", "molecule_class"}:
- issue(findings, "unreviewed_extra_columns", role)
- rows = list(reader)
- if any(None in row or any(v is None for v in row.values()) for row in rows):
- issue(findings, "malformed_csv_row", role)
- return []
- return rows
- except csv.Error:
- issue(findings, "malformed_csv", role)
- return []
- def preflight(args):
- report = {
- "format_and_disclosure_checks_pass": False,
- "files": {},
- "candidate_count": 0,
- "candidates": [],
- "issues": [],
- "not_checked": [
- "official_novelty",
- "binding_or_pH_selectivity",
- "participant_eligibility_and_track",
- "intellectual_property_and_institutional_permissions",
- "actual_human_scientific_review",
- "all_possible_sensitive_information",
- ],
- }
- if (
- args.min_length < 1
- or args.max_length < args.min_length
- or args.max_designs < 1
- or args.max_bytes < 1
- ):
- issue(report["issues"], "invalid_limits", "configuration")
- return report
- classes = {c.strip() for c in args.classes.split(",") if c.strip()}
- paired_classes = {c.strip() for c in args.paired_classes.split(",") if c.strip()}
- if not classes:
- issue(report["issues"], "empty_class_vocabulary", "configuration")
- return report
- text = read_text(args.csv, "submission", report, args.max_bytes, scan=True)
- if args.methods:
- read_text(args.methods, "methods", report, args.max_bytes, scan=True)
- if text is None:
- return report
- rows = parse_csv(text, "submission", report["issues"], strict_headers=True)
- report["candidate_count"] = len(rows)
- if not rows or len(rows) > args.max_designs:
- issue(report["issues"], "candidate_count_limit", "submission")
- sources = None
- if args.source_csv:
- source = read_text(
- args.source_csv, "source", report, args.max_bytes, scan=False
- )
- source_rows = (
- parse_csv(source, "source", report["issues"], strict_headers=False)
- if source is not None
- else []
- )
- sources = {}
- for r in source_rows:
- if r["name"] in sources:
- issue(report["issues"], "duplicate_source_name", "source")
- sources[r["name"]] = r
- names, sequences = set(), set()
- for row_number, row in enumerate(rows, start=2):
- name, seq = row["name"], row["sequence"]
- cls = row.get("molecule_class") or args.default_class
- # Only hashes, counts and row numbers are emitted, never the sequence/name.
- report["candidates"].append(
- {
- "csv_row": row_number,
- "sequence_sha256": hashlib.sha256(seq.encode()).hexdigest(),
- "chain_lengths": [len(c) for c in seq.split(":")],
- }
- )
- if any(
- value.lstrip().startswith(("=", "+", "-", "@")) for value in row.values()
- ):
- issue(
- report["issues"], "spreadsheet_formula_cell", "submission", row_number
- )
- if not name or name != name.strip() or any(ord(c) < 32 for c in name):
- issue(report["issues"], "invalid_name", "submission", row_number)
- if name in names:
- issue(report["issues"], "duplicate_name", "submission", row_number)
- if seq in sequences:
- issue(report["issues"], "duplicate_sequence", "submission", row_number)
- names.add(name)
- sequences.add(seq)
- if cls not in classes:
- issue(
- report["issues"], "unsupported_molecule_class", "submission", row_number
- )
- chains = seq.split(":")
- expected_chains = 2 if cls in paired_classes else 1
- if len(chains) != expected_chains:
- issue(report["issues"], "chain_format", "submission", row_number)
- if any(not c or set(c) - AMINO_ACIDS for c in chains):
- issue(report["issues"], "invalid_amino_acids", "submission", row_number)
- if any(not args.min_length <= len(c) <= args.max_length for c in chains):
- issue(report["issues"], "chain_length_limit", "submission", row_number)
- if sources is not None:
- original = sources.get(name)
- if (
- original is None
- or original["sequence"] != seq
- or (original.get("molecule_class") or args.default_class) != cls
- ):
- issue(
- report["issues"],
- "source_identity_mismatch",
- "submission",
- row_number,
- )
- report["format_and_disclosure_checks_pass"] = not report["issues"]
- return report
- def main():
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument("csv", type=Path)
- parser.add_argument("--methods", type=Path)
- parser.add_argument("--source-csv", type=Path)
- parser.add_argument("--min-length", type=int, default=10)
- parser.add_argument("--max-length", type=int, default=250)
- parser.add_argument("--max-designs", type=int, default=20)
- parser.add_argument("--max-bytes", type=int, default=5_000_000)
- parser.add_argument("--classes", default=DEFAULT_CLASSES)
- parser.add_argument(
- "--paired-classes",
- default=DEFAULT_PAIRED_CLASSES,
- help="Comma-separated class labels requiring two colon-separated chains; configure from portal rules.",
- )
- parser.add_argument("--default-class", default="single_chain")
- args = parser.parse_args()
- report = preflight(args)
- print(json.dumps(report, indent=2))
- return 0 if report["format_and_disclosure_checks_pass"] else 2
- if __name__ == "__main__":
- raise SystemExit(main())
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.