get_track_data
Retrieve genomic track data from UCSC Genome Browser or custom hubs, with optional filtering by chromosome and coordinates for targeted analysis.
Instructions
Retrieve data from a specified track in a hub or UCSC database genome. Can be filtered by chromosome and coordinates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| genome | Yes | Genome assembly name | |
| track | Yes | Track name | |
| chrom | No | Chromosome name (optional) | |
| start | No | Start coordinate (0-based, optional, requires end) | |
| end | No | End coordinate (1-based, optional, requires start) | |
| hub_url | No | URL of track/assembly hub (optional) | |
| max_items | No | Maximum number of items to return (default: 1000000) | |
| json_output_arrays | No | Return data as JSON arrays instead of objects |
Implementation Reference
- ucsc-genome-mcp.py:423-435 (handler)Handler function for get_track_data tool: maps input arguments to API parameters and calls the UCSC Genome API /getData/track endpoint.elif name == "get_track_data": params = { "genome": arguments["genome"], "track": arguments["track"], "chrom": arguments.get("chrom"), "start": arguments.get("start"), "end": arguments.get("end"), "hubUrl": arguments.get("hub_url"), "maxItemsOutput": arguments.get("max_items"), "jsonOutputArrays": 1 if arguments.get("json_output_arrays") else None } url = build_api_url("/getData/track", params) result = await make_api_request(url)
- ucsc-genome-mcp.py:267-308 (schema)Schema definition for the get_track_data tool, including input parameters like genome, track, optional chrom, start, end, hub_url, max_items, and json_output_arrays.Tool( name="get_track_data", description="Retrieve data from a specified track in a hub or UCSC database genome. Can be filtered by chromosome and coordinates.", inputSchema={ "type": "object", "properties": { "genome": { "type": "string", "description": "Genome assembly name" }, "track": { "type": "string", "description": "Track name" }, "chrom": { "type": "string", "description": "Chromosome name (optional)" }, "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 track/assembly hub (optional)" }, "max_items": { "type": "integer", "description": "Maximum number of items to return (default: 1000000)" }, "json_output_arrays": { "type": "boolean", "description": "Return data as JSON arrays instead of objects" } }, "required": ["genome", "track"] } ),
- ucsc-genome-mcp.py:27-37 (helper)Helper function to construct the full UCSC API URL from endpoint and parameters, filtering None values and using semicolon separators.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 to perform asynchronous HTTP GET request to UCSC API URL 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()