search_genes
Find genes by name, description, or identifier using the Ensembl database to retrieve genomic information for research and analysis.
Instructions
Search for genes by name, description, or identifier
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search term (gene name, description, or partial match) | |
| species | No | Species name (default: homo_sapiens) | |
| feature | No | Feature type to search (default: gene) | |
| biotype | No | Filter by biotype (e.g., protein_coding, lncRNA) | |
| limit | No | Maximum results (1-200, default: 25) |
Implementation Reference
- src/index.ts:996-1030 (handler)The handler function that executes the 'search_genes' tool. It validates input using isValidSearchArgs, constructs parameters for the Ensembl REST API /search endpoint, fetches results, and returns formatted JSON response.private async handleSearchGenes(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { const species = this.getDefaultSpecies(args.species); const feature = args.feature || 'gene'; const limit = args.limit || 25; const params: any = { q: args.query, species, feature, limit, }; if (args.biotype) { params.biotype = args.biotype; } const response = await this.apiClient.get('/search', { params }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleError(error, 'searching genes'); } }
- src/index.ts:597-608 (schema)Input schema definition for the 'search_genes' tool, specifying parameters like query (required), species, feature, biotype, and limit in the ListTools response.name: 'search_genes', description: 'Search for genes by name, description, or identifier', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search term (gene name, description, or partial match)' }, species: { type: 'string', description: 'Species name (default: homo_sapiens)' }, feature: { type: 'string', enum: ['gene', 'transcript'], description: 'Feature type to search (default: gene)' }, biotype: { type: 'string', description: 'Filter by biotype (e.g., protein_coding, lncRNA)' }, limit: { type: 'number', description: 'Maximum results (1-200, default: 25)', minimum: 1, maximum: 200 }, }, required: ['query'],
- src/index.ts:840-841 (registration)Registration of the 'search_genes' tool handler in the CallToolRequestSchema switch statement, mapping tool name to handleSearchGenes method.return this.handleSearchGenes(args); // Sequence Data
- src/index.ts:184-197 (schema)Runtime validation type guard (isValidSearchArgs) for 'search_genes' tool input parameters, ensuring correct types and constraints.const isValidSearchArgs = ( args: any ): args is { query: string; species?: string; feature?: string; biotype?: string; limit?: number } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.feature === undefined || ['gene', 'transcript'].includes(args.feature)) && (args.biotype === undefined || typeof args.biotype === 'string') && (args.limit === undefined || (typeof args.limit === 'number' && args.limit > 0 && args.limit <= 200)) ); };