Skip to main content
Glama

annotate_text

Analyze text to identify and extract relevant biological ontology terms using configurable parameters for precise annotation.

Instructions

Analyze text and identify relevant ontology terms with configurable parameters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to annotate with ontology terms
ontologiesNoComma-separated ontology acronyms to use for annotation
semantic_typesNoComma-separated semantic types to filter by
expand_semantic_types_hierarchyNoInclude children of semantic types (default: false)
expand_class_hierarchyNoInclude class ancestors in annotation (default: false)
class_hierarchy_max_levelNoMaximum hierarchy depth (default: 0)
expand_mappingsNoUse manual mappings (UMLS, REST, CUI, OBOXREF) (default: false)
stop_wordsNoComma-separated custom stop words
minimum_match_lengthNoMinimum character length for matches
exclude_numbersNoExclude numeric matches (default: false)
whole_word_onlyNoMatch whole words only (default: true)
exclude_synonymsNoExclude synonym matches (default: false)
longest_onlyNoReturn only longest matches (default: false)

Implementation Reference

  • The handler function that validates input arguments using isValidAnnotateTextArgs and makes an API call to the BioOntology annotator endpoint with all supported parameters, returning JSON results or error.
    private async handleAnnotateText(args: any) {
      if (!isValidAnnotateTextArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid annotate text arguments');
      }
    
      try {
        const params: any = {
          text: args.text,
          apikey: this.apiKey,
        };
    
        // Add optional parameters
        if (args.ontologies) params.ontologies = args.ontologies;
        if (args.semantic_types) params.semantic_types = args.semantic_types;
        if (args.expand_semantic_types_hierarchy !== undefined) params.expand_semantic_types_hierarchy = args.expand_semantic_types_hierarchy;
        if (args.expand_class_hierarchy !== undefined) params.expand_class_hierarchy = args.expand_class_hierarchy;
        if (args.class_hierarchy_max_level !== undefined) params.class_hierarchy_max_level = args.class_hierarchy_max_level;
        if (args.expand_mappings !== undefined) params.expand_mappings = args.expand_mappings;
        if (args.stop_words) params.stop_words = args.stop_words;
        if (args.minimum_match_length !== undefined) params.minimum_match_length = args.minimum_match_length;
        if (args.exclude_numbers !== undefined) params.exclude_numbers = args.exclude_numbers;
        if (args.whole_word_only !== undefined) params.whole_word_only = args.whole_word_only;
        if (args.exclude_synonyms !== undefined) params.exclude_synonyms = args.exclude_synonyms;
        if (args.longest_only !== undefined) params.longest_only = args.longest_only;
    
        const response = await this.apiClient.get('/annotator', { params });
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error annotating text: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Type guard function that validates the input arguments for the annotate_text tool against the expected schema.
    const isValidAnnotateTextArgs = (
      args: any
    ): args is {
      text: string;
      ontologies?: string;
      semantic_types?: string;
      expand_semantic_types_hierarchy?: boolean;
      expand_class_hierarchy?: boolean;
      class_hierarchy_max_level?: number;
      expand_mappings?: boolean;
      stop_words?: string;
      minimum_match_length?: number;
      exclude_numbers?: boolean;
      whole_word_only?: boolean;
      exclude_synonyms?: boolean;
      longest_only?: boolean;
    } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.text === 'string' &&
        args.text.length > 0 &&
        (args.ontologies === undefined || typeof args.ontologies === 'string') &&
        (args.semantic_types === undefined || typeof args.semantic_types === 'string') &&
        (args.expand_semantic_types_hierarchy === undefined || typeof args.expand_semantic_types_hierarchy === 'boolean') &&
        (args.expand_class_hierarchy === undefined || typeof args.expand_class_hierarchy === 'boolean') &&
        (args.class_hierarchy_max_level === undefined || (typeof args.class_hierarchy_max_level === 'number' && args.class_hierarchy_max_level >= 0)) &&
        (args.expand_mappings === undefined || typeof args.expand_mappings === 'boolean') &&
        (args.stop_words === undefined || typeof args.stop_words === 'string') &&
        (args.minimum_match_length === undefined || (typeof args.minimum_match_length === 'number' && args.minimum_match_length > 0)) &&
        (args.exclude_numbers === undefined || typeof args.exclude_numbers === 'boolean') &&
        (args.whole_word_only === undefined || typeof args.whole_word_only === 'boolean') &&
        (args.exclude_synonyms === undefined || typeof args.exclude_synonyms === 'boolean') &&
        (args.longest_only === undefined || typeof args.longest_only === 'boolean')
      );
    };
  • src/index.ts:598-620 (registration)
    Registration of the 'annotate_text' tool in the ListTools response, including full inputSchema definition.
    {
      name: 'annotate_text',
      description: 'Analyze text and identify relevant ontology terms with configurable parameters',
      inputSchema: {
        type: 'object',
        properties: {
          text: { type: 'string', description: 'Text to annotate with ontology terms' },
          ontologies: { type: 'string', description: 'Comma-separated ontology acronyms to use for annotation' },
          semantic_types: { type: 'string', description: 'Comma-separated semantic types to filter by' },
          expand_semantic_types_hierarchy: { type: 'boolean', description: 'Include children of semantic types (default: false)' },
          expand_class_hierarchy: { type: 'boolean', description: 'Include class ancestors in annotation (default: false)' },
          class_hierarchy_max_level: { type: 'number', description: 'Maximum hierarchy depth (default: 0)', minimum: 0 },
          expand_mappings: { type: 'boolean', description: 'Use manual mappings (UMLS, REST, CUI, OBOXREF) (default: false)' },
          stop_words: { type: 'string', description: 'Comma-separated custom stop words' },
          minimum_match_length: { type: 'number', description: 'Minimum character length for matches', minimum: 1 },
          exclude_numbers: { type: 'boolean', description: 'Exclude numeric matches (default: false)' },
          whole_word_only: { type: 'boolean', description: 'Match whole words only (default: true)' },
          exclude_synonyms: { type: 'boolean', description: 'Exclude synonym matches (default: false)' },
          longest_only: { type: 'boolean', description: 'Return only longest matches (default: false)' },
        },
        required: ['text'],
      },
    },
  • src/index.ts:710-711 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement that routes to the handleAnnotateText method.
    case 'annotate_text':
      return this.handleAnnotateText(args);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'analyze' and 'identify' imply a read-only operation, it doesn't clarify if this is computationally intensive, has rate limits, requires specific permissions, or what the output format looks like. For a tool with 13 parameters and no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. It's appropriately sized for the tool's complexity, with zero waste or redundancy, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (13 parameters, no output schema, and no annotations), the description is insufficient. It doesn't cover behavioral aspects like performance, error handling, or output structure, and while the schema handles parameters, the lack of annotations means the description should compensate more for transparency gaps. This leaves the agent under-informed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'configurable parameters,' but doesn't add specific meaning beyond what the input schema provides. Since schema description coverage is 100%, the schema already documents all 13 parameters thoroughly. The description doesn't explain parameter interactions, defaults, or usage examples, so it meets the baseline but doesn't enhance understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Analyze text and identify relevant ontology terms with configurable parameters.' It specifies the verb ('analyze' and 'identify'), the resource ('text'), and the action ('annotate with ontology terms'). However, it doesn't explicitly differentiate from sibling tools like 'batch_annotate' or 'search_terms,' which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'batch_annotate' for multiple texts or 'search_terms' for different search functionalities, nor does it specify prerequisites or contexts for usage. This leaves the agent without clear direction on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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