Skip to main content

Genome Model Context Protocol (MCP) server for genomic data access

Project description

Genome MCP - Model Context Protocol Server for Genomic Data

License: MIT Python 3.9+ Publish Code Quality PyPI version

A Model Context Protocol (MCP) server that provides unified access to genomic databases through a standardized API interface. Built with async architecture and designed for AI-tool integration.

Features

  • MCP Server Architecture: Built on Model Context Protocol for seamless AI-tool integration
  • NCBI Database Integration: Full access to NCBI Gene database via EUtils API
  • Async Performance: High-performance async/await architecture
  • Rate Limiting & Caching: Built-in request optimization and response caching
  • Type Safety: Full type hints with Pydantic models
  • CLI Interface: Command-line interface for direct database queries
  • Modern Python: Uses uv for dependency management and modern packaging

Installation

Using uv (Recommended)

# Install with uv
uv add genome-mcp

# Or run directly without installation
uv run genome-mcp --help

Using pip

pip install genome-mcp

Quick Start

Command Line Interface

# Show help and available commands
genome-mcp --help

# NCBI Gene Server
genome-mcp ncbi-gene info --gene-id 7157  # TP53
genome-mcp ncbi-gene search --term "cancer" --species human
genome-mcp ncbi-gene homologs --gene-id 7157 --species mouse

# Server info and health
genome-mcp server info
genome-mcp server health

# Pretty output (default)
genome-mcp ncbi-gene info --gene-id 7157 --output pretty

# JSON output for programmatic use
genome-mcp ncbi-gene info --gene-id 7157 --output json

Python API

import asyncio
from src.servers.ncbi.gene import NCBIGeneServer

async def main():
    # Create NCBI Gene server instance
    server = NCBIGeneServer()
    
    # Get gene information
    gene_info = await server.execute_request("get_gene_info", {"gene_id": "7157"})
    print(f"Gene: {gene_info['data']['name']}")
    print(f"Description: {gene_info['data']['description']}")
    
    # Search for genes
    search_results = await server.execute_request("search_genes", {
        "term": "cancer",
        "species": "human"
    })
    print(f"Found {len(search_results['data'])} genes")

if __name__ == "__main__":
    asyncio.run(main())

Configuration

Environment Variables

# NCBI API key (optional but recommended for higher rate limits)
export NCBI_API_KEY="your_ncbi_api_key"

# Email for NCBI API (required for some operations)
export NCBI_EMAIL="your_email@example.com"

Project Configuration

The project includes a comprehensive configuration file (project_config.json) that defines:

  • Server settings and capabilities
  • Rate limiting and caching configuration
  • Logging and monitoring settings
  • Development and deployment options

Configuration File

Create a configuration file at ~/.genome_mcp/config.json:

{
  "servers": {
    "ncbi_gene": {
      "base_url": "https://eutils.ncbi.nlm.nih.gov/entrez/eutils",
      "rate_limit": {
        "requests_per_second": 3,
        "burst_limit": 10
      },
      "cache": {
        "enabled": true,
        "ttl": 3600
      }
    }
  },
  "logging": {
    "level": "INFO",
    "format": "json"
  }
}

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/your-org/genome-mcp.git
cd genome-mcp

# Install with uv
uv sync --dev

# Install pre-commit hooks
uv run pre-commit install

Running Tests

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=src --cov-report=html

# Run specific test file
uv run pytest tests/test_ncbi_gene_server.py

Code Quality

# Format code
uv run black src/ tests/

# Sort imports
uv run isort src/ tests/

# Type checking
uv run mypy src/

# Linting
uv run ruff check src/ tests/

Project Structure

genome-mcp/
  src/                     # Source code (flat structure)
    cli.py                 # Command line interface
    servers/               # MCP server implementations
      base.py            # Base MCP server class
      ncbi/              # NCBI server implementations
        gene.py         # NCBI Gene server
    utils/                 # Utility functions
    models/                # Pydantic models and types
  tests/                   # Test code
  docs/                    # Documentation
  examples/               # Example code
  .github/                # GitHub Actions workflows
  project_config.json      # Project configuration

Architecture

MCP Server Architecture

  • BaseMCPServer: Abstract base class providing common MCP functionality
  • NCBIGeneServer: Implementation for NCBI Gene database access
  • Async Design: Full async/await support for high performance
  • Rate Limiting: Built-in request rate limiting with Token Bucket algorithm
  • Caching: Optional response caching to improve performance
  • Error Handling: Comprehensive error handling and logging

Key Components

  • Server Capabilities: Define available operations and features
  • Request Execution: Support for single, batch, and streaming requests
  • Health Monitoring: Built-in health checks and statistics tracking
  • Configuration Management: JSON-based configuration system

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use Genome MCP in your research, please cite:

@software{genome_mcp,
  title={Genome MCP: Model Context Protocol Server for Genomic Data},
  author={Genome MCP Team},
  year={2025},
  url={https://github.com/your-org/genome-mcp}
}

Support

Acknowledgments

  • NCBI for providing comprehensive genomic databases
  • Model Context Protocol for enabling AI-tool integration
  • uv for modern Python package management

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

genome_mcp-0.1.0.tar.gz (67.3 kB view details)

Uploaded Source

Built Distribution

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

genome_mcp-0.1.0-py3-none-any.whl (52.5 kB view details)

Uploaded Python 3

File details

Details for the file genome_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: genome_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 67.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for genome_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6db8111d872af51a09160c1c14af231a86c49fe8692ef41f8bc10c70d0f92c7f
MD5 6ebc05bd57f6a4493a6d3027600a5875
BLAKE2b-256 4e676295e9e093e73de362b7dc407560439f21849c9977ec7489ab9ebbc01c6e

See more details on using hashes here.

File details

Details for the file genome_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: genome_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 52.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for genome_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55fa6e4b609a099a047ac3e72b3d68ae8f5d00a9a9b4bbb62b2a4afe3cbc7b26
MD5 68f30c390ad7d9ccbde2e5a58083ad77
BLAKE2b-256 db8d3fd05231ab3a183a38aea5966689dff1d8691be33a06f786dce7c32cd918

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