Skip to main content

An MCP server wrapping just-prs — PGS Catalog search and polygenic risk score computation

Project description

just-prs-mcp

An MCP server that wraps just-prs — a Polars-based tool for Polygenic Risk Scores (PRS) from the PGS Catalog. It exposes catalog search, PRS computation, VCF/array normalization, percentile & absolute-risk estimation, quality assessment, and (in extended mode) bulk downloads and reference-panel / pgen scoring as MCP tools.

Built on uv + FastMCP.

Agents: start with AGENTS.md.

Highlights

  • Hybrid tool registration with modes — a small always-on essentials surface (catalog lookup + the core compute/analyze workflow) plus an extended surface (batch, bulk downloads, HuggingFace upload, reference/pgen scoring) registered on opt-in. Keeps the default tool list small.
  • Real background tasks — slow operations (normalize_vcf, compute_prs_batch, downloads, reference scoring) run as @mcp.tool(task=True) with FastMCP's in-memory backend (no Redis); FASTMCP_DOCKET_URL switches to Redis for scale.
  • Structured I/O via Pydantic models + tool annotations — just-prs's own PRSResult / AbsoluteRisk / TraitInfo are returned directly where they fit.
  • Boot-safe — the server starts with no environment configured; no API key is required for any core feature.
  • In-memory test harness (Client(transport=server)) — fast, deterministic, network-free.

Quickstart

uv sync                                  # install deps (incl. dev)
uv sync --extra reference                # + pgenlib for reference/pgen tools (Linux/WSL)
uv run pytest                            # tests, all in-memory (no network)
uv run just-prs-mcp stdio                # run over stdio
uv run just-prs-mcp stdio --mode extended  # expose the full tool surface
uv run just-prs-mcp http                 # run over HTTP (default :3011)
uv run fastmcp dev fastmcp.json          # MCP Inspector

The server boots with no environment configured.

Tools

Tool Tier Notes
search_scores essentials Search the PGS Catalog by free text
score_info essentials Cleaned metadata for one PGS ID
best_performance essentials Best evaluation metrics (OR/HR/AUROC/C-index)
search_traits essentials REST trait search
trait_info essentials Trait by EFO ID + associated PGS IDs
normalize_vcf essentials VCF → genotype Parquet (background task)
compute_prs essentials Score one VCF against one PGS
percentile essentials Percentile of a PRS value (reference/theoretical/AUROC)
absolute_risk essentials Absolute disease risk from a PRS z-score
assess_quality essentials Quality label + interpretation (pure logic)
compute_prs_batch extended Score one VCF against many PGS (background task)
normalize_array extended 23andMe / AncestryDNA → Parquet (background task)
download_scoring_file extended One harmonized scoring file from EBI FTP
list_pgs_ids extended All PGS IDs on EBI FTP
download_all_metadata extended All metadata sheets as Parquet (background task)
bulk_download_scores extended Many/all scoring files (background task)
push_catalog_to_hf extended Upload cleaned catalog to HuggingFace (needs token)
download_reference_panel extended Fetch 1000G / HGDP+1kGP panel (background task)
reference_score / reference_score_batch extended Score against a panel (needs pgenlib)
pgen_read_pvar / pgen_read_psam / pgen_score extended PLINK2 binary ops (needs pgenlib)

Plus a resource (resource://prs/panels) and a prompt (compute_prs_for_trait).

File paths: computation tools take local paths (VCF / normalized Parquet / .pgen dir) on the server's filesystem. Over stdio that's your machine. Reference / pgen tools need the optional native pgenlib (Linux/WSL — uv sync --extra reference); without it they return a clear install hint.

Modes

PRS_MCP_MODE (env) or --mode (CLI), default essentials:

  • essentials — catalog lookup + the core compute/analyze workflow.
  • extended — everything (batch, bulk downloads, HF upload, reference/pgen).

Configuration

All PRS_MCP_* env vars are optional (see .env.example and settings.py): PRS_MCP_MODE, PRS_MCP_CACHE_DIR, PRS_MCP_DEFAULT_GENOME_BUILD, PRS_MCP_DEFAULT_PANEL, PRS_MCP_DUCKDB_MEMORY_LIMIT, PRS_MCP_HF_TOKEN, PRS_MCP_TRANSPORT, PRS_MCP_HOST, PRS_MCP_PORT, PRS_MCP_LOG_LEVEL.

PRS_MCP_CACHE_DIR sets the root for cached catalog metadata, scoring files, and reference panels; if unset, just-prs uses its own default (PRS_CACHE_DIR / platformdirs). The HuggingFace upload tool reads PRS_MCP_HF_TOKEN or the native HF_TOKEN.

Using with coding agents

.mcp.json (Claude Code) launches uv run just-prs-mcp stdio. For Codex (~/.codex/config.toml):

[mcp_servers.just-prs]
command = "uv"
args = ["run", "just-prs-mcp", "stdio"]

Deployment

  • Docker: docker build -t just-prs-mcp . && docker run -p 3011:3011 just-prs-mcp (defaults to HTTP).
  • Smithery: uv sync --extra smithery; entrypoint in pyproject.toml [tool.smithery] + smithery.yaml.
  • Declarative: fastmcp.json drives fastmcp run / fastmcp dev.

Project layout

src/just_prs_mcp/
  server.py        build_server(), CLI, graceful shutdown, Smithery entrypoint
  settings.py      pydantic-settings (PRS_MCP_*), safe defaults
  client.py        shared PRSCatalog / REST-client construction + adapters
  models.py        Pydantic tool I/O models (+ reused just-prs models)
  logging_setup.py stdlib logging -> stderr
  tools/
    catalog.py       essentials — PGS Catalog lookup
    compute.py       essentials — normalize / compute / analyze
    extended.py      extended — batch, downloads, HF upload
    reference.py     extended — reference-panel / pgen scoring (pgenlib)
tests/             in-memory client tests (wiring, not just-prs correctness)

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

just_prs_mcp-0.1.1.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

just_prs_mcp-0.1.1-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file just_prs_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: just_prs_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for just_prs_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fcc66bd77a78aa6f46ee31bbf01be56684f363842bc0e74f6729e4e16806dc73
MD5 c5ec9d237f8ca8e3613897bc2c72aae9
BLAKE2b-256 1f3b6598173c5d15dc0af6d35010693399bc7538a1dc53a98b3db2c801297c04

See more details on using hashes here.

File details

Details for the file just_prs_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: just_prs_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for just_prs_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c76d57fb0dcff274498df3d3cd85a0a9b1db4f39c22f5d60319c30545a952c8a
MD5 244f73250f5e367bea8cbc3ee55805b9
BLAKE2b-256 8d2d1db3d0209e4c358d1eeac5080f96918d0e78b2ee0e65080ce9cb2754e937

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page