Skip to main content
Glama
PhenotypeLibrary MCP Server

PhenotypeLibrary MCP Server

by zwelshman

PhenotypeLibrary MCP Server

A Model Context Protocol (MCP) server for the Phenotype Library / Concept Library API.

This server provides access to clinical code lists, phenotypes, ontology terms, and other research metadata from the SAIL Databank Concept Library.

Features

  • Phenotypes: Search and retrieve phenotype definitions, codelists, and version history

  • Concepts: Search and retrieve clinical code lists (concepts), codelists, and version history

  • Ontology: Search ontology terms (MONDO, MeSH, SNOMED CT, ICD-10, etc.)

  • Collections: Browse collections of phenotypes/concepts

  • Tags: Browse tags for categorization

  • Data Sources: Access data source metadata

  • Templates: Browse phenotype templates

Related MCP server: SNOMED CT MCP Server

Installation

# Install from source
pip install -e .

# Or install with development dependencies
pip install -e ".[dev]"

Configuration

Create a .env file with your configuration:

# API Configuration
PHENOTYPELIBRARY_BASE_URL=https://conceptlibrary.saildatabank.com/api/v1/
PHENOTYPELIBRARY_TIMEOUT=30.0

# Optional: Authentication (for private data)
PHENOTYPELIBRARY_USERNAME=your_username
PHENOTYPELIBRARY_PASSWORD=your_password

Available Domains

  • SAIL (default): https://conceptlibrary.saildatabank.com/api/v1/

  • HDRUK: https://phenotypes.healthdatagateway.org/api/v1/

  • Demo: https://conceptlibrary.demo-dev.saildatabank.com/api/v1/

  • ADP: https://conceptlibrary.saildatabank.com/ADP/api/v1/

  • Gateway: https://conceptlibrary.serp.ac.uk/api/v1/

Deployment

Render (Web Service)

  1. Connect your GitHub repository to Render

  2. Create a new Web Service

  3. Use the render.yaml configuration file (or manually configure):

    • Build Command: pip install -e .

    • Start Command: python server.py

    • Health Check Path: /health

  4. Add environment variables:

    • PHENOTYPELIBRARY_BASE_URL (optional, defaults to SAIL)

    • PHENOTYPELIBRARY_TIMEOUT (optional, defaults to 30.0)

    • PHENOTYPELIBRARY_USERNAME (optional, for private data)

    • PHENOTYPELIBRARY_PASSWORD (optional, for private data)

    • MCP_ALLOWED_HOSTS (comma-separated Host values the transport accepts; includes your deployed domain, e.g. phenotypelibrarymcp.onrender.com)

    • MCP_ALLOWED_ORIGINS (optional, comma-separated browser Origin values)

    • MCP_ENABLE_DNS_REBINDING_PROTECTION (optional, true by default; set false to disable Host/Origin validation)

MCP Endpoint

Once deployed, the MCP server will be available at:

  • Streamable HTTP Endpoint: https://your-app.onrender.com/mcp

  • Health Check: https://your-app.onrender.com/health

Docker Compose

Deprecated — Docker files were removed from this project; use the pip install + python server.py flow above instead.

Usage

Running the Server

# Streamable HTTP transport (binds $HOST/$PORT, defaults 0.0.0.0:8000)
python server.py

# Or use the console script
phenotypelibrary-mcp

Local testing note: DNS rebinding protection is on by default and only accepts hosts listed in MCP_ALLOWED_HOSTS (default: phenotypelibrarymcp.onrender.com). For local testing, set MCP_ALLOWED_HOSTS=localhost:*,127.0.0.1:*.

Using with MCP Inspector

# Test with MCP Inspector (streamable HTTP transport)
npx @modelcontextprotocol/inspector http://localhost:8000/mcp

Using with MCP Clients

Add to your MCP client config (Cursor, Claude Desktop, etc.):

{
  "mcpServers": {
    "phenotypelibrary": {
      "url": "https://phenotypelibrarymcp.onrender.com/mcp"
    }
  }
}

Available Tools

Phenotypes

  • search_phenotypes - Search phenotypes with filters

  • get_phenotype_detail - Get detailed phenotype information

  • get_phenotype_codelist - Get clinical codes for a phenotype

  • get_phenotype_versions - Get version history

Concepts

  • search_concepts - Search concepts (clinical code lists)

  • get_concept_detail - Get detailed concept information

  • get_concept_codelist - Get clinical codes for a concept

  • get_concept_versions - Get version history

Ontology

  • search_ontology - Search ontology terms

  • get_ontology_node - Get specific ontology node by term

  • get_ontology_groups - Get all ontology groups

  • get_ontology_type - Get ontology type details

Collections & Tags

  • get_collections - List all collections

  • get_collection_detail - Get collection details

  • get_tags - List all tags

  • get_tag_detail - Get tag details

Data Sources & Templates

  • get_data_sources - List data sources

  • get_data_source_detail - Get data source details

  • get_templates - List templates

  • get_template_detail - Get template details

  • get_template_versions - Get template version history

Example Usage

# Search for asthma phenotypes
result = await search_phenotypes(search="asthma")

# Get phenotype detail
detail = await get_phenotype_detail("PH1")

# Get codelist for a phenotype
codelist = await get_phenotype_codelist("PH1")

# Search ontology for diabetes terms
ontology = await search_ontology(search="diabetes")

# Get specific ontology node
node = await get_ontology_node("MONDO:0005148")

API Response Handling

The Concept Library API returns varying response shapes. client.list() normalizes them all to a single form:

  • Bare JSON array → wrapped into {"count": N, "next": null, "previous": null, "results": [...]}

  • Paged mapping (page/total_pages/data) → data becomes results

  • DRF-style mapping (count/next/previous/results) → passed through as-is

Detail endpoints return a single-item list; the tools unwrap it to the item. All ID parameters are stripped of whitespace, and concept IDs get a C prefix (normalized via PhenotypeLibraryClient.normalize_concept_id).

Development

# Run tests
pytest

# Lint
ruff check .

# Format
ruff format .

License

GPL-3.0 - See LICENSE file for details.

References

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables querying and browsing SNOMED CT medical terminology concepts, including search, details, and hierarchy navigation via MCP tools.
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that provides SNOMED CT clinical terminology lookup via any FHIR R4 terminology server supporting SNOMED CT and ECL. Offers tools for searching by term, fetching by code, and navigating the concept hierarchy.
      21
      Apache 2.0
    • A
      license
      C
      quality
      D
      maintenance
      MCP server for retrieving clinical standard content from the CDISC Library, supporting controlled terminology, ADaM, SDTM, CDASH, SEND metadata, and search.
      31
      7
      MIT