Skip to main content
Glama
Augmented-Nature

Ensembl MCP Server

get_cds_sequence

Retrieve coding sequence (CDS) for Ensembl transcripts to analyze gene coding regions and protein translation.

Instructions

Get coding sequence (CDS) for a transcript

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transcript_idYesEnsembl transcript ID
speciesNoSpecies name (default: homo_sapiens)
formatNoOutput format (default: fasta)

Implementation Reference

  • The main handler function that validates input, calls Ensembl API /sequence/id/{transcript_id}?type=cds to retrieve the coding sequence, handles JSON/FASTA output formats, and manages errors.
    private async handleGetCdsSequence(args: any) {
      if (!isValidCdsArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid CDS sequence arguments');
      }
    
      try {
        const species = this.getDefaultSpecies(args.species);
        const format = args.format || 'fasta';
    
        const response = await this.apiClient.get(`/sequence/id/${args.transcript_id}`, {
          params: {
            type: 'cds',
            species,
          },
        });
    
        return {
          content: [
            {
              type: 'text',
              text: format === 'json'
                ? JSON.stringify(response.data, null, 2)
                : typeof response.data === 'string'
                  ? response.data
                  : JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        return this.handleError(error, 'fetching CDS sequence');
      }
    }
  • src/index.ts:628-639 (registration)
    Tool registration in ListToolsRequestSchema handler, including name, description, and input schema definition.
      name: 'get_cds_sequence',
      description: 'Get coding sequence (CDS) for a transcript',
      inputSchema: {
        type: 'object',
        properties: {
          transcript_id: { type: 'string', description: 'Ensembl transcript ID' },
          species: { type: 'string', description: 'Species name (default: homo_sapiens)' },
          format: { type: 'string', enum: ['json', 'fasta'], description: 'Output format (default: fasta)' },
        },
        required: ['transcript_id'],
      },
    },
  • Type guard function for validating input arguments to the get_cds_sequence tool.
    const isValidCdsArgs = (
      args: any
    ): args is { transcript_id: string; species?: string; format?: string } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.transcript_id === 'string' &&
        args.transcript_id.length > 0 &&
        (args.species === undefined || typeof args.species === 'string') &&
        (args.format === undefined || ['json', 'fasta'].includes(args.format))
      );
    };
  • src/index.ts:846-847 (registration)
    Dispatch case in CallToolRequestSchema handler that routes calls to the get_cds_sequence handler function.
    case 'translate_sequence':
      return this.handleTranslateSequence(args);

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

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