Skip to main content
Glama
Augmented-Nature

Unofficial PubChem MCP Server

get_compound_synonyms

Retrieve all names and synonyms for a chemical compound using its PubChem CID to identify substances across different naming conventions.

Instructions

Get all names and synonyms for a compound

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesPubChem Compound ID (CID)

Implementation Reference

  • The main execution handler for the get_compound_synonyms tool. Validates the input using isValidCidArgs, calls the PubChem API to retrieve synonyms for the given CID, and returns the JSON response as text content.
    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 ListToolsRequestSchema handler, defining the tool name, description, and input schema requiring a 'cid' parameter of type number or string.
    {
      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'],
      },
    },
  • Input schema definition for the get_compound_synonyms tool, specifying an object with a required 'cid' property that accepts number or string.
    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 CallToolRequestSchema handler that routes calls to the get_compound_synonyms tool to its handler function.
    case 'get_compound_synonyms':
      return await this.handleGetCompoundSynonyms(args);
  • Helper validation function isValidCidArgs used by the handler to check input arguments, ensuring 'cid' is number or string and optional 'format' is valid.
    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))
      );
    };

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but does not disclose any behavioral traits such as rate limits, authentication needs, error handling, or the format of returned synonyms. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words or fluff. It is front-loaded and appropriately sized for a simple retrieval tool, making it easy to parse and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with one parameter, high schema coverage, and no output schema, the description is minimally complete. It covers the basic function but lacks details on output format, error cases, or integration with sibling tools. Given the simplicity, it meets the minimum threshold but could be more informative to fully guide an AI agent in complex scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'cid' parameter clearly documented as 'PubChem Compound ID (CID)' of type number or string. The description adds no additional meaning beyond this, as it does not elaborate on parameter usage, constraints, or examples. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema adequately handles parameter semantics without extra description value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('all names and synonyms for a compound'), making the purpose specific and understandable. However, it does not explicitly distinguish this tool from sibling tools like 'get_compound_info' or 'search_compounds', which might also retrieve compound-related data, leaving some ambiguity in differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as sibling tools like 'get_compound_info' or 'search_by_smiles'. It lacks context on prerequisites, exclusions, or specific scenarios where retrieving synonyms is preferred over other compound data, offering minimal usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.