Skip to main content
Glama

get_protein_sequence

Retrieve amino acid sequences for proteins using UniProt accession numbers. Supports FASTA or JSON output formats.

Instructions

Get the amino acid sequence for a protein

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessionYesUniProt accession number
formatNoOutput format (default: fasta)

Implementation Reference

  • The main handler function that validates input and fetches the protein sequence from the UniProt API endpoint `/uniprotkb/{accession}` in the specified format (default: fasta), returning the sequence data or error.
    private async handleGetProteinSequence(args: any) {
      if (!isValidSequenceArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid sequence arguments');
      }
    
      try {
        const format = args.format || 'fasta';
        const response = await this.apiClient.get(`/uniprotkb/${args.accession}`, {
          params: { format },
        });
    
        return {
          content: [
            {
              type: 'text',
              text: format === 'json'
                ? JSON.stringify(response.data, null, 2)
                : String(response.data),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching sequence: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:440-450 (registration)
    Registration of the 'get_protein_sequence' tool in the ListTools response, including its description and input schema definition.
      name: 'get_protein_sequence',
      description: 'Get the amino acid sequence for a protein',
      inputSchema: {
        type: 'object',
        properties: {
          accession: { type: 'string', description: 'UniProt accession number' },
          format: { type: 'string', enum: ['fasta', 'json'], description: 'Output format (default: fasta)' },
        },
        required: ['accession'],
      },
    },
  • src/index.ts:734-735 (registration)
    Dispatcher case in the CallToolRequestSchema handler that routes calls to the handleGetProteinSequence method.
    case 'get_protein_sequence':
      return this.handleGetProteinSequence(args);
  • Input validation function (type guard) for the get_protein_sequence tool arguments, ensuring valid accession and optional format.
    const isValidSequenceArgs = (
      args: any
    ): args is { accession: string; format?: 'fasta' | 'json' } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.accession === 'string' &&
        args.accession.length > 0 &&
        (args.format === undefined || ['fasta', 'json'].includes(args.format))
      );
    };

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

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