Skip to main content
Glama

get_safety_data

Retrieve GHS hazard classifications and safety information for chemical compounds using PubChem Compound IDs with this dedicated tool.

Instructions

Get GHS hazard classifications and safety information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesPubChem Compound ID (CID)

Implementation Reference

  • The main handler function that implements the get_safety_data tool. Validates input CID, fetches classification/safety data from PubChem API, and returns 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 (registration)
    Tool registration entry in the ListToolsRequestSchema handler, defining the tool name, description, and input schema requiring a 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)
    Dispatch case in the CallToolRequestSchema handler that routes get_safety_data calls to the specific handler method.
    case 'get_safety_data': return await this.handleGetSafetyData(args);
  • Helper validation function used by get_safety_data handler to validate input arguments, specifically checking for valid CID.
    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)) ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Augmented-Nature/PubChem-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server