BioMCP Documentation

repository·main·Indexed 19 days ago

https://github.com/genomoncology/biomcp

BioMCP is a unified CLI and MCP server (version 0.8.25) providing a single command grammar to access approximately 30 trusted biomedical data sources, including PubMed, ClinVar, and OncoKB. It enables researchers, clinicians, and AI agents to search and analyze data regarding genes, variants, trials, articles, drugs, diseases, pathways, proteins, adverse events, and PGx without managing multiple disparate APIs.

Tokens
314.7K
Snippets
967
Records
1.4K
Agent score
68%

What's inside BioMCP

  1. Overview of source contract check scripts

    main

    The scripts/ directory contains lightweight commands for checking upstream source behavior and replaying operational demo flows. The available scripts are:

    • contract-smoke.sh: An optional runner for selected live probes.
    • genegpt-demo.sh: A reproduction flow for the paper-style GeneGPT demo.
    • geneagent-demo.sh: A reproduction flow for the paper-style GeneAgent demo.

    Note that these checks are source-facing and are intended as smoke probes, not as a replacement for unit tests or formal verification.

  2. Overview of BioMCP Biomedical Data Sources

    main

    BioMCP provides structured access to a wide variety of upstream biomedical databases, organized by the type of information they provide. While the main User Guide is organized by entities (genes, variants, articles, etc.), the Sources documentation helps you select a provider based on your specific research goal, the keyword you are targeting, or the required provenance.

    Common use cases include:

    • Literature & Research: PubMed (articles/annotations), Semantic Scholar (TLDRs/citations).
    • Clinical & Regulatory: ClinicalTrials.gov (recruiting studies), OpenFDA (recalls/labels), EMA (EU regulatory), WHO Prequalification (vaccines).
    • Genomics & Variants: ClinVar (clinical significance), gnomAD (population frequency), CIViC (clinical variant evidence), OncoKB (oncology actionability).
    • Proteins & Pathways: UniProt (protein cards), Reactome (pathway records), KEGG (pathway IDs).
    • Pharmacology & Drugs: ChEMBL (drug-target activity), DDInter (drug-drug interactions), PharmGKB / CPIC (pharmacogenomics).
  3. Use the biomcp_news_spike Python package

    main

    The biomcp_news_spike package provides a structured implementation for biomedical news discovery, article extraction, entity analysis, and personalized briefing. It is designed to be imported directly into downstream Python projects to avoid shelling out to CLI binaries.

    Core Capabilities:

    • Discovery: RSS/headline discovery and source matrix construction.
    • Extraction: HTTP fetching, Trafilatura-based text extraction, and access/extraction classification.
    • Analysis: Heuristic entity extraction, profile scoring, and briefing card generation.
    • Validation: BioMCP pivot selection, result validation, checksums, and regression comparison.
    from pathlib import Path
    from biomcp_news_spike import PipelineConfig, run_pipeline
    
    payload = run_pipeline(
        PipelineConfig(
            label="daily-news-smoke",
            output=Path("results/news_smoke.json"),
            per_source=4,
            max_articles=20,
            max_entity_articles=10,
            conservative_ranking=True,
        )
    )
  4. Use OpenFDA MCP tools for drug safety and surveillance

    main

    BioMCP provides an interface to OpenFDA data, allowing you to query adverse events (FAERS), recalls, device reports (MAUDE), drug labels, shortages, and U.S. approval context. This is useful for drug safety, surveillance, and regulatory triage workflows.

    Key data sources exposed include:

    • Adverse Events: FAERS reports.
    • Recalls: Drug recall information.
    • Device Events: MAUDE device-event reporting.
    • Labels: FDA public label text and sections.
    • Shortages: Current U.S. shortage status.
    • Approvals: U.S. approval and application details (derived from Drugs@FDA).
    • Regulatory Overlay: FDA device 510(k)/PMA status via the get diagnostic <id> regulatory command.
  5. What is BioMCP and its core purpose

    main

    BioMCP is a biomedical data access layer designed for both AI agents and human researchers. It provides a unified CLI and MCP (Model Context Protocol) server that allows users to query multiple public biomedical data sources using a single, consistent command grammar.

    Instead of managing multiple API keys and learning the idiosyncrasies of various upstream APIs (like PubMed, ClinVar, or UniProt), users can ask structured biomedical questions and receive markdown-formatted answers. The design goal is to provide a single binary and one grammar to access authoritative data without manual API juggling.

  6. Understand Section Outcomes and Provenance

    main

    BioMCP uses section_outcomes to distinguish between different states of biomedical data collection. This ensures that scripts and agents can differentiate between a confirmed zero (a successful lookup that returned no results) and missing evidence (data that was never requested or could not be retrieved).

    Key Outcome States

    • empty: A successful query was made to a provider (e.g., OpenFDA), and the provider explicitly returned no results. The section_outcomes will reflect {"outcome":"empty", "sources":["Provider Name"]}.
    • not_requested: The specific section was not part of the query. The section_outcomes will reflect {"outcome":"not_requested", "sources":[]} and the _meta.section_sources will not contain an entry for that key.
    • inapplicable: A local decision was made to skip a provider because the input data lacked the required identifiers (e.g., a GWAS lookup requires an rsID, so a coordinate-only input results in an inapplicable outcome). In this case, the sources array in section_outcomes remains empty to avoid incorrectly crediting the provider with the decision.

    Data Structure Integration

    When an outcome is recorded, it is reflected in two places:

    1. section_outcomes: Contains the outcome and the sources that provided the result.
    2. _meta.section_sources: Tracks source attribution and metadata for the collection process.
  7. Resolve JATS and PMC HTML supplement links via stable handles

    main

    BioMCP provides a stable article-asset grammar to resolve JATS and PMC HTML supplement links. Even if no specific package contains the linked file, BioMCP resolves these provider-relative links into a consistent handle format. This allows downstream tools to retrieve assets using a single, predictable command structure regardless of the original source format.

    biomcp get article <ARTICLE_ID> asset <ASSET_FILENAME>
  8. Interpret BioMCP response outcomes and errors

    main

    When inspecting JSON or MCP responses, use the section_outcomes field to triage results:

    • empty: The source was contacted successfully but found no evidence.
    • unavailable: No usable result was obtained.
    • degraded: Partial evidence was preserved.

    Provenance information is available in _meta.section_sources.

    For hard remote-source failures, look for error.source and error.recovery in the JSON. If source fields are missing, it is likely an unwrapped transport error. Legacy errors with unknown names will use the label BioMCP source.

  9. Define Ownership for Entity Results and Rendering

    main

    The architecture enforces strict ownership boundaries to ensure deterministic output:

    ComponentResponsibility
    EntitiesSemantic results, source status, fallback/degradation decisions, pagination, provenance, and typed next-command data (command name + ordered, unquoted arguments).
    Render/Output ModulesMarkdown/JSON serialization, shell-safe presentation of next commands (quoting arguments independently), and terminal-control sanitization.
    CLI DispatchersArgument parsing, request construction, execution call, and selecting output format (Markdown vs JSON).

    Key Requirements:

    • Entity code must not depend on markdown-specific quoting helpers for semantic command construction.
    • JSON _meta.next_commands must be treated as a behavior contract.
    • Markdown tests should assert stable structural anchors rather than exact prose/word counts.
  10. Understand BioMCP variant and article capabilities

    main

    BioMCP provides CLI commands and API proxies for querying genomic variants and scientific literature.

    Variant Capabilities:

    • Search/Get: Supports searching for variants and retrieving specific details using search variant and get variant.
    • Supported Identifiers: Accepts exact IDs like rsID, genomic HGVS (chrN:g.posRef>Alt), or gene + protein (e.g., BRAF V600E, BRAF p.Val600Glu).
    • Unsupported Formats: Transcript HGVS (e.g., NM_000248.3:c.135del) is currently unsupported and will fail fast.
    • Data Sources: Uses MyVariantClient as a base resolver, providing access to clinvar, population, conservation, cosmic, cgi, civic, cbioportal, gwas, and predict sections.
    • Provenance: Outputs include section-level provenance (e.g., gnomAD via MyVariant.info).

    Article/Literature Capabilities:

    • Search/Get: Supports search article, get article, article entities, article batch, citations, references, and recommendations.
    • Identifiers: Accepts PMID, PMCID, and DOI (DOI resolution currently depends on Europe PMC).
    • Full-text Retrieval: Uses a ladder of sources including NCBI ID Converter, Europe PMC (PMC XML/MED XML/HTML), NCBI EFetch PMC XML, PMC OA archive XML, and Semantic Scholar PDF (requires --pdf flag).
    • Federated Sources: Integrates PubTator3, Europe PMC, PubMed, Semantic Scholar, and LitSense2 (keyword-gated).
  11. Implement Source-Local Request Plan Builders

    main

    To decouple request construction from network execution, implement source-local request plan builders. These builders define the parameters of a request before it is executed by a client.

    Example Target Plan Types:

    • src/sources/ols4.rs: OlsSearchRequestPlan (exposing method, path, q, rows, groupField, etc.).
    • src/sources/mydisease.rs: Separate builders for query, lookup_disease_by_xref, and get.

    Workflow:

    1. Use the plan builder to construct the request parameters.
    2. Execute the plan through the existing client/cache path.
    3. Map the resulting status and content type to the entity model.

    Invariants:

    • Request construction is asserted before network execution.
    • Wiremock/fixture tests assert response/status mapping against the plan.
    • Auth mode and header redaction are testable without asserting literal secret values.
  12. Verify HPO Phenotype Enrichment optimization results

    main

    When evaluating optimizations for the HPO Phenotype Enrichment for Clinical Symptoms, use the following metrics to ensure performance gains do not introduce regressions in clinical accuracy or data integrity:

    Accuracy & Integrity Metrics

    • Expected symptom recall: Must remain constant (baseline: 0.652).
    • Mismatch count: Must remain constant (baseline: 8).
    • Output checksum: Must match the baseline (f08c35ff31306ff4696bd953eaba4b00aeed9e6746a1228469e1479238e3d34f).
    • Regression/Validation: Must pass (true).

    Performance Metrics

    • Fixture extraction elapsed: Target reduction in milliseconds.
    • Features per second: Target increase in throughput.
    • Peak RSS: Monitor memory usage; increases should ideally stay within 5% of the baseline.