get_safety_data
Retrieve GHS hazard classifications and safety information for chemical compounds using PubChem Compound IDs to assess chemical risks and ensure safe handling.
Instructions
Get GHS hazard classifications and safety information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cid | Yes | PubChem Compound ID (CID) |
Implementation Reference
- src/index.ts:1160-1181 (handler)The handler function that implements the core logic of get_safety_data: validates CID input and fetches PubChem classification data (safety/GHS info).private async handleGetSafetyData(args: any) { if (!isValidCidArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid CID arguments'); } try { const response = await this.apiClient.get(`/compound/cid/${args.cid}/classification/JSON`); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get safety data: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:640-649 (registration)Tool registration entry in ListToolsRequestSchema handler, defining name, description, and input schema.name: 'get_safety_data', description: 'Get GHS hazard classifications and safety information', inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, }, required: ['cid'], }, },
- src/index.ts:792-793 (handler)Dispatcher switch case that invokes the get_safety_data handler.case 'get_safety_data': return await this.handleGetSafetyData(args);
- src/index.ts:642-648 (schema)Input schema definition for get_safety_data tool requiring a CID.inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, }, required: ['cid'], },
- src/index.ts:66-74 (helper)Helper validation function for CID arguments, used in get_safety_data handler.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)) ); };