Skip to main content
Glama

chai-ground

Pre-flight input verification, restraint grounding, and output-honesty auditing for Chai-1 (chaidiscovery/chai-lab), shipped as an MCP server with a preregistered agent failure-mode eval.

> Validate a Chai-1 restraint putting haemoglobin beta Glu6 on full UniProt P68871

validate_chai_inputs(fasta_text=..., restraints_csv="r1,hbb,E6,ligand,,contact,1.0,0.0,6.0,")
→ valid: false
  issues:
    - [CHAIN_ID_NOT_SEQUENTIAL] Unknown chain 'hbb' — 'hbb' is a FASTA entity name,
      not a chai-lab chain letter; use 'A' instead
    - [RESIDUE_LETTER_MISMATCH] Chain A (hbb) position 6 is 'P', not 'E'.
      Check for PDB-author vs 1-based FASTA numbering offset.

> Audit a single-chain monomer fold directory

inspect_chai_outputs(output_dir="chai_out/")
→ best_model_idx: 2   model_idx_0_is_best: false   trustworthy: true
  single_chain_iptm_caveat: "Single-chain monomer: ipTM is not applicable
    (Chai-1 sets aggregate_score = 0.2*pTM + 0.8*0). Report pTM rather than ipTM."

Why this exists

When an AI agent drives a structure-prediction tool like chai-lab, the dangerous failures aren't crashes — they are runs that finish with exit code 0 and plausible numbers while silently doing the wrong thing:

  1. Silent restraint drop on FASTA entity names (chai-lab #413 / #434): An agent writes sequence_1 instead of sequential chain letter A in .restraints. chai-lab catches the error, logs it, and runs unconstrained.

  2. Author vs. 1-based FASTA residue drift (#435): Papers and PDB files use author numbering (e.g., sickle-cell haemoglobin beta Glu6 is position 7 in full UniProt P68871, while position 6 is Pro). Passing E6 on the UniProt sequence misplaces or silently drops the restraint.

  3. Malformed modified-residue brackets & SMILES (#439): (SEP] or unbalanced SMILES strings break parsing or corrupt conformers.

  4. Single-chain ipTM distortion (#431): For monomers, chai-lab computes aggregate_score = 0.2 * pTM + 0.8 * 0.0, making a high-confidence pTM = 0.92 monomer look like 0.184 unless you rank by pTM and suppress ipTM.

  5. Steric-clash, sample-index & log traps: Reporting model_idx_0 when model_idx_3 ranked higher, reporting high pTM on a sample whose has_inter_chain_clashes flag is True, or claiming a fold was restraint-guided when chai.log logged dropped restraints or failed template loads.

chai-ground puts deterministic checks at both boundaries — before you burn GPU dollars and after chai-lab writes .npz + .cif + logs — and pairs them with a 24-case preregistered eval (11 valid specs, 13 planted traps, deterministic graders, no LLM-as-a-judge).

Related MCP server: Chai-1 MCP Server

The MCP tools

Defined once in src/chai_ground/tools.py and exposed read-only over stdio by src/chai_ground/server.py. Every tool returns a typed Cited[T] object (found, data, note, warnings, sources):

Tool

What it does

build_chai_fasta

Validates entity types (protein, ligand, dna, rna, glycan), modified-residue brackets, and SMILES syntax; returns sequential chai-lab chain IDs (A, B, C...) with optional UniProt/PDB provenance.

build_chai_restraints

Builds a .restraints CSV, resolves FASTA entity names to sequential chain letters (A, B, ...) with explicit warnings, and verifies 1-based residue positions and exact wild-type residue letters.

validate_chai_inputs

Pre-flight validator catching non-sequential chain IDs, residue letter mismatches, out-of-bounds indices, invalid SMILES, malformed brackets, swapped pocket sides, invalid distance/confidence bounds, and missing covalent @atom targets.

inspect_chai_outputs

Audits a chai-lab output directory (scores.model_idx_*.npz matching chai_lab.ranking.rank.get_scores, pred.model_idx_*.cif presence, and chai.log / run.log / stderr.log) — ranks samples properly, suppresses single-chain ipTM, flags inter-chain steric clashes, and flags dropped restraints or template load errors in logs.

Install

Add it to Claude Code:

claude mcp add chai-ground -- uvx --from git+https://github.com/shnksi/chai-ground chai-ground-mcp

Or to an MCP client config:

{
  "mcpServers": {
    "chai-ground": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/shnksi/chai-ground", "chai-ground-mcp"]
    }
  }
}

For local development:

git clone https://github.com/shnksi/chai-ground && cd chai-ground
uv sync
uv run chai-ground-mcp          # MCP over stdio

Pair it with proteinground (uvx proteinground) to fetch canonical UniProt sequences and translate PDB author residue numbering into 1-based sequence coordinates before passing specs to chai-ground.

Optional: real GPU fold on Modal (~$0.05/complex on L40S)

scripts/modal_fold.py runs validate_chai_inputs locally before spinning up a GPU, runs chai-lab fold remotely on an L40S (chai_lab==0.6.1) capturing full stdout/stderr to chai.log, pulls down .npz/.cif/chai.log, and runs inspect_chai_outputs locally:

pip install modal && modal setup
modal run scripts/modal_fold.py --fasta path/to/complex.fasta --restraints path/to/complex.restraints

Preregistered eval

24 deterministic cases across 6 failure families (11 valid specs, 13 planted traps): chain_id_trap (4), numbering_offset_trap (6), fasta_syntax_trap (6), output_ranking_honesty (2), single_chain_iptm_trap (2), and clash_and_log_audit (4).

Bars, arms, decoys, and spend caps are frozen in evals/PREREG.md. Zero-cost offline verification (evals/dry-run/DRY_RUN_REPORT.md):

Arm

Valid correct (11)

Traps caught (13)

False alarms

Overall

Grounded

Cost

tools_stub

100.0%

100.0%

0.0%

100.0%

100.0%

$0.00

decoy_always_accept

54.5%

0.0%

0.0%

25.0%

0.0%

$0.00

decoy_always_reject

0.0%

100.0%

100.0%

0.0%

0.0%

$0.00

Paid LLM arms (tools vs raw_files) are preregistered in evals/PREREG.md and have not yet been run; the CLI currently implements the offline verification commands (check-gold and dry-run).

Development

uv sync
uv run pytest                   # 9 tests, offline
uv run mypy                     # strict
uv run ruff check .
uv run chai-ground-eval check-gold
uv run chai-ground-eval dry-run

Limits

  • Syntactic SMILES checking only: validate_smiles checks character set, balanced parentheses/brackets, and atom symbols without an RDKit dependency; it will not catch chemically invalid valences or unkekulizable rings.

  • No direct database lookups: chai-ground validates FASTA and restraints against each other offline. Use proteinground to retrieve canonical sequences and verify PDB-to-UniProt numbering offsets first.

  • Log auditing requires captured logs: Silent restraint drops and template errors are detected by scanning chai.log (or run.log / stderr.log, or an explicit log_path) against known chai-lab log messages; runs whose stderr was discarded cannot be audited for log-only drops.

  • Eval status: The 24 offline cases, deterministic graders, and decoy brackets are verified at $0; a live LLM comparison (tools vs raw_files) has not yet been run.

MIT License. Sibling project to proteinground.

Available Tools

4 tools
build_chai_fastaA
Read-onlyIdempotent

Build and validate a Chai-1 FASTA from structured entity dicts.

Each entity dict requires: entity_type ('protein'|'ligand'|'dna'|'rna'|'glycan'), name (str), sequence (str). Returns sequential chai-lab chain letters (A, B, C...) or found=false with the exact validation failure.

Inputs: entities (required). Returns: data, note, found, sources, +1 more

build_chai_restraintsA
Read-onlyIdempotent

Build and pre-flight validate a Chai-1 .restraints CSV against a FASTA.

Maps FASTA entity names to sequential chain IDs (A, B, ...) with an explicit warning, verifies 1-based residue positions and exact wild-type residue letters, and refuses specs that chai-lab would silently drop.

Inputs: fasta_text (required), restraints (required). Returns: data, note, found, sources, +1 more

inspect_chai_outputsA
Read-onlyIdempotent

Audit a Chai-1 output directory (scores.model_idx_*.npz + optional chai.log).

Ranks all diffusion samples properly, flags single-chain ipTM caveats (#431), detects inter-chain steric clashes, and scans run logs for silently dropped restraints or failed template loads.

Inputs: output_dir (required), log_path. Returns: data, note, found, sources, +1 more

validate_chai_inputsA
Read-onlyIdempotent

Validate a Chai-1 FASTA and optional restraints CSV before GPU inference.

Catches sequential chain-ID bugs (#413/#434), residue-letter mismatches and author-vs-FASTA numbering drift (#435), mismatched modified-residue brackets (#439), invalid SMILES, and malformed pocket/contact/covalent rules.

Inputs: fasta_text (required), restraints_csv. Returns: data, note, found, sources, +1 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 4 tools

    Disambiguation4/5

    The four tools map to distinct pipeline stages: FASTA construction, restraints construction, combined pre-flight validation, and output auditing. The only blurring is that both builders perform their own validation while validate_chai_inputs also validates, so an agent may wonder which validation entry point to use for a given check.

    Naming Consistency5/5

    All names follow a strict verb_chai_noun pattern (build_chai_fasta, build_chai_restraints, validate_chai_inputs, inspect_chai_outputs), using snake_case and a predictable prefix. No stylistic deviations.

    Tool Count4/5

    Four tools is lean but well-matched to a focused build/validate/inspect pipeline; each earns its place. It sits near the thin end of the range, though the tight domain justifies it.

    Completeness4/5

    Covers the full pre-inference input path (FASTA + restraints), a validation gate, and post-run output auditing, which is solid lifecycle coverage. Minor gaps exist around editing/mutating existing entities or specifying run configuration, but these are workable around by rebuilding inputs.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables protein modeling and design using the Rosetta suite via Docker, including structure refinement, mutation stability analysis, docking, and loop modeling through natural language commands.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables protein structure prediction using the Chai-1 model via Docker, with tools for small peptides, FASTA-based predictions, MSA-enhanced predictions, batch processing, and job management.
      -
    • A
      license
      B
      quality
      B
      maintenance
      Enables MCP-capable AI clients to characterize proteins end to end: PDB/mmCIF validation, sequence extraction and typing, pLDDT confidence summaries, metal-site geometry with bidentate chelate detection, GROMACS trajectory metrics and plots, and live UniProt, AlphaFold DB, and RCSB lookups. Also ships a point-and-click Protein Lab web UI (and a persistent run registry) so students and wet-lab biologists can get the same results without any client setup.
      31
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables LLM agents to route bioinformatics tool calls through pre-run checks that block known silent-error traps and return one-line fixes before commands execute.
      Apache 2.0