Skip to main content
Glama
Augmented-Nature

PDB MCP Server

get_structure_info

Retrieve detailed structural data for a specific protein or nucleic acid from the Protein Data Bank using its PDB ID.

Instructions

Get detailed information for a specific PDB structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdb_idYesPDB ID (4-character code, e.g., 1ABC)
formatNoOutput format (default: json)

Implementation Reference

  • Executes the 'get_structure_info' tool: validates input, fetches PDB structure data from RCSB API in specified format (JSON or file), handles errors.
    private async handleGetStructureInfo(args: any) {
      if (!isValidPDBIdArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid PDB ID arguments');
      }
    
      try {
        const pdbId = args.pdb_id.toLowerCase();
        const format = args.format || 'json';
    
        if (format === 'json') {
          const response = await this.apiClient.get(`/core/entry/${pdbId}`);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(response.data, null, 2),
              },
            ],
          };
        } else {
          // Handle file format downloads
          const baseUrl = 'https://files.rcsb.org/download';
          const extension = format === 'mmcif' ? 'cif' : format;
          const url = `${baseUrl}/${pdbId}.${extension}`;
    
          const response = await axios.get(url);
          return {
            content: [
              {
                type: 'text',
                text: response.data,
              },
            ],
          };
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching structure info: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:256-267 (registration)
    Registers the 'get_structure_info' tool in ListTools response with name, description, and input schema.
    {
      name: 'get_structure_info',
      description: 'Get detailed information for a specific PDB structure',
      inputSchema: {
        type: 'object',
        properties: {
          pdb_id: { type: 'string', description: 'PDB ID (4-character code, e.g., 1ABC)' },
          format: { type: 'string', enum: ['json', 'pdb', 'mmcif', 'xml'], description: 'Output format (default: json)' },
        },
        required: ['pdb_id'],
      },
    },
  • src/index.ts:313-314 (registration)
    Dispatches tool calls for 'get_structure_info' to the handler in CallToolRequestSchema handler.
    case 'get_structure_info':
      return this.handleGetStructureInfo(args);
  • Helper function to validate input arguments for the 'get_structure_info' tool (PDB ID format and optional format).
    const isValidPDBIdArgs = (
      args: any
    ): args is { pdb_id: string; format?: 'json' | 'pdb' | 'mmcif' | 'xml' } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.pdb_id === 'string' &&
        args.pdb_id.length === 4 &&
        /^[0-9][a-zA-Z0-9]{3}$/i.test(args.pdb_id) &&
        (args.format === undefined || ['json', 'pdb', 'mmcif', 'xml'].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/PDB-MCP-Server'

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