find_genome
Search for genomes in the UCSC Genome Browser using flexible queries with inclusion, exclusion, and wildcard operators to locate specific genomic assemblies.
Instructions
Search for a genome in the UCSC browser using a search string. Supports advanced search with +word (force inclusion), -word (exclusion), and word* (wildcard).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search string to find genomes (e.g., 'dog', 'GRCh38', 'GCF_028858775.2') | |
| browser | No | Filter by browser availability (default: mustExist) | |
| stats_only | No | Only show statistics about search results | |
| year | No | Filter results by year | |
| category | No | Filter by NCBI category | |
| status | No | Filter by NCBI status | |
| level | No | Filter by NCBI assembly level | |
| max_items | No | Maximum number of items to return (default: 1000000, use -1 for max) |
Implementation Reference
- ucsc-genome-mcp.py:340-353 (handler)Handler logic for the 'find_genome' tool: constructs parameters from tool arguments, builds the API URL for /findGenome, and fetches the JSON response from UCSC API.if name == "find_genome": params = { "q": arguments["query"], "browser": arguments.get("browser"), "statsOnly": 1 if arguments.get("stats_only") else None, "year": arguments.get("year"), "category": arguments.get("category"), "status": arguments.get("status"), "level": arguments.get("level"), "maxItemsOutput": arguments.get("max_items") } url = build_api_url("/findGenome", params) result = await make_api_request(url)
- ucsc-genome-mcp.py:51-96 (registration)Registration of the 'find_genome' tool in the list_tools() decorator, including its description and full input schema.Tool( name="find_genome", description="Search for a genome in the UCSC browser using a search string. Supports advanced search with +word (force inclusion), -word (exclusion), and word* (wildcard).", inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "Search string to find genomes (e.g., 'dog', 'GRCh38', 'GCF_028858775.2')" }, "browser": { "type": "string", "enum": ["mustExist", "mayExist", "notExist"], "description": "Filter by browser availability (default: mustExist)" }, "stats_only": { "type": "boolean", "description": "Only show statistics about search results" }, "year": { "type": "integer", "description": "Filter results by year" }, "category": { "type": "string", "enum": ["reference", "representative"], "description": "Filter by NCBI category" }, "status": { "type": "string", "enum": ["reference", "representative"], "description": "Filter by NCBI status" }, "level": { "type": "string", "enum": ["complete", "chromosome", "scaffold", "contig"], "description": "Filter by NCBI assembly level" }, "max_items": { "type": "integer", "description": "Maximum number of items to return (default: 1000000, use -1 for max)" } }, "required": ["query"] } ),
- ucsc-genome-mcp.py:27-37 (helper)Helper function to construct UCSC Genome API URLs from endpoint and parameters, used by the find_genome 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 requests to UCSC API and parse JSON response, used by the find_genome 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()