get_protein_classes
Retrieve protein classification and functional annotation data for a specific gene in JSON or TSV format using the ProteinAtlas MCP Server.
Instructions
Get protein classification and functional annotation data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: json) | |
| gene | Yes | Gene symbol |
Implementation Reference
- src/index.ts:1305-1332 (handler)The handler function that executes the get_protein_classes tool logic. Validates input using isValidGeneArgs, fetches data using searchProteins with protein class-specific columns ['g', 'eg', 'pc', 'upbp', 'up_mf', 'pe'], and returns formatted JSON 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 ListToolsRequestSchema response, defining name, description, and input schema.{ 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:705-706 (registration)Dispatch case in the CallToolRequestSchema handler that routes calls to get_protein_classes to the handleGetProteinClasses method.case 'get_protein_classes': return this.handleGetProteinClasses(args);
- src/index.ts:63-73 (schema)Type guard function for validating input arguments to gene-based tools like get_protein_classes.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:717-736 (helper)Core helper method used by get_protein_classes to query the Protein Atlas API with custom columns for protein class data.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; }