get_3d_conformers
Retrieve 3D molecular conformer data and structural information from PubChem using compound IDs to support chemical analysis and visualization.
Instructions
Get 3D conformer data and structural information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cid | Yes | PubChem Compound ID (CID) | |
| conformer_type | No | Type of conformer data (default: 3d) |
Implementation Reference
- src/index.ts:1020-1046 (handler)The core handler function for the 'get_3d_conformers' tool. Validates input using isValidConformerArgs, fetches 3D conformer properties (Volume3D, ConformerCount3D) from PubChem API via axios, and returns formatted JSON response or throws MCP errors.
private async handleGet3dConformers(args: any) { if (!isValidConformerArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid 3D conformer arguments'); } try { const response = await this.apiClient.get(`/compound/cid/${args.cid}/property/Volume3D,ConformerCount3D/JSON`); return { content: [ { type: 'text', text: JSON.stringify({ cid: args.cid, conformer_type: args.conformer_type || '3d', properties: response.data, }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get 3D conformers: ${error instanceof Error ? error.message : 'Unknown error'}` ); } } - src/index.ts:481-488 (schema)The input schema definition for the 'get_3d_conformers' tool, specifying parameters cid (required, number or string) and optional conformer_type (enum '3d' or '2d'). Used in tool listing.
inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, conformer_type: { type: 'string', enum: ['3d', '2d'], description: 'Type of conformer data (default: 3d)' }, }, required: ['cid'], }, - src/index.ts:478-490 (registration)Registration of the 'get_3d_conformers' tool in the ListToolsRequestSchema response, including name, description, and input schema.
{ name: 'get_3d_conformers', description: 'Get 3D conformer data and structural information', inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, conformer_type: { type: 'string', enum: ['3d', '2d'], description: 'Type of conformer data (default: 3d)' }, }, required: ['cid'], }, }, { - src/index.ts:760-761 (registration)Dispatch/registration case in the CallToolRequestSchema switch statement that routes calls to the handleGet3dConformers handler.
case 'get_3d_conformers': return await this.handleGet3dConformers(args); - src/index.ts:103-112 (helper)Type guard helper function for validating arguments to the get_3d_conformers tool, checking cid and conformer_type types.
const isValidConformerArgs = ( args: any ): args is { cid: number | string; conformer_type?: string } => { return ( typeof args === 'object' && args !== null && (typeof args.cid === 'number' || typeof args.cid === 'string') && (args.conformer_type === undefined || ['3d', '2d'].includes(args.conformer_type)) ); };