search_proteins
Search the UniProt database for proteins using names, keywords, or organism filters to retrieve detailed protein information in multiple formats.
Instructions
Search UniProt database for proteins by name, keyword, or organism
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (protein name, keyword, or complex search) | |
| organism | No | Organism name or taxonomy ID to filter results | |
| size | No | Number of results to return (1-500, default: 25) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:795-835 (handler)Handler function that executes the search_proteins tool. Validates input, constructs UniProt search query with optional organism filter, calls the UniProt REST API, and returns JSON results or error.private async handleSearchProteins(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { let query = args.query; if (args.organism) { query += ` AND organism_name:"${args.organism}"`; } const response = await this.apiClient.get('/uniprotkb/search', { params: { query: query, format: args.format || 'json', size: args.size || 25, }, }); return { content: [ { type: 'text', text: typeof response.data === 'object' ? JSON.stringify(response.data, null, 2) : String(response.data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching proteins: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:400-412 (registration)Registration of the search_proteins tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.{ name: 'search_proteins', description: 'Search UniProt database for proteins by name, keyword, or organism', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (protein name, keyword, or complex search)' }, 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 }, format: { type: 'string', enum: ['json', 'tsv', 'fasta', 'xml'], description: 'Output format (default: json)' }, }, required: ['query'], },
- src/index.ts:728-729 (registration)Dispatch/registration in the CallToolRequestSchema switch statement that routes calls to the handleSearchProteins handler.case 'search_proteins': return this.handleSearchProteins(args);
- src/index.ts:66-77 (schema)Type guard function for validating input arguments to the search_proteins tool, matching the inputSchema.const isValidSearchArgs = ( args: any ): args is { query: string; organism?: string; size?: number; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && (args.organism === undefined || typeof args.organism === 'string') && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) && (args.format === undefined || ['json', 'tsv', 'fasta', 'xml'].includes(args.format)) ); };