Skip to main content
Glama

export_for_pymol

Export protein structure data from AlphaFold MCP Server in PyMOL-compatible format for visualization, with optional confidence score coloring.

Instructions

Export structure data formatted for PyMOL visualization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeConfidenceNoInclude confidence score coloring (default: true)
uniprotIdYesUniProt accession

Implementation Reference

  • The handler function that executes the tool logic: fetches AlphaFold structure data and generates a PyMOL script for visualization, optionally including confidence-based coloring instructions.
      private async handleExportForPymol(args: any) {
        if (!isValidExportArgs(args)) {
          throw new McpError(ErrorCode.InvalidParams, 'Invalid PyMOL export 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 includeConfidence = args.includeConfidence !== false;
    
          const pymolScript = `
    # PyMOL script for AlphaFold structure ${args.uniprotId}
    fetch ${structure.pdbUrl}
    as cartoon
    color spectrum
    ${includeConfidence ? `
    # Color by confidence
    # Very high confidence (pLDDT > 90): blue
    # Confident (pLDDT 70-90): cyan
    # Low confidence (pLDDT 50-70): yellow
    # Very low confidence (pLDDT < 50): orange
    ` : ''}
    center
    zoom
    `;
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  uniprotId: args.uniprotId,
                  pymolScript,
                  structureUrl: structure.pdbUrl,
                  instructions: 'Copy the PyMOL script above and paste it into PyMOL command line',
                }, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `Error exporting for PyMOL: ${error instanceof Error ? error.message : 'Unknown error'}`,
              },
            ],
            isError: true,
          };
        }
      }
  • src/index.ts:539-549 (registration)
    Registration of the 'export_for_pymol' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
      name: 'export_for_pymol',
      description: 'Export structure data formatted for PyMOL visualization',
      inputSchema: {
        type: 'object',
        properties: {
          uniprotId: { type: 'string', description: 'UniProt accession' },
          includeConfidence: { type: 'boolean', description: 'Include confidence score coloring (default: true)' },
        },
        required: ['uniprotId'],
      },
    },
  • src/index.ts:617-618 (registration)
    Switch case in CallToolRequestSchema handler that routes 'export_for_pymol' calls to the handler function.
    case 'export_for_pymol':
      return this.handleExportForPymol(args);
  • Type guard function validating input arguments for export tools (used by export_for_pymol handler).
    const isValidExportArgs = (
      args: any
    ): args is { uniprotId: string; includeConfidence?: boolean } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.uniprotId === 'string' &&
        args.uniprotId.length > 0 &&
        (args.includeConfidence === undefined || typeof args.includeConfidence === 'boolean')
      );
    };
  • Input schema definition for the 'export_for_pymol' tool.
    inputSchema: {
      type: 'object',
      properties: {
        uniprotId: { type: 'string', description: 'UniProt accession' },
        includeConfidence: { type: 'boolean', description: 'Include confidence score coloring (default: true)' },
      },
      required: ['uniprotId'],
    },

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