Home / MCP / SAMtools MCP Server

SAMtools MCP Server

Provides a SAM/BAM/CRAM workflow server with view, sort, index, merge, depth, and statistics capabilities.

python
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "samtools": {
            "command": "uv",
            "args": [
                "run",
                "--with",
                "fastmcp",
                "fastmcp",
                "run",
                "/path/to/samtools_mcp.py"
            ],
            "env": {
                "PYTHONPATH": "/path/to/libs"
            }
        }
    }
}

SAMtools MCP provides a standardized interface to work with SAM/BAM/CRAM files, enabling you to view, convert, sort, index, merge, and analyze alignment data through a consistent, scriptable API. This makes it easier to automate common genomic file operations and integrate SAM/BAM workflows into your pipelines.

How to use

You run the SAMtools MCP server locally and connect with an MCP client to perform common alignment-data operations. The server exposes commands for viewing and converting file formats, sorting, indexing, merging, depth calculation, and statistics. You can execute tasks across single files or multiple inputs and, where supported, target specific genomic regions or flags to filter reads.

How to install

Prerequisites you need before installing:

# Install Python runtime tools if needed
# This example uses uv as the runtime launcher and assumes you will run a Python-based MCP script
pip install uv
# Prepare dependencies for the SAMtools MCP Python component
uv pip install -r requirements.txt

Additional sections

Configuration and runtime start flow are described below to help you get the server running and ready to accept requests.

Local MCP start configuration uses uv to run the Python-based SAMtools MCP script. You can adapt the path to your script and any required arguments.

Available tools

view

View and convert alignment files with region and flag filtering, and header manipulation.

sort

Sort alignment files by coordinate or name, with multi-threading support and per-thread memory control.

index

Create BAI/CSI indexes for BAM/CRAM files and support CRAM indexing.

merge

Merge multiple BAM/CRAM files with header reconciliation and multi-file processing.

depth

Calculate per-base read depth across one or more input files, with optional regions.

flagstat

Generate comprehensive alignment statistics, including quality and paired-end metrics.

idxstats

Provide reference-sequence statistics and counts of mapped/unmapped reads.

faidx

Index FASTA files and enable region-based extraction and retrieval of sequences.