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
| Name | Required | Description | Default |
|---|---|---|---|
| genome | Yes | Genome assembly name (e.g., 'hg38') | |
| chrom | Yes | Chromosome name (e.g., 'chr1', 'chrM') | |
| start | No | Start coordinate (0-based, optional, requires end) | |
| end | No | End coordinate (1-based, optional, requires start) | |
| hub_url | No | URL of assembly hub (optional) | |
| reverse_complement | No | Return reverse complement of sequence |
Implementation Reference
- ucsc-genome-mcp.py:411-421 (handler)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)
- ucsc-genome-mcp.py:233-266 (registration)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"] } ),
- ucsc-genome-mcp.py:236-265 (schema)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"] }
- ucsc-genome-mcp.py:27-37 (helper)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}"
- ucsc-genome-mcp.py:39-45 (helper)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()