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 logic for the get_track_data tool: maps arguments to API parameters and calls the UCSC /getData/track endpoint via make_api_request.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:270-307 (schema)Input schema defining parameters for the get_track_data tool, including required genome and track, optional filters.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:267-308 (registration)Registration of the get_track_data tool in the list_tools() function, specifying name, description, and input schema.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 UCSC API URLs from endpoint and parameters, used by get_track_data handler.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 HTTP GET request to UCSC API and parse JSON response, used by get_track_data handler.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()