Skip to main content
Glama
Augmented-Nature

PubChem MCP Server

get_compound_synonyms

Retrieve all names and synonyms for a chemical compound by providing its PubChem Compound ID (CID). Enhances search and identification in chemical 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 input CID, calls the PubChem API to retrieve synonyms, 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'}`
        );
      }
    }
  • Input schema definition for the tool, specifying that 'cid' is required as a number or string.
    inputSchema: {
      type: 'object',
      properties: {
        cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' },
      },
      required: ['cid'],
    },
  • src/index.ts:428-438 (registration)
    Tool registration in the tools list provided to MCP server.setRequestHandler(ListToolsRequestSchema), including name, description, and 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)
    Dispatcher case in the CallToolRequestSchema handler that routes calls to the specific handler function.
    case 'get_compound_synonyms':
      return await this.handleGetCompoundSynonyms(args);
  • Type guard function used for input validation in the handler, checking for valid 'cid' (number or string). Note: format check is extra but harmless.
    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))
      );
    };
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.

Install Server

Other Tools

Related Tools

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