Skip to main content
Glama

download_structure

Retrieve AlphaFold protein structure files in PDB, CIF, or BCIF formats by providing a UniProt accession ID to streamline structural biology research.

Instructions

Download AlphaFold structure file in specified format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoFile format (default: pdb)
uniprotIdYesUniProt accession

Implementation Reference

  • The handler function that implements the download_structure tool. It fetches the structure prediction for a UniProt ID from the AlphaFold API, selects the appropriate format URL (pdb, cif, or bcif), downloads the file content, and returns it embedded in a text response.
    private async handleDownloadStructure(args: any) {
      if (!isValidUniProtArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid download structure arguments');
      }
    
      try {
        const response = await this.apiClient.get(`/prediction/${args.uniprotId}`);
        const structures = response.data;
    
        if (!structures || structures.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: `No structure available for ${args.uniprotId}`,
              },
            ],
          };
        }
    
        const structure = structures[0];
        const format = args.format || 'pdb';
        const url = format === 'pdb' ? structure.pdbUrl :
                   format === 'cif' ? structure.cifUrl :
                   format === 'bcif' ? structure.bcifUrl : structure.pdbUrl;
    
        const fileResponse = await axios.get(url);
    
        return {
          content: [
            {
              type: 'text',
              text: `Structure file for ${args.uniprotId} (${format.toUpperCase()} format):\n\n${fileResponse.data}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error downloading structure: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema definition for the download_structure tool as returned by ListToolsRequestSchema. Defines the expected parameters: uniprotId (string, required) and optional format (enum: pdb, cif, bcif).
      name: 'download_structure',
      description: 'Download AlphaFold structure file in specified format',
      inputSchema: {
        type: 'object',
        properties: {
          uniprotId: { type: 'string', description: 'UniProt accession' },
          format: { type: 'string', enum: ['pdb', 'cif', 'bcif'], description: 'File format (default: pdb)' },
        },
        required: ['uniprotId'],
      },
    },
  • src/index.ts:582-582 (registration)
    The case statement in the CallToolRequestSchema handler's switch that dispatches calls to the download_structure tool to its handler function.
    return this.handleDownloadStructure(args);
  • Type guard and validation function for UniProt arguments (uniprotId and optional format), used by the download_structure handler to validate input parameters.
    const isValidUniProtArgs = (
      args: any
    ): args is { uniprotId: string; format?: 'pdb' | 'cif' | 'bcif' | 'json' } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.uniprotId === 'string' &&
        args.uniprotId.length > 0 &&
        (args.format === undefined || ['pdb', 'cif', 'bcif', '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/AlphaFold-MCP-Server'

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