Skip to main content
Glama

convert_coordinates

Convert genomic coordinates between hg19 and hg38 genome builds for accurate cross-study data analysis and integration.

Instructions

Convert between different genomic coordinate systems

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chrYesChromosome (e.g., chr1, chr2, chrX)
positionYesGenomic position to convert
fromBuildNoSource genome build (default: hg38)hg38
toBuildNoTarget genome build (default: hg19)hg19

Implementation Reference

  • Main handler function for the convert_coordinates tool. Performs input validation, approximate coordinate conversion between hg19/hg38 using helper offsets, generates detailed output with warnings and recommendations for accurate tools.
    async convertCoordinates(args: any) {
      if (!args.chr || !args.position) {
        throw new Error('chr and position parameters are required');
      }
      
      if (typeof args.position !== 'number') {
        throw new Error('position parameter must be a number');
      }
    
      const fromBuild = args.fromBuild || 'hg38';
      const toBuild = args.toBuild || 'hg19';
      
      // Validate genome builds
      const validBuilds = ['hg19', 'hg38'];
      if (!validBuilds.includes(fromBuild) || !validBuilds.includes(toBuild)) {
        throw new Error('Genome builds must be either "hg19" or "hg38"');
      }
    
      if (fromBuild === toBuild) {
        return {
          content: [{
            type: "text",
            text: `No conversion needed: ${args.chr}:${args.position.toLocaleString()} (${fromBuild} → ${toBuild})`
          }]
        };
      }
    
      let output = `**Genomic Coordinate Conversion**\n`;
      output += `Input: ${args.chr}:${args.position.toLocaleString()} (${fromBuild})\n`;
      output += `Target: ${toBuild}\n\n`;
    
      // Note: This is a simplified coordinate conversion
      // Real coordinate conversion requires liftOver tools or chain files
      
      // Provide approximate conversion based on known differences
      let convertedPosition = args.position;
      let conversionNote = '';
      
      if (fromBuild === 'hg19' && toBuild === 'hg38') {
        // Very rough approximation - real conversion needs liftOver
        // Most positions shift by small amounts, some by larger amounts
        const roughOffset = this.getApproximateHg19ToHg38Offset(args.chr, args.position);
        convertedPosition = args.position + roughOffset;
        conversionNote = 'hg19 to hg38 conversion (approximate)';
      } else if (fromBuild === 'hg38' && toBuild === 'hg19') {
        // Reverse conversion
        const roughOffset = this.getApproximateHg38ToHg19Offset(args.chr, args.position);
        convertedPosition = args.position + roughOffset;
        conversionNote = 'hg38 to hg19 conversion (approximate)';
      }
    
      output += `**Converted Coordinates:**\n`;
      output += `• **${toBuild}**: ${args.chr}:${convertedPosition.toLocaleString()}\n`;
      output += `• **Offset**: ${(convertedPosition - args.position).toLocaleString()} bp\n\n`;
    
      output += `**Conversion Details:**\n`;
      output += `• Method: ${conversionNote}\n`;
      output += `• Chromosome: ${args.chr}\n`;
      output += `• Region type: ${this.getRegionType(args.chr, args.position)}\n\n`;
    
      output += `**⚠️ Important Limitations:**\n`;
      output += `• This is an APPROXIMATE conversion for demonstration purposes\n`;
      output += `• Real coordinate conversion requires UCSC liftOver tools\n`;
      output += `• Some positions may not have direct equivalents between builds\n`;
      output += `• Insertions/deletions between builds can affect accuracy\n\n`;
    
      output += `**Recommended Tools for Accurate Conversion:**\n`;
      output += `• UCSC Genome Browser LiftOver: https://genome.ucsc.edu/cgi-bin/hgLiftOver\n`;
      output += `• Ensembl Assembly Converter: https://www.ensembl.org/Homo_sapiens/Tools/AssemblyConverter\n`;
      output += `• NCBI Remap: https://www.ncbi.nlm.nih.gov/genome/tools/remap\n`;
    
      return {
        content: [{
          type: "text",
          text: output
        }]
      };
    }
  • MCP tool schema definition including input parameters, types, descriptions, defaults, and required fields for convert_coordinates.
    {
      name: "convert_coordinates",
      description: "Convert between different genomic coordinate systems",
      inputSchema: {
        type: "object",
        properties: {
          chr: {
            type: "string",
            description: "Chromosome (e.g., chr1, chr2, chrX)"
          },
          position: {
            type: "integer",
            description: "Genomic position to convert"
          },
          fromBuild: {
            type: "string",
            description: "Source genome build (default: hg38)",
            enum: ["hg19", "hg38"],
            default: "hg38"
          },
          toBuild: {
            type: "string", 
            description: "Target genome build (default: hg19)",
            enum: ["hg19", "hg38"],
            default: "hg19"
          }
        },
        required: ["chr", "position"]
      }
    }
  • src/index.ts:779-786 (registration)
    Tool call dispatcher that maps convert_coordinates requests to the referenceHandlers.convertCoordinates implementation, passing parsed arguments.
    if (name === "convert_coordinates") {
      return await referenceHandlers.convertCoordinates({
        chr: args?.chr,
        position: args?.position,
        fromBuild: args?.fromBuild,
        toBuild: args?.toBuild
      });
    }
  • Private helper method providing chromosome-specific approximate offsets for hg19 to hg38 coordinate conversion, used by the main handler.
    private getApproximateHg19ToHg38Offset(chr: string, position: number): number {
      // This is a very simplified approximation
      // Real conversion requires comprehensive chain files
      
      // Most positions have small positive offsets in hg38
      // This is just for demonstration purposes
      const baseOffset = Math.floor(position * 0.0001); // Very rough approximation
      
      // Some chromosomes have different patterns
      switch (chr.toLowerCase()) {
        case 'chr1': return baseOffset + 100;
        case 'chr2': return baseOffset - 50;
        case 'chrx': return baseOffset + 200;
        case 'chry': return baseOffset - 100;
        default: return baseOffset;
      }
    }
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. It states the conversion action but doesn't describe what happens during conversion (e.g., liftOver-like mapping, potential data loss), output format, error handling, or performance considerations. For a tool with 4 parameters and no annotation coverage, 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 directly states the tool's purpose without any fluff or redundancy. It's appropriately sized for a straightforward conversion tool and front-loads the core functionality, 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 (coordinate conversion with 4 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the conversion outputs (e.g., new coordinates, mapping quality), potential limitations (e.g., regions without direct mapping), or how it integrates with sibling tools. This leaves significant gaps for an agent to use the tool effectively.

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?

Schema description coverage is 100%, so the schema already documents all parameters with descriptions, enums, and defaults. The description adds no additional parameter semantics beyond implying coordinate conversion involves 'chr' and 'position' inputs. This meets the baseline of 3 when the schema does the heavy lifting, but doesn't compensate with extra context like conversion algorithms or edge cases.

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 as converting between genomic coordinate systems, which is a specific verb+resource combination. It distinguishes itself from sibling tools that focus on analysis, querying, or validation rather than coordinate conversion. However, it doesn't specify what exactly gets converted (e.g., positions, ranges) or mention the default direction, keeping it from 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 any prerequisites, limitations, or typical use cases (e.g., for mapping variants between genome builds). With many sibling tools available, this lack of contextual guidance leaves the agent to infer usage based on tool names alone.

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

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