Skip to main content
Glama
Augmented-Nature

GeneOntology MCP Server

validate_go_id

Validate Gene Ontology identifier format and verify term existence for accurate ontology-based analysis and annotation research.

Instructions

Validate GO identifier format and check if term exists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesGO identifier to validate

Implementation Reference

  • The main handler function that validates the GO identifier format using regex, normalizes it, queries the QuickGO API to check existence, and returns detailed validation results.
    private async handleValidateGoId(args: any) {
      if (!isValidTermArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'GO ID is required');
      }
    
      try {
        const termId = this.normalizeGoId(args.id);
    
        // Check format
        const isValidFormat = /^GO:\d{7}$/.test(termId);
    
        let exists = false;
        let termInfo = null;
    
        if (isValidFormat) {
          try {
            const response = await this.quickGoClient.get(`/ontology/go/terms/${termId}`);
            termInfo = response.data.results?.[0];
            exists = !!termInfo;
          } catch (e) {
            exists = false;
          }
        }
    
        const validation = {
          input_id: args.id,
          normalized_id: termId,
          valid_format: isValidFormat,
          exists: exists,
          term_info: exists ? {
            name: termInfo?.name,
            namespace: termInfo?.aspect === 'F' ? 'molecular_function' :
                      termInfo?.aspect === 'P' ? 'biological_process' : 'cellular_component',
            obsolete: termInfo?.isObsolete || false
          } : null,
          format_rules: {
            pattern: 'GO:NNNNNNN',
            example: 'GO:0008150',
            description: 'GO identifiers consist of "GO:" followed by exactly 7 digits'
          }
        };
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(validation, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error validating GO ID: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Defines the input schema for the validate_go_id tool, requiring a single 'id' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        id: { type: 'string', description: 'GO identifier to validate' },
      },
      required: ['id'],
    },
  • src/index.ts:314-324 (registration)
    Registers the validate_go_id tool in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: 'validate_go_id',
      description: 'Validate GO identifier format and check if term exists',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string', description: 'GO identifier to validate' },
        },
        required: ['id'],
      },
    },
  • src/index.ts:347-348 (registration)
    Dispatches calls to the validate_go_id tool to its handler function in the CallToolRequestSchema switch statement.
    case 'validate_go_id':
      return this.handleValidateGoId(args);
  • Helper function used by the handler to normalize GO IDs to the standard 'GO:NNNNNNN' format.
    private normalizeGoId(id: string): string {
      if (id.startsWith('GO:')) {
        return id;
      }
      if (/^\d{7}$/.test(id)) {
        return `GO:${id}`;
      }
      return id;
    }

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/GeneOntology-MCP-Server'

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