get_protein_classes
Retrieve protein classification and functional annotation data for specific genes from the Human Protein Atlas database to support biological research and analysis.
Instructions
Get protein classification and functional annotation data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gene | Yes | Gene symbol | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:1305-1332 (handler)The core handler function for the 'get_protein_classes' tool. Validates input using isValidGeneArgs, queries the Protein Atlas API via searchProteins with specific columns for protein class (pc), UniProt biological process (upbp), molecular function (up_mf), and evidence (pe), then returns formatted JSON or error response.private async handleGetProteinClasses(args: any) { if (!isValidGeneArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid gene arguments'); } try { const columns = ['g', 'eg', 'pc', 'upbp', 'up_mf', 'pe']; const result = await this.searchProteins(args.gene, args.format || 'json', columns, 1); return { content: [ { type: 'text', text: typeof result === 'object' ? JSON.stringify(result, null, 2) : String(result), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching protein classes: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:649-660 (registration)Tool registration in the MCP server's tool list, including name, description, and input schema definition.{ name: 'get_protein_classes', description: 'Get protein classification and functional annotation data', inputSchema: { type: 'object', properties: { gene: { type: 'string', description: 'Gene symbol' }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, }, required: ['gene'], }, },
- src/index.ts:63-73 (schema)Input validation function for gene-based tools, including 'get_protein_classes'. Checks for valid gene string and optional format.const isValidGeneArgs = ( args: any ): args is { gene: string; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.gene === 'string' && args.gene.length > 0 && (args.format === undefined || ['json', 'tsv', 'xml', 'trig'].includes(args.format)) ); };
- src/index.ts:705-706 (registration)Switch case in the tool request handler that routes calls to 'get_protein_classes' to its handler function.case 'get_protein_classes': return this.handleGetProteinClasses(args);
- src/index.ts:717-736 (helper)Core helper function used by the handler to query the Human Protein Atlas API search endpoint, with custom columns for protein classes.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; }