Skip to main content
Glama
hlydecker

UCSC Genome Browser MCP Server

by hlydecker

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
NameRequiredDescriptionDefault
genomeYesGenome assembly name
trackYesTrack name
chromNoChromosome name (optional)
startNoStart coordinate (0-based, optional, requires end)
endNoEnd coordinate (1-based, optional, requires start)
hub_urlNoURL of track/assembly hub (optional)
max_itemsNoMaximum number of items to return (default: 1000000)
json_output_arraysNoReturn data as JSON arrays instead of objects

Implementation Reference

  • 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)
  • 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"]
        }
    ),
  • 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}"
  • 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()

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