get_protein_by_ensembl
Retrieve detailed protein information, including expression and localization data, by providing an Ensembl gene ID. Supports multiple output formats like JSON, TSV, XML, and TRIG.
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-891 (handler)The main handler function for the 'get_protein_by_ensembl' tool. Validates input using isValidEnsemblArgs, fetches data via fetchProteinDataByEnsembl, and returns formatted response or error.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:75-85 (schema)Type guard function that validates the input arguments for the get_protein_by_ensembl tool, checking for required ensemblId and optional format.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)) ); };
- src/index.ts:472-482 (registration)Tool registration entry in the ListTools response, including name, description, and input schema definition.name: 'get_protein_by_ensembl', description: 'Get protein information using Ensembl gene ID', 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:743-746 (helper)Helper method that performs the actual API call to fetch protein data by Ensembl ID and 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:673-674 (registration)Dispatch case in the CallToolRequest handler that routes the tool call to the specific handler method.case 'get_protein_by_ensembl': return this.handleGetProteinByEnsembl(args);