Skip to main content
Glama

batch_annotate

Annotate multiple texts simultaneously with biological ontologies using comma-separated ontology acronyms, returning longest or whole-word matches as specified.

Instructions

Process multiple texts for annotation efficiently

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
longest_onlyNoReturn only longest matches (default: true)
ontologiesNoComma-separated ontology acronyms
textsYesArray of texts to annotate (max 10)
whole_word_onlyNoMatch whole words only (default: true)

Implementation Reference

  • The handler function that implements the batch_annotate tool. It validates input, loops over each text, calls the BioOntology /annotator API with parameters, collects successes and errors per text, and returns batched results as JSON.
    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, }; } }
  • JSON Schema defining the input parameters for the batch_annotate tool, including required texts array and optional annotation options.
    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:640-653 (registration)
    Tool registration entry in the list of available tools, specifying name, description, and input schema.
    { 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)
    Switch case in the CallToolRequestHandler that routes calls to batch_annotate to its handler function.
    case 'batch_annotate': return this.handleBatchAnnotate(args);

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Augmented-Nature/BioOntology-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server