Skip to main content
Glama
hlydecker

UCSC Genome Browser MCP Server

by hlydecker

get_sequence

Retrieve DNA sequences from genome assemblies using chromosome coordinates. Specify genome, chromosome, and optional start/end positions to extract specific genomic regions.

Instructions

Retrieve DNA sequence from a specified genome assembly. Can retrieve entire chromosome or specific coordinates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
genomeYesGenome assembly name (e.g., 'hg38')
chromYesChromosome name (e.g., 'chr1', 'chrM')
startNoStart coordinate (0-based, optional, requires end)
endNoEnd coordinate (1-based, optional, requires start)
hub_urlNoURL of assembly hub (optional)
reverse_complementNoReturn reverse complement of sequence

Implementation Reference

  • The execution handler for the get_sequence tool. It extracts parameters from the tool arguments, builds the UCSC API URL for the /getData/sequence endpoint, and fetches the DNA sequence data.
    elif name == "get_sequence":
        params = {
            "genome": arguments["genome"],
            "chrom": arguments["chrom"],
            "start": arguments.get("start"),
            "end": arguments.get("end"),
            "hubUrl": arguments.get("hub_url"),
            "revComp": 1 if arguments.get("reverse_complement") else None
        }
        url = build_api_url("/getData/sequence", params)
        result = await make_api_request(url)
  • The registration of the get_sequence tool in the list_tools() function, defining its name, description, and input schema for MCP.
    Tool(
        name="get_sequence",
        description="Retrieve DNA sequence from a specified genome assembly. Can retrieve entire chromosome or specific coordinates.",
        inputSchema={
            "type": "object",
            "properties": {
                "genome": {
                    "type": "string",
                    "description": "Genome assembly name (e.g., 'hg38')"
                },
                "chrom": {
                    "type": "string",
                    "description": "Chromosome name (e.g., 'chr1', 'chrM')"
                },
                "start": {
                    "type": "integer",
                    "description": "Start coordinate (0-based, optional, requires end)"
                },
                "end": {
                    "type": "integer",
                    "description": "End coordinate (1-based, optional, requires start)"
                },
                "hub_url": {
                    "type": "string",
                    "description": "URL of assembly hub (optional)"
                },
                "reverse_complement": {
                    "type": "boolean",
                    "description": "Return reverse complement of sequence"
                }
            },
            "required": ["genome", "chrom"]
        }
    ),
  • The input schema definition for the get_sequence tool, specifying parameters like genome, chrom, start, end, etc.
    inputSchema={
        "type": "object",
        "properties": {
            "genome": {
                "type": "string",
                "description": "Genome assembly name (e.g., 'hg38')"
            },
            "chrom": {
                "type": "string",
                "description": "Chromosome name (e.g., 'chr1', 'chrM')"
            },
            "start": {
                "type": "integer",
                "description": "Start coordinate (0-based, optional, requires end)"
            },
            "end": {
                "type": "integer",
                "description": "End coordinate (1-based, optional, requires start)"
            },
            "hub_url": {
                "type": "string",
                "description": "URL of assembly hub (optional)"
            },
            "reverse_complement": {
                "type": "boolean",
                "description": "Return reverse complement of sequence"
            }
        },
        "required": ["genome", "chrom"]
    }
  • Helper function build_api_url used by get_sequence handler to construct the UCSC API request URL with semicolon-separated parameters.
    def build_api_url(endpoint: str, params: dict[str, Any]) -> str:
        """Build the complete API URL with parameters."""
        # Filter out None values
        filtered_params = {k: v for k, v in params.items() if v is not None}
        
        # Convert parameters to URL format (using semicolons as per UCSC API spec)
        if filtered_params:
            param_str = ";".join(f"{k}={v}" for k, v in filtered_params.items())
            return f"{BASE_URL}{endpoint}?{param_str}"
        return f"{BASE_URL}{endpoint}"
  • Helper function make_api_request used by get_sequence handler to perform the asynchronous HTTP GET request to the UCSC API and parse JSON response.
    async def make_api_request(url: str) -> dict[str, Any]:
        """Make an HTTP request to the UCSC API and return JSON response."""
        async with httpx.AsyncClient(timeout=30.0) as client:
            response = await client.get(url)
            response.raise_for_status()
            return response.json()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hlydecker/ucsc-genome-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server