recommend_ontologies
Discover relevant biological ontologies for your text or keywords by customizing weights for coverage, acceptance, detail, and specialization criteria. Optimize results with tailored settings.
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) | |
| max_elements_set | No | Max ontologies per set (2-4, default: 3) | |
| ontologies | No | Comma-separated ontology acronyms to limit evaluation to | |
| output_type | No | Output type: 1=individual ontologies, 2=ontology sets (default: 1) | |
| wa | No | Weight for acceptance criterion (0-1, default: 0.15) | |
| wc | No | Weight for coverage criterion (0-1, default: 0.55) | |
| wd | No | Weight for detail criterion (0-1, default: 0.15) | |
| ws | No | Weight for specialization criterion (0-1, default: 0.15) |
Implementation Reference
- src/index.ts:951-992 (handler)The handler function that implements the core logic of the 'recommend_ontologies' tool. It validates the input arguments, constructs the API request parameters for the BioOntology recommender endpoint, performs the HTTP GET request, and returns the response as formatted JSON 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:621-639 (registration)The tool registration in the ListTools response, defining the name, description, and input schema for 'recommend_ontologies'.{ 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:163-190 (schema)Input validation schema as a TypeScript type guard function for the recommend_ontologies tool arguments.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:712-713 (registration)The switch case in the CallToolRequest handler that routes calls to the recommend_ontologies handler method.case 'recommend_ontologies': return this.handleRecommendOntologies(args);