Labsco
longevity-genie logo

OpenGenes

โ˜… 19

from longevity-genie

Access the OpenGenes database for aging and longevity research, with automatic updates from Hugging Face Hub.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

opengenes-mcp

Tests PyPI version Python 3.10+ License: MIT Code style: black

MCP (Model Context Protocol) server for OpenGenes database

This server implements the Model Context Protocol (MCP) for OpenGenes, providing a standardized interface for accessing aging and longevity research data. MCP enables AI assistants and agents to query comprehensive biomedical datasets through structured interfaces.

The server automatically downloads the latest OpenGenes database and documentation from Hugging Face Hub (specifically from the opengenes folder), ensuring you always have access to the most up-to-date data without manual file management.

The OpenGenes database contains:

  • lifespan_change: Experimental data about genetic interventions and their effects on lifespan across model organisms
  • gene_criteria: Criteria classifications for aging-related genes (12 different categories)
  • gene_hallmarks: Hallmarks of aging associated with specific genes
  • longevity_associations: Genetic variants associated with longevity from population studies

If you want to understand more about what the Model Context Protocol is and how to use it more efficiently, you can take the DeepLearning AI Course or search for MCP videos on YouTube.

๐Ÿ† Part of Holy Bio MCP Framework

This MCP server is part of the Holy Bio MCP project - a unified framework for bioinformatics research that won the Bio x AI Hackathon 2025 and continues to be actively developed and extended after the victory.

The Holy Bio MCP framework brings together multiple specialized MCP servers into a cohesive ecosystem for advanced biological research:

Together, these servers provide 50+ specialized bioinformatics functions that can work seamlessly together in AI-driven research workflows. Learn more about the complete framework at github.com/longevity-genie/holy-bio-mcp.

About MCP (Model Context Protocol)

MCP is a protocol that bridges the gap between AI systems and specialized domain knowledge. It enables:

  • Structured Access: Direct connection to authoritative aging and longevity research data
  • Natural Language Queries: Simplified interaction with specialized databases through SQL
  • Type Safety: Strong typing and validation through FastMCP
  • AI Integration: Seamless integration with AI assistants and agents

Data Source and Updates

The OpenGenes MCP server automatically downloads data from the longevity-genie/bio-mcp-data repository on Hugging Face Hub. This ensures:

  • Always Up-to-Date: Automatic access to the latest OpenGenes database without manual updates
  • Reliable Distribution: Centralized data hosting with version control and change tracking
  • Efficient Caching: Downloaded files are cached locally to minimize network requests
  • Fallback Support: Local fallback files are supported for development and offline use

The data files are stored in the opengenes subfolder of the Hugging Face repository and include:

  • open_genes.sqlite - The complete OpenGenes database
  • prompt.txt - Database schema documentation and usage guidelines

Available Tools

This server provides three main tools for interacting with the OpenGenes database:

  1. opengenes_db_query(sql: str) - Execute read-only SQL queries against the OpenGenes database
  2. opengenes_get_schema_info() - Get detailed schema information including tables, columns, and enumerations
  3. opengenes_example_queries() - Get a list of example SQL queries with descriptions

Available Resources

  1. resource://db-prompt - Complete database schema documentation and usage guidelines
  2. resource://schema-summary - Formatted summary of tables and their purposes

Database Schema

Detailed schema information

Main Tables

  • lifespan_change (47 columns): Experimental lifespan data with intervention details across model organisms
  • gene_criteria (2 columns): Gene classifications by aging criteria (12 different categories)
  • gene_hallmarks (2 columns): Hallmarks of aging mappings for genes
  • longevity_associations (11 columns): Population genetics longevity data from human studies

Key Fields

  • HGNC: Gene symbol (primary identifier across all tables)
  • model_organism: Research organism (mouse, C. elegans, fly, etc.)
  • effect_on_lifespan: Direction of lifespan change (increases/decreases/no change)
  • intervention_method: Method of genetic intervention (knockout, overexpression, etc.)
  • criteria: Aging-related gene classification (12 categories)
  • hallmarks of aging: Biological aging processes associated with genes

Example Queries

Sample SQL queries for common research questions
-- Get top genes with most lifespan experiments
SELECT HGNC, COUNT(*) as experiment_count 
FROM lifespan_change 
WHERE HGNC IS NOT NULL 
GROUP BY HGNC 
ORDER BY experiment_count DESC 
LIMIT 10;

-- Find genes that increase lifespan in mice
SELECT DISTINCT HGNC, effect_on_lifespan 
FROM lifespan_change 
WHERE model_organism = 'mouse' 
AND effect_on_lifespan = 'increases lifespan' 
AND HGNC IS NOT NULL;

-- Get hallmarks of aging for genes
SELECT HGNC, "hallmarks of aging" 
FROM gene_hallmarks 
WHERE "hallmarks of aging" LIKE '%mitochondrial%';

-- Find longevity associations by ethnicity
SELECT HGNC, "polymorphism type", "nucleotide substitution", ethnicity 
FROM longevity_associations 
WHERE ethnicity LIKE '%Italian%';

-- Find genes with both lifespan effects and longevity associations
SELECT DISTINCT lc.HGNC 
FROM lifespan_change lc 
INNER JOIN longevity_associations la ON lc.HGNC = la.HGNC 
WHERE lc.HGNC IS NOT NULL;

Safety Features

  • Read-only access: Only SELECT queries are allowed
  • Input validation: Blocks INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, TRUNCATE operations
  • Error handling: Comprehensive error handling with informative messages

Testing & Verification

The MCP server is provided with comprehensive tests including LLM-as-a-judge tests that evaluate the quality of responses to complex queries. However, LLM-based tests are disabled by default in CI to save costs.

Environment Setup for LLM Agent Tests

If you want to run LLM agent tests that use MCP functions with Gemini models, you need to set up a .env file with your Gemini API key:

# Create a .env file in the project root
echo "GEMINI_API_KEY=your-gemini-api-key-here" > .env

Note: The .env file and Gemini API key are only required for running LLM agent tests. All other tests and basic MCP server functionality work without any API keys.

Running Tests

Run tests for the MCP server:

uv run pytest -vvv -s

You can also run manual tests:

uv run python test/manual_test_questions.py

You can use MCP inspector with locally built MCP server same way as with uvx.

Note: Using the MCP Inspector is optional. Most MCP clients (like Cursor, Windsurf, etc.) will automatically display the available tools from this server once configured. However, the Inspector can be useful for detailed testing and exploration.

If you choose to use the Inspector via npx, ensure you have Node.js and npm installed. Using nvm (Node Version Manager) is recommended for managing Node.js versions.

Example questions that MCP helps to answer

Research questions you can explore with this MCP server
  • Interventions on which genes extended mice lifespan most of all?
  • Which knockdowns were most lifespan extending on model animals?
  • What processes are improved in GHR knockout mice?
  • Which genetic intervention led to the greatest increase in lifespan in flies?
  • To what extent did the lifespan increase in mice overexpressing VEGFA?
  • Are there any liver-specific interventions that increase lifespan in mice?
  • Which gene-longevity association is confirmed by the greatest number of studies?
  • What polymorphisms in FOXO3 are associated with human longevity?
  • In which ethnic groups was the association of the APOE gene with longevity shown?
  • Is the INS gene polymorphism associated with longevity?
  • What genes are associated with transcriptional alterations?
  • Which hallmarks are associated with the KL gene?
  • How many genes are associated with longevity in humans?
  • What types of studies have been conducted on the IGF1R gene?
  • What evidence of the link between PTEN and aging do you know?
  • What genes are associated with both longevity and altered expression in aged humans?
  • Is the expression of the ACE2 gene altered with aging in humans?
  • What genes need to be downregulated in worms to extend their lifespan?