Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

trRosettaRNA2 MCP

Wraps trRosettaRNA2, a deep learning RNA 3D structure prediction protocol. From a multiple sequence alignment (MSA) it predicts secondary structure, then end-to-end 3D structure, with optional PyRosetta energy-minimisation refinement.

Quick Start with Docker

Approach 1: Pull Pre-built Image from GitHub

docker pull ghcr.io/macromnex/trrosettarna2_mcp:latest
claude mcp add trrosettarna2 -- docker run -i --rm --user `id -u`:`id -g` --gpus all --ipc=host -v `pwd`:`pwd` ghcr.io/macromnex/trrosettarna2_mcp:latest

Approach 2: Build Docker Image Locally

git clone https://github.com/MacromNex/trrosettarna2_mcp.git
cd trrosettarna2_mcp
docker build -t trrosettarna2_mcp:latest .
claude mcp add trrosettarna2 -- docker run -i --rm --user `id -u`:`id -g` --gpus all --ipc=host -v `pwd`:`pwd` trrosettarna2_mcp:latest

Note: Run from your project directory; `pwd` is mounted so the server can read your inputs and write outputs. Use absolute paths under that directory for input and output files.

PyRosetta (license required, not in the image). The trRosettaRNA2 weights are baked in, and predict_secondary_structure works out of the box. Every 3D tool, however, runs PyRosetta relaxation after folding (upstream default -relax_steps 200), and submit_pyrosetta_refinement needs PyRosetta too. Without it the 3D tools write model_1_unrelaxed.pdb, model_1_2D.npz and plddt.csv and then report an error (No module named 'pyrosetta'). If you hold a PyRosetta license, mount a Python 3.10 PyRosetta package (e.g. from conda install -c https://conda.rosettacommons.org pyrosetta) into the image's env:

-v /path/to/env/lib/python3.10/site-packages/pyrosetta:/app/env/lib/python3.10/site-packages/pyrosetta:ro

Add it before the image name in the claude mcp add ... docker run command.

MSA generation needs the RNAcentral database (~32 GB, see below). Mount its directory and pass the mounted path as database, e.g. -v /data/rnacentral:/data/rnacentral:ro.

In the container TRRNA2_ALLOWED_ROOTS=/, so any mounted path is accepted.

Quick Start

Prerequisites

  • Conda or Mamba (mamba was used here)
  • Python 3.10 (pinned by the upstream environment.yml)
  • NVIDIA GPU with CUDA (tested on 2x A100-PCIE-40GB, driver 580.173.02)

Installation

# From this MCP's root directory

# 1. Create the conda environment from the upstream environment.yml
mamba env create -f repo/trRosettaRNA2/environment.yml -p ./env -y

# 2. Download and extract the pretrained weights (~111 MB extracted)
wget http://yanglab.qd.sdu.edu.cn/trRosettaRNA/download/params_trRNA2.tar.bz2
tar -jxvf params_trRNA2.tar.bz2
mv params examples/models/params

# 3. Install MCP server and missing runtime dependencies into the same env.
#    PYTHONNOUSERSITE=1 and --no-user are required: without them pip treats
#    packages found in ~/.local/lib/python3.10/site-packages as satisfied and
#    installs nothing, leaving the env broken for any isolated run.
PYTHONNOUSERSITE=1 ./env/bin/pip install --no-user fastmcp loguru click absl-py wrapt

absl-py, loguru and wrapt are not in the upstream environment.yml. ml_collections (imported by trRNA2.utils_3d.constants) needs absl, and dm-tree needs wrapt, so without them python -m trRNA2.predict fails at import with ModuleNotFoundError: No module named 'absl'.

(Optional) RNAcentral database for MSA generation

submit_msa_generation needs a RNAcentral-derived database, not bundled here:

bash repo/trRosettaRNA2/scripts/download_database.sh /path/to/database/dir

This fetches library.tar.bz2 (9.57 GB) and extracts it to 38 GB: rnacentral_99_rep_seq.fasta (23.5 GB, 34,218,812 sequences) plus a pre-built 6-volume BLAST index.

On this host it is installed at /mnt/data/data_repository/bio-seq/rna/RNAcentral/library/, and the trrosettarna2 entry in ~/.claude.json sets

TRRNA2_ALLOWED_ROOTS=<mcp_dir>:/mnt/data/data_repository/bio-seq/rna/RNAcentral

so the containment check accepts the database path. Any database outside the MCP directory needs the same treatment.

Running the MCP server

./env/bin/python src/server.py

Registration with Claude Code (local scope):

claude mcp add trrosettarna2 \
  /home/xux/Desktop/AgentMCP/NucleicMCP/tool-mcps/trrosettarna2_mcp/env/bin/python \
  /home/xux/Desktop/AgentMCP/NucleicMCP/tool-mcps/trrosettarna2_mcp/src/server.py

MCP Tools

Six use cases, each with a synchronous form and a submit_* form that returns a job id, plus five job-management tools (16 in total).

Tool Use case Form
predict_structure_from_msa RNA 3D structure prediction from MSA sync
predict_single_sequence_structure Single-sequence 3D structure prediction sync
predict_secondary_structure Secondary structure (trRNA2-SS 3-model ensemble) sync
predict_structure_with_custom_ss 3D structure under a user-supplied SS constraint sync
submit_structure_from_msa as above async
submit_single_sequence_structure as above async
submit_secondary_structure as above async
submit_structure_with_custom_ss as above async
submit_pyrosetta_refinement PyRosetta energy-minimisation refinement async only
submit_msa_generation MSA generation against RNAcentral async only
get_job_status, get_job_result, get_job_log, cancel_job, list_jobs job management —

PyRosetta refinement and MSA generation are submit-only: both run far longer than a client will comfortably block on. A 76-nt tRNA searched against the 34-million-sequence RNAcentral database takes ~45 minutes and returns ~895,000 aligned sequences. The remaining synchronous tools carry a 1800 s ceiling.

Structure tools return the predicted PDB paths, the 2D geometry .npz, and the mean pLDDT parsed from plddt.csv.

All structure tools take gpu (index, or -1 for CPU; default 0), nrows (maximum MSA rows fed to the network, default 500) and num_recycles (default 3). gpu is what lets two predictions run at once on a multi-GPU host -- submit one job per device. Raise nrows when working from a deep alignment: submit_msa_generation can return hundreds of thousands of sequences and the default keeps only the first 500. predict_secondary_structure returns the base-pair probability matrix, a thresholded CT file, and the number of predicted pairs.

Path containment

scripts/lib/path_utils.py confines every input and output path to the MCP installation directory, resolving symlinks before any mkdir so a symlink cannot redirect a write. Widen it with TRRNA2_ALLOWED_ROOTS (an os.pathsep-separated list) when inputs or the RNAcentral database live elsewhere.

Relative paths are resolved against the MCP install directory, not the client's working directory, because the job manager runs each script with that as its cwd. Pass absolute paths to avoid surprises.

Directory Structure

./
├── README.md
├── env/                    # conda environment (Python 3.10)
├── src/
│   ├── server.py           # FastMCP server, 16 tools
│   └── jobs/manager.py     # durable background job manager
├── scripts/
│   ├── predict_structure.py            # UC-001/002/005/006
│   ├── predict_secondary_structure.py  # UC-003
│   ├── generate_msa.py                 # UC-004
│   └── lib/                # path containment + trRNA2 runtime helpers
├── examples/
│   ├── use_case_*.py       # standalone scripts the MCP tools were derived from
│   ├── data/               # demo MSA, FASTA, SS files
│   └── models/params/      # pretrained weights
├── jobs/                   # per-job metadata, logs and results
├── reports/
└── repo/trRosettaRNA2/     # upstream repository

Troubleshooting

  • ModuleNotFoundError: No module named 'absl' — the environment is missing absl-py; see step 3 of Installation. The scripts and job manager set PYTHONNOUSERSITE=1, so dependencies present only in ~/.local are deliberately not visible.
  • Path is outside allowed roots — the input or output path resolves outside the MCP directory. Pass a path inside it, or set TRRNA2_ALLOWED_ROOTS.
  • pip dependency-conflict warnings naming unrelated packages (boltz, metagpt, lancedb) come from ~/.local/lib/python3.10/site-packages being scanned by the resolver; they are noise, but note that the same leakage previously masked the three genuinely missing packages above.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages