analyze_stereochemistry
Identify and evaluate stereochemistry, chirality, and isomer details using PubChem Compound ID for precise chemical structure analysis.
Instructions
Analyze stereochemistry, chirality, and isomer information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cid | Yes | PubChem Compound ID (CID) |
Implementation Reference
- src/index.ts:1048-1073 (handler)The handler function that performs the core logic: validates input CID, queries PubChem API for stereochemistry properties (AtomStereoCount, DefinedAtomStereoCount, BondStereoCount, DefinedBondStereoCount, IsomericSMILES), and returns formatted results.private async handleAnalyzeStereochemistry(args: any) { if (!isValidCidArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid stereochemistry arguments'); } try { const response = await this.apiClient.get(`/compound/cid/${args.cid}/property/AtomStereoCount,DefinedAtomStereoCount,BondStereoCount,DefinedBondStereoCount,IsomericSMILES/JSON`); return { content: [ { type: 'text', text: JSON.stringify({ cid: args.cid, stereochemistry: response.data, }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to analyze stereochemistry: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:490-500 (registration)Tool registration in the ListTools response, including name, description, and input schema requiring a CID.{ name: 'analyze_stereochemistry', description: 'Analyze stereochemistry, chirality, and isomer information', inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, }, required: ['cid'], }, },
- src/index.ts:762-763 (handler)Dispatcher case in the CallTool handler that routes the tool call to the specific handler function.case 'analyze_stereochemistry': return await this.handleAnalyzeStereochemistry(args);
- src/index.ts:493-499 (schema)Input schema defining the expected arguments: a CID as number or string.inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, }, required: ['cid'], },
- src/index.ts:65-74 (helper)Validation helper function used to check if arguments contain a valid CID, reused across tools.const isValidCidArgs = ( args: any ): args is { cid: number | string; format?: string } => { return ( typeof args === 'object' && args !== null && (typeof args.cid === 'number' || typeof args.cid === 'string') && (args.format === undefined || ['json', 'sdf', 'xml', 'asnt', 'asnb'].includes(args.format)) ); };