search_by_gene
Find proteins using gene names or symbols, with options to filter by organism and control result quantity.
Instructions
Search for proteins by gene name or symbol
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gene | Yes | Gene name or symbol (e.g., BRCA1, INS) | |
| organism | No | Organism name or taxonomy ID to filter results | |
| size | No | Number of results to return (1-500, default: 25) |
Implementation Reference
- src/index.ts:872-910 (handler)The handler function that executes the tool: validates args, constructs UniProt search query using gene:"{gene}" optionally with organism filter, fetches from /uniprotkb/search API, returns JSON results or error.private async handleSearchByGene(args: any) { if (!isValidGeneSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid gene search arguments'); } try { let query = `gene:"${args.gene}"`; if (args.organism) { query += ` AND organism_name:"${args.organism}"`; } const response = await this.apiClient.get('/uniprotkb/search', { params: { query: query, format: 'json', size: args.size || 25, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching by gene: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:427-437 (registration)Tool registration in ListToolsRequestSchema handler: defines name, description, and input schema.name: 'search_by_gene', description: 'Search for proteins by gene name or symbol', inputSchema: { type: 'object', properties: { gene: { type: 'string', description: 'Gene name or symbol (e.g., BRCA1, INS)' }, organism: { type: 'string', description: 'Organism name or taxonomy ID to filter results' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, }, required: ['gene'], },
- src/index.ts:91-101 (helper)Helper validation function (type guard) for search_by_gene input arguments.const isValidGeneSearchArgs = ( args: any ): args is { gene: string; organism?: string; size?: number } => { return ( typeof args === 'object' && args !== null && typeof args.gene === 'string' && (args.organism === undefined || typeof args.organism === 'string') && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) ); };
- src/index.ts:733-733 (registration)Dispatch registration in CallToolRequestSchema switch statement.return this.handleSearchByGene(args);