Skip to main content
Glama

get_compound_synonyms

Retrieve all names and synonyms for chemical compounds using PubChem Compound ID to identify substances across different naming conventions and databases.

Instructions

Get all names and synonyms for a compound

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesPubChem Compound ID (CID)

Implementation Reference

  • The main handler function that validates the CID input and fetches synonyms from the PubChem API endpoint /compound/cid/{cid}/synonyms/JSON, returning the JSON response.
    private async handleGetCompoundSynonyms(args: any) { if (!isValidCidArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid CID arguments'); } try { const response = await this.apiClient.get(`/compound/cid/${args.cid}/synonyms/JSON`); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get compound synonyms: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
  • src/index.ts:428-438 (registration)
    Tool registration in the ListToolsRequestHandler response, defining the tool name, description, and input schema.
    { name: 'get_compound_synonyms', description: 'Get all names and synonyms for a compound', inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, }, required: ['cid'], }, },
  • src/index.ts:750-751 (registration)
    Dispatch case in the CallToolRequestHandler switch statement that routes to the handler function.
    case 'get_compound_synonyms': return await this.handleGetCompoundSynonyms(args);
  • JSON Schema definition for the tool's input parameters.
    inputSchema: { type: 'object', properties: { cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' }, }, required: ['cid'], },
  • Input validation helper function used by the handler to validate CID arguments.
    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/k-lordbodin7/PubChem-MCP-Server'

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