recommend_ontologies
Find relevant biological ontologies for your text or keywords by customizing weighting criteria like coverage, acceptance, detail, and specialization.
Instructions
Get ontology recommendations for text or keywords with customizable weights
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Input text or comma-separated keywords | |
| input_type | No | Input type: 1=text, 2=keywords (default: 1) | |
| output_type | No | Output type: 1=individual ontologies, 2=ontology sets (default: 1) | |
| max_elements_set | No | Max ontologies per set (2-4, default: 3) | |
| wc | No | Weight for coverage criterion (0-1, default: 0.55) | |
| wa | No | Weight for acceptance criterion (0-1, default: 0.15) | |
| wd | No | Weight for detail criterion (0-1, default: 0.15) | |
| ws | No | Weight for specialization criterion (0-1, default: 0.15) | |
| ontologies | No | Comma-separated ontology acronyms to limit evaluation to |
Implementation Reference
- src/index.ts:951-993 (handler)The main handler function that validates input arguments, constructs parameters for the BioOntology /recommender API endpoint, fetches recommendations, and returns the JSON response or an error message.private async handleRecommendOntologies(args: any) { if (!isValidRecommendOntologiesArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid recommend ontologies arguments'); } try { const params: any = { input: args.input, apikey: this.apiKey, }; // Add optional parameters if (args.input_type !== undefined) params.input_type = args.input_type; if (args.output_type !== undefined) params.output_type = args.output_type; if (args.max_elements_set !== undefined) params.max_elements_set = args.max_elements_set; if (args.wc !== undefined) params.wc = args.wc; if (args.wa !== undefined) params.wa = args.wa; if (args.wd !== undefined) params.wd = args.wd; if (args.ws !== undefined) params.ws = args.ws; if (args.ontologies) params.ontologies = args.ontologies; const response = await this.apiClient.get('/recommender', { params }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error recommending ontologies: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:163-190 (schema)Type guard function validating the structure and types of arguments for the recommend_ontologies tool.const isValidRecommendOntologiesArgs = ( args: any ): args is { input: string; input_type?: number; output_type?: number; max_elements_set?: number; wc?: number; wa?: number; wd?: number; ws?: number; ontologies?: string; } => { return ( typeof args === 'object' && args !== null && typeof args.input === 'string' && args.input.length > 0 && (args.input_type === undefined || (typeof args.input_type === 'number' && [1, 2].includes(args.input_type))) && (args.output_type === undefined || (typeof args.output_type === 'number' && [1, 2].includes(args.output_type))) && (args.max_elements_set === undefined || (typeof args.max_elements_set === 'number' && [2, 3, 4].includes(args.max_elements_set))) && (args.wc === undefined || (typeof args.wc === 'number' && args.wc >= 0 && args.wc <= 1)) && (args.wa === undefined || (typeof args.wa === 'number' && args.wa >= 0 && args.wa <= 1)) && (args.wd === undefined || (typeof args.wd === 'number' && args.wd >= 0 && args.wd <= 1)) && (args.ws === undefined || (typeof args.ws === 'number' && args.ws >= 0 && args.ws <= 1)) && (args.ontologies === undefined || typeof args.ontologies === 'string') ); };
- src/index.ts:621-639 (registration)Registers the recommend_ontologies tool in the ListTools response, including name, description, and detailed inputSchema.{ name: 'recommend_ontologies', description: 'Get ontology recommendations for text or keywords with customizable weights', inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Input text or comma-separated keywords' }, input_type: { type: 'number', description: 'Input type: 1=text, 2=keywords (default: 1)', enum: [1, 2] }, output_type: { type: 'number', description: 'Output type: 1=individual ontologies, 2=ontology sets (default: 1)', enum: [1, 2] }, max_elements_set: { type: 'number', description: 'Max ontologies per set (2-4, default: 3)', enum: [2, 3, 4] }, wc: { type: 'number', description: 'Weight for coverage criterion (0-1, default: 0.55)', minimum: 0, maximum: 1 }, wa: { type: 'number', description: 'Weight for acceptance criterion (0-1, default: 0.15)', minimum: 0, maximum: 1 }, wd: { type: 'number', description: 'Weight for detail criterion (0-1, default: 0.15)', minimum: 0, maximum: 1 }, ws: { type: 'number', description: 'Weight for specialization criterion (0-1, default: 0.15)', minimum: 0, maximum: 1 }, ontologies: { type: 'string', description: 'Comma-separated ontology acronyms to limit evaluation to' }, }, required: ['input'], }, },
- src/index.ts:712-713 (registration)Switch case in CallToolRequest handler that routes recommend_ontologies calls to the specific handler method.case 'recommend_ontologies': return this.handleRecommendOntologies(args);