get_structure_info
Retrieve detailed information about a specific PDB structure by providing its PDB ID. Output formats include JSON, PDB, mmCIF, or XML for flexible use in analysis and research.
Instructions
Get detailed information for a specific PDB structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Output format (default: json) | |
| pdb_id | Yes | PDB ID (4-character code, e.g., 1ABC) |
Implementation Reference
- src/index.ts:429-475 (handler)The handler function that validates input, fetches PDB structure data from RCSB API based on pdb_id and optional format, and returns the content or error.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)Tool registration in the ListTools response, including name, description, and input schema definition.{ 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:259-266 (schema)Input schema definition for the get_structure_info tool, specifying parameters and validation rules.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:38-49 (helper)Helper function for validating the input arguments for PDB ID and optional format used in the handler.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)) ); };
- src/index.ts:313-314 (registration)Dispatch case in the CallToolRequestSchema handler that routes to the tool's handler function.case 'get_structure_info': return this.handleGetStructureInfo(args);