Skip to main content
Glama
README.md
![Logo](logo.png)
# Unofficial GTEx Portal MCP Server

A comprehensive Model Context Protocol (MCP) server providing access to the GTEx (Genotype-Tissue Expression) Portal API. This server enables AI assistants to query and analyze genomics data from the GTEx project through **25 specialized tools** across three categories.

**Developed by [Augmented Nature](https://augmentednature.ai)**

## Overview

The GTEx Portal contains gene expression and regulatory data from 54 non-diseased tissue sites across nearly 1000 individuals. This MCP server provides structured access to:

- **Expression Analysis**: Gene expression patterns and tissue specificity (7 tools)
- **Association Analysis**: eQTL/sQTL analysis and genetic associations (6 tools)
- **Reference/Dataset**: Gene/variant lookups and metadata (12 tools)

## 🧬 Complete Tool Suite (25/25 Implemented)

### Expression Analysis Tools (7 tools)
- `get_gene_expression` - Get gene expression data across tissues for specific genes
- `get_median_gene_expression` - Get median gene expression levels across tissues
- `get_top_expressed_genes` - Get top expressed genes in specific tissues
- `get_tissue_specific_genes` - Get genes with tissue-specific expression patterns
- `get_clustered_expression` - Get clustered gene expression data for visualization
- `calculate_expression_correlation` - Calculate Pearson correlation between genes across tissues
- `get_differential_expression` - Get differential gene expression between tissue groups

### Association Analysis Tools (6 tools)
- `get_eqtl_genes` - Get genes with eQTL associations for genomic regions
- `get_single_tissue_eqtls` - Get single-tissue eQTL results for genes
- `calculate_dynamic_eqtl` - Calculate dynamic eQTL effects across tissues
- `get_multi_tissue_eqtls` - Get multi-tissue eQTL meta-analysis results
- `get_sqtl_results` - Get splicing QTL (sQTL) results for genes
- `analyze_ld_structure` - Analyze linkage disequilibrium structure around variants

### Reference/Dataset Tools (12 tools)
- `search_genes` - Search for genes by symbol, name, or description
- `get_gene_info` - Get detailed information about specific genes
- `get_variants` - Get genetic variants in genomic regions
- `get_tissue_info` - Get information about GTEx tissues and sample counts
- `get_sample_info` - Get GTEx sample metadata and demographics
- `get_subject_phenotypes` - Get subject phenotype data and demographics
- `validate_gene_id` - Validate and normalize gene identifiers
- `validate_variant_id` - Validate variant identifiers and genomic coordinates
- `get_dataset_info` - Get information about available GTEx datasets
- `search_transcripts` - Search for gene transcripts and isoforms
- `get_gene_ontology` - Get Gene Ontology annotations for genes
- `convert_coordinates` - Convert between genomic coordinate systems (hg19/hg38)

## šŸš€ Installation

1. Clone or download the server files
2. Install dependencies:
```bash
cd gtex-server
npm install
```

3. Build the server:
```bash
npm run build
```

## Usage

### Running the Server

Start the server for testing:
```bash
npm run dev
```

Use the MCP inspector for development:
```bash
npm run inspector
```

### Integrating with Claude Desktop

Add the server to your Claude Desktop configuration file:

**On macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

**On Windows**: `%APPDATA%/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "gtex-server": {
      "command": "node",
      "args": ["/path/to/gtex-server/build/index.js"]
    }
  }
}
```

Replace `/path/to/gtex-server` with the actual path to your server installation.

## šŸ“Š Example Usage

### Search for Genes
```
Search for genes related to "BRCA1" or "insulin signaling"
```

### Gene Expression Analysis
```
Get median gene expression for ENSG00000012048.20 (BRCA1) across all tissues
```

### Tissue-Specific Analysis
```
Find tissue-specific genes in Brain_Cortex and compare with Muscle_Skeletal
```

### eQTL Analysis
```
Find genes with eQTL associations in genomic region chr17:43000000-43200000
```

### Expression Correlation
```
Calculate expression correlation between BRCA1 and BRCA2 across tissues
```

### Coordinate Conversion
```
Convert genomic coordinates from hg38 to hg19: chr1:1500000
```

## šŸ”¬ Scientific Applications

This server enables comprehensive genomics research including:

- **Tissue Expression Profiling**: Identify genes with tissue-specific or tissue-enriched expression
- **Co-expression Analysis**: Find genes with correlated expression patterns
- **eQTL Mapping**: Discover expression quantitative trait loci and regulatory variants  
- **Comparative Genomics**: Compare expression across different tissue types
- **Functional Annotation**: Link genes to biological processes via Gene Ontology
- **Variant Analysis**: Explore genetic variation and its impact on gene expression

## šŸ—„ļø API Data Source

This server connects to the GTEx Portal API v2:
- **Base URL**: https://gtexportal.org/api/v2/
- **Documentation**: https://gtexportal.org/api/v2/redoc
- **Data**: GTEx v8 dataset (15,201 RNA-Seq samples from 54 tissues, 948 donors)
- **Genome Build**: GRCh38/hg38

## šŸ“‹ Data Types and Formats

### Gene Identifiers
- **GENCODE IDs**: e.g., `ENSG00000012048.20` (BRCA1)
- **Gene Symbols**: e.g., `BRCA1`, `TP53`, `INSR`

### Tissue Identifiers  
- **Tissue Site Detail IDs**: e.g., `Muscle_Skeletal`, `Brain_Cortex`, `Heart_Left_Ventricle`
- Use `get_tissue_info` tool to see all 54 available tissues

### Genomic Coordinates
- **Chromosome**: e.g., `chr17`, `chrX`, `chrY`
- **Positions**: 1-based genomic coordinates
- **Genome Build**: GRCh38/hg38 (with hg19 conversion available)

### Expression Values
- **Units**: TPM (Transcripts Per Million)
- **Statistics**: Mean, median, standard deviation across samples
- **Detection**: Percentage of samples with detectable expression

## ⚔ Performance & Reliability

- **Error Handling**: Comprehensive validation and graceful error recovery
- **Rate Limiting**: Automatic handling of API rate limits
- **Timeouts**: 30-second timeouts with retry logic
- **Caching**: Intelligent caching to improve response times
- **Pagination**: Automatic handling of large result sets
- **Validation**: Input parameter validation and normalization

## šŸ› ļø Development

### Project Structure
```
gtex-server/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts                      # Main MCP server with tool registration
│   ā”œā”€ā”€ types/gtex-types.ts          # Complete TypeScript type definitions
│   ā”œā”€ā”€ utils/api-client.ts          # GTEx API client with comprehensive methods
│   └── handlers/
│       ā”œā”€ā”€ expression-handlers.ts    # 7 expression analysis tools
│       ā”œā”€ā”€ association-handlers.ts   # 6 eQTL/sQTL analysis tools  
│       └── reference-handlers.ts     # 12 reference/lookup tools
ā”œā”€ā”€ build/                           # Compiled JavaScript output
ā”œā”€ā”€ test-complete-server.js         # Comprehensive testing script
ā”œā”€ā”€ package.json                     # Dependencies and build scripts
└── tsconfig.json                    # TypeScript configuration
```

### Development Commands
```bash
# Build the project
npm run build

# Run in development mode with auto-reload
npm run dev

# Watch for changes during development
npm run watch

# Test all 25 tools
node test-complete-server.js
```

### Technical Implementation

- **Language**: TypeScript with ES modules
- **Framework**: Model Context Protocol SDK v0.6.0
- **Architecture**: Modular design with separate handler classes
- **API Client**: Axios with comprehensive error handling
- **Data Processing**: Statistical analysis and data formatting
- **Type Safety**: Complete type definitions for all GTEx API responses

## šŸ“š References

- [GTEx Portal](https://gtexportal.org/) - Main GTEx data portal
- [GTEx API Documentation](https://gtexportal.org/api/v2/redoc) - Complete API reference
- [Model Context Protocol](https://modelcontextprotocol.io/) - MCP specification
- [GTEx Consortium Nature Paper](https://www.nature.com/articles/s41588-017-0004-9) - Primary publication
- [GTEx Analysis Methods](https://www.gtexportal.org/home/documentationPage#staticTextAnalysisMethods) - Statistical methods

## šŸŽÆ Status: Production Ready

āœ… **All 25 tools implemented and tested**  
āœ… **Complete TypeScript implementation**  
āœ… **Comprehensive error handling**  
āœ… **Live GTEx Portal API integration**  
āœ… **MCP 1.0 compliant**  
āœ… **Ready for genomics research**

## šŸ“„ License

MIT License - Feel free to use, modify, and distribute for research and commercial applications.

---

*This server bridges the GTEx Portal's extensive genomics database with the Model Context Protocol, enabling powerful genomics analysis through AI assistants.*

TDQS

B3.3/5.0

Scored across 25 tools

Disambiguation4/5

Most tools have distinct purposes targeting specific data types or analyses (e.g., get_gene_expression vs. get_eqtl_genes vs. get_sample_info), with clear boundaries. However, some overlap exists between get_gene_info and search_genes, and between get_subject_phenotypes and get_sample_info, which could cause minor confusion.

Naming Consistency5/5

Tool names follow a highly consistent verb_noun pattern throughout, primarily using 'get_' for data retrieval, 'calculate_' for computations, and 'analyze_'/'search_'/'validate_' for other operations. All names use snake_case uniformly, making them predictable and readable.

Tool Count3/5

With 25 tools, the count is borderline high for a single server, leaning toward heavy but not extreme. This is reasonable given the broad scope of GTEx data analysis, but it may overwhelm agents with many similar-sounding retrieval tools.

Completeness5/5

The tool set provides comprehensive coverage for GTEx data analysis, including data retrieval (genes, variants, expression, eQTLs, samples), computations (correlation, dynamic eQTLs), searches, and validations. It supports full workflows from data access to analysis without obvious gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues