download_structure
Retrieve protein structure coordinates in PDB, mmCIF, MMTF, or XML formats by specifying the PDB ID and optional biological assembly ID.
Instructions
Download structure coordinates in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assembly_id | No | Biological assembly ID (optional) | |
| format | No | File format (default: pdb) | |
| pdb_id | Yes | PDB ID (4-character code) |
Implementation Reference
- src/index.ts:477-516 (handler)The handler function that validates arguments, constructs the download URL for the specified PDB structure (with optional assembly), fetches the file using axios from RCSB files server, and returns the content or error.private async handleDownloadStructure(args: any) { if (!isValidDownloadArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid download structure arguments'); } try { const pdbId = args.pdb_id.toLowerCase(); const format = args.format || 'pdb'; const assemblyId = args.assembly_id; let url: string; if (assemblyId) { const extension = format === 'mmcif' ? 'cif' : format; url = `https://files.rcsb.org/download/${pdbId}-assembly${assemblyId}.${extension}`; } else { const extension = format === 'mmcif' ? 'cif' : format; url = `https://files.rcsb.org/download/${pdbId}.${extension}`; } const response = await axios.get(url); return { content: [ { type: 'text', text: `Structure file for ${args.pdb_id} (${format.toUpperCase()} format)${assemblyId ? ` - Assembly ${assemblyId}` : ''}:\n\n${response.data}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error downloading structure: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; }
- src/index.ts:269-280 (schema)The input schema for the download_structure tool, defining required pdb_id and optional format and assembly_id parameters.name: 'download_structure', description: 'Download structure coordinates in various formats', inputSchema: { type: 'object', properties: { pdb_id: { type: 'string', description: 'PDB ID (4-character code)' }, format: { type: 'string', enum: ['pdb', 'mmcif', 'mmtf', 'xml'], description: 'File format (default: pdb)' }, assembly_id: { type: 'string', description: 'Biological assembly ID (optional)' }, }, required: ['pdb_id'], }, },
- src/index.ts:315-316 (registration)Switch case in the CallToolRequestHandler that registers and routes calls to 'download_structure' to its handler method.case 'download_structure': return this.handleDownloadStructure(args);
- src/index.ts:51-63 (helper)Type guard helper function that validates the arguments for download_structure: checks PDB ID format, valid format enum, and string assembly_id.const isValidDownloadArgs = ( args: any ): args is { pdb_id: string; format?: 'pdb' | 'mmcif' | 'mmtf' | 'xml'; assembly_id?: string } => { 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 || ['pdb', 'mmcif', 'mmtf', 'xml'].includes(args.format)) && (args.assembly_id === undefined || typeof args.assembly_id === 'string') ); };