get_protein_by_ensembl
Retrieve protein expression, localization, and pathology data from the Human Protein Atlas using Ensembl gene identifiers.
Instructions
Get protein information using Ensembl gene ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ensemblId | Yes | Ensembl gene ID (e.g., ENSG00000139618) | |
| format | No | Output format (default: json) |
Implementation Reference
- src/index.ts:865-890 (handler)Primary handler for the 'get_protein_by_ensembl' tool. Validates input arguments, calls the fetch helper, formats the result as MCP content, and handles errors appropriately.private async handleGetProteinByEnsembl(args: any) { if (!isValidEnsemblArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid Ensembl arguments'); } try { const result = await this.fetchProteinDataByEnsembl(args.ensemblId, args.format || 'json'); 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 by Ensembl ID: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; }
- src/index.ts:743-746 (helper)Core helper function that makes the HTTP GET request to the Human Protein Atlas API endpoint for the given Ensembl ID and format, then parses the response.private async fetchProteinDataByEnsembl(ensemblId: string, format: string = 'json'): Promise<any> { const response = await this.apiClient.get(`/${ensemblId}.${format}`); return this.parseResponse(response.data, format); }
- src/index.ts:474-481 (schema)Input schema for the tool defining the expected parameters: required 'ensemblId' string and optional 'format' enum.inputSchema: { type: 'object', properties: { ensemblId: { type: 'string', description: 'Ensembl gene ID (e.g., ENSG00000139618)' }, format: { type: 'string', enum: ['json', 'tsv', 'xml', 'trig'], description: 'Output format (default: json)' }, }, required: ['ensemblId'], },
- src/index.ts:673-674 (registration)Registration in the tool dispatch switch statement within the CallToolRequest handler, routing calls to the specific handler method.case 'get_protein_by_ensembl': return this.handleGetProteinByEnsembl(args);
- src/index.ts:75-85 (helper)Type guard validation function matching the input schema, used by the handler to validate arguments before processing.const isValidEnsemblArgs = ( args: any ): args is { ensemblId: string; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.ensemblId === 'string' && args.ensemblId.length > 0 && (args.format === undefined || ['json', 'tsv', 'xml', 'trig'].includes(args.format)) ); };