search_proteins
Search for proteins in the Human Protein Atlas using gene names, protein names, or keywords. Retrieve data on expression, localization, and pathology in JSON or TSV format.
Instructions
Search Human Protein Atlas for proteins by name, gene symbol, or description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| columns | No | Specific columns to include in results | |
| compress | No | Whether to compress the response (default: false) | |
| format | No | Output format (default: json) | |
| maxResults | No | Maximum number of results (1-10000, default: 100) | |
| query | Yes | Search query (gene name, protein name, or keyword) |
Implementation Reference
- src/index.ts:809-835 (handler)The primary handler function for the 'search_proteins' tool. It validates the input arguments using isValidSearchArgs, calls the core searchProteins helper method, handles the response formatting, and manages errors.private async handleSearchProteins(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { const result = await this.searchProteins(args.query, args.format || 'json', args.columns, args.maxResults); return { content: [ { type: 'text', text: typeof result === 'object' ? JSON.stringify(result, null, 2) : String(result), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching proteins: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:42-61 (schema)Type guard function that validates the input parameters for the search_proteins tool, serving as runtime schema validation.const isValidSearchArgs = ( args: any ): args is { query: string; format?: string; columns?: string[]; compress?: boolean; maxResults?: number; } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.format === undefined || ['json', 'tsv', 'xml', 'trig'].includes(args.format)) && (args.columns === undefined || Array.isArray(args.columns)) && (args.compress === undefined || typeof args.compress === 'boolean') && (args.maxResults === undefined || (typeof args.maxResults === 'number' && args.maxResults > 0 && args.maxResults <= 10000)) ); };
- src/index.ts:444-458 (registration)The registration of the 'search_proteins' tool in the MCP server's tools list, including its declarative JSON input schema.{ name: 'search_proteins', description: 'Search Human Protein Atlas for proteins by name, gene symbol, or description', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (gene name, protein name, or keyword)' }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, columns: { type: 'array', items: { type: 'string' }, description: 'Specific columns to include in results' }, maxResults: { type: 'number', description: 'Maximum number of results (1-10000, default: 100)', minimum: 1, maximum: 10000 }, compress: { type: 'boolean', description: 'Whether to compress the response (default: false)' }, }, required: ['query'], }, },
- src/index.ts:717-736 (helper)Core helper method that performs the actual HTTP request to the Human Protein Atlas API search endpoint, handling parameters like query, format, columns, and response parsing.private async searchProteins(query: string, format: string = 'json', columns?: string[], maxResults?: number): Promise<any> { // Default columns if none provided - basic protein information const defaultColumns = ['g', 'gs', 'eg', 'gd', 'up', 'chr', 'pc', 'pe']; const searchColumns = columns && columns.length > 0 ? columns : defaultColumns; const params: any = { search: query, format: format, columns: searchColumns.join(','), compress: 'no', }; const response = await this.apiClient.get('/api/search_download.php', { params }); if (format === 'json') { return this.parseResponse(response.data, format); } return response.data; }