get_safety_data
Retrieve GHS hazard classifications and safety information for chemical compounds using PubChem Compound IDs.
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)Implements the core logic of the get_safety_data tool: validates CID input, fetches safety classification data from PubChem API, and returns formatted JSON response.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:639-649 (schema)Defines the tool metadata including name, description, and input schema requiring a PubChem CID.{ 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 (registration)Registers the tool dispatch in the CallToolRequestSchema switch statement, routing calls to the handler method.case 'get_safety_data': return await this.handleGetSafetyData(args);
- src/index.ts:732-733 (registration)Registers the tool in the list returned by ListToolsRequestSchema, making it discoverable by clients.}));