batch_annotate
Annotate multiple texts with biological ontology terms in a single operation, identifying relevant concepts from over 1,200 ontologies for efficient batch processing.
Instructions
Process multiple texts for annotation efficiently
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| texts | Yes | Array of texts to annotate (max 10) | |
| ontologies | No | Comma-separated ontology acronyms | |
| longest_only | No | Return only longest matches (default: true) | |
| whole_word_only | No | Match whole words only (default: true) |
Implementation Reference
- src/index.ts:995-1041 (handler)The handler function that executes the batch_annotate tool. It validates input, loops through up to 10 texts, calls the BioOntology /annotator API for each with shared parameters, collects results or errors, and returns a JSON summary.private async handleBatchAnnotate(args: any) { if (!Array.isArray(args.texts) || args.texts.length === 0 || args.texts.length > 10) { throw new McpError(ErrorCode.InvalidParams, 'Invalid batch annotate arguments - texts must be array of 1-10 items'); } try { const results = []; for (const text of args.texts) { const params: any = { text: text, apikey: this.apiKey, }; if (args.ontologies) params.ontologies = args.ontologies; if (args.longest_only !== undefined) params.longest_only = args.longest_only; if (args.whole_word_only !== undefined) params.whole_word_only = args.whole_word_only; try { const response = await this.apiClient.get('/annotator', { params }); results.push({ text, annotations: response.data, success: true }); } catch (error: any) { results.push({ text, error: error.message, success: false }); } } return { content: [ { type: 'text', text: JSON.stringify({ batch_results: results }, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error in batch annotation: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:641-652 (schema)Input schema definition for the batch_annotate tool, defining parameters like texts array (1-10 items), optional ontologies, longest_only, and whole_word_only.name: 'batch_annotate', description: 'Process multiple texts for annotation efficiently', inputSchema: { type: 'object', properties: { texts: { type: 'array', items: { type: 'string' }, description: 'Array of texts to annotate (max 10)', minItems: 1, maxItems: 10 }, ontologies: { type: 'string', description: 'Comma-separated ontology acronyms' }, longest_only: { type: 'boolean', description: 'Return only longest matches (default: true)' }, whole_word_only: { type: 'boolean', description: 'Match whole words only (default: true)' }, }, required: ['texts'], },
- src/index.ts:714-715 (registration)Registration of the batch_annotate tool in the CallToolRequestSchema switch dispatcher, routing calls to the handleBatchAnnotate method.case 'batch_annotate': return this.handleBatchAnnotate(args);