search_by_taxonomy
Search UniProt MCP Server by NCBI taxonomy ID or name to retrieve protein entries based on detailed taxonomic classification. Specify result size for precise querying.
Instructions
Search by detailed taxonomic classification
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | Number of results to return (1-500, default: 25) | |
| taxonomyId | No | NCBI taxonomy ID | |
| taxonomyName | No | Taxonomic name (e.g., Mammalia, Bacteria) |
Implementation Reference
- src/index.ts:1651-1693 (handler)The handler function that executes the search_by_taxonomy tool. It validates input arguments using isValidTaxonomySearchArgs, constructs a UniProt search query filtering by taxonomy ID or name, fetches results from the UniProt REST API, and returns the JSON response.private async handleSearchByTaxonomy(args: any) { if (!isValidTaxonomySearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid taxonomy search arguments'); } try { let query = 'reviewed:true'; if (args.taxonomyId) { query += ` AND taxonomy_id:"${args.taxonomyId}"`; } if (args.taxonomyName) { query += ` AND taxonomy_name:"${args.taxonomyName}"`; } 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 taxonomy: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; }
- src/index.ts:639-650 (registration)Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for search_by_taxonomy.name: 'search_by_taxonomy', description: 'Search by detailed taxonomic classification', inputSchema: { type: 'object', properties: { taxonomyId: { type: 'number', description: 'NCBI taxonomy ID', minimum: 1 }, taxonomyName: { type: 'string', description: 'Taxonomic name (e.g., Mammalia, Bacteria)' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, }, required: [], }, },
- src/index.ts:770-771 (registration)Registration of the handler in the CallToolRequestSchema switch statement.case 'search_by_taxonomy': return this.handleSearchByTaxonomy(args);
- src/index.ts:197-208 (helper)Input validation helper function used by the handler to validate arguments for search_by_taxonomy.const isValidTaxonomySearchArgs = ( args: any ): args is { taxonomyId?: number; taxonomyName?: string; size?: number } => { return ( typeof args === 'object' && args !== null && (args.taxonomyId === undefined || (typeof args.taxonomyId === 'number' && args.taxonomyId > 0)) && (args.taxonomyName === undefined || typeof args.taxonomyName === 'string') && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) && (args.taxonomyId !== undefined || args.taxonomyName !== undefined) ); };