search_by_function
Find proteins by Gene Ontology terms or functional keywords to identify molecules with specific biological roles.
Instructions
Search proteins by GO terms or functional annotations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| goTerm | No | Gene Ontology term (e.g., GO:0005524) | |
| function | No | Functional description or keyword | |
| 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:1441-1487 (handler)Main handler function implementing the 'search_by_function' tool. Builds a UniProt search query based on GO terms, function keywords, organism filter, performs API call, and returns JSON results or error.private async handleSearchByFunction(args: any) { if (!isValidFunctionSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid function search arguments'); } try { let query = 'reviewed:true'; if (args.goTerm) { query += ` AND go:"${args.goTerm}"`; } if (args.function) { query += ` AND (cc_function:"${args.function}" OR ft_act_site:"${args.function}")`; } 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 function: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; }
- src/index.ts:580-593 (registration)Tool registration in ListToolsRequestSchema handler, defining name, description, and input schema for 'search_by_function'.{ name: 'search_by_function', description: 'Search proteins by GO terms or functional annotations', inputSchema: { type: 'object', properties: { goTerm: { type: 'string', description: 'Gene Ontology term (e.g., GO:0005524)' }, function: { type: 'string', description: 'Functional description or keyword' }, 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: [], }, },
- src/index.ts:183-195 (helper)Helper validation function isValidFunctionSearchArgs used to validate input arguments for the search_by_function tool.const isValidFunctionSearchArgs = ( args: any ): args is { goTerm?: string; function?: string; organism?: string; size?: number } => { return ( typeof args === 'object' && args !== null && (args.goTerm === undefined || typeof args.goTerm === 'string') && (args.function === undefined || typeof args.function === 'string') && (args.organism === undefined || typeof args.organism === 'string') && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) && (args.goTerm !== undefined || args.function !== undefined) ); };
- src/index.ts:762-763 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement.return this.handleSearchByFunction(args); case 'search_by_localization':