Skip to main content
Glama
Augmented-Nature

Unofficial PubChem MCP Server

get_compound_info

Retrieve detailed chemical compound data from PubChem using the Compound ID, including molecular properties and bioassay information in multiple output formats.

Instructions

Get detailed information for a specific compound by PubChem CID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesPubChem Compound ID (CID)
formatNoOutput format (default: json)

Implementation Reference

  • The core handler function for the 'get_compound_info' tool. Validates input using isValidCidArgs, fetches compound data from PubChem REST API by CID in specified format (default JSON), and returns the response as text content.
    private async handleGetCompoundInfo(args: any) {
      if (!isValidCidArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid CID arguments');
      }
    
      try {
        const format = args.format || 'json';
        const response = await this.apiClient.get(`/compound/cid/${args.cid}/${format === 'json' ? 'JSON' : format}`);
    
        return {
          content: [
            {
              type: 'text',
              text: format === 'json' ? JSON.stringify(response.data, null, 2) : String(response.data),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to get compound info: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • Tool definition in ListTools response, including name, description, and input schema for validation (cid required, format optional).
    {
      name: 'get_compound_info',
      description: 'Get detailed information for a specific compound by PubChem CID',
      inputSchema: {
        type: 'object',
        properties: {
          cid: { type: ['number', 'string'], description: 'PubChem Compound ID (CID)' },
          format: { type: 'string', enum: ['json', 'sdf', 'xml', 'asnt', 'asnb'], description: 'Output format (default: json)' },
        },
        required: ['cid'],
      },
    },
  • src/index.ts:742-743 (registration)
    Switch case in CallToolRequest handler that routes 'get_compound_info' tool calls to the handleGetCompoundInfo method.
    case 'get_compound_info':
      return await this.handleGetCompoundInfo(args);
  • Type guard function validating input arguments for get_compound_info tool, matching the input schema.
      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

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but provides minimal information. It doesn't indicate whether this is a read-only operation, what kind of authentication might be required, potential rate limits, error conditions, or what 'detailed information' actually includes. The description is functional but lacks important behavioral context.

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 gets straight to the point with zero wasted words. It's appropriately sized for a straightforward lookup tool and front-loads the essential information without unnecessary elaboration.

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

Completeness2/5

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

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what 'detailed information' includes, what format the output takes, or provide any context about the scope or limitations of the information returned. Given the complexity implied by the sibling tools (which handle specific aspects like properties, bioactivities, safety data), this description should clarify what comprehensive information it provides.

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?

With 100% schema description coverage, the schema already documents both parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it mentions 'PubChem CID' which the schema already covers, and doesn't elaborate on format choices or provide examples. This meets the baseline for high schema coverage.

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 action ('Get detailed information') and target resource ('specific compound by PubChem CID'), which distinguishes it from siblings like get_compound_properties or get_compound_synonyms that retrieve specific subsets of information. However, it doesn't explicitly differentiate from batch_compound_lookup or search_compounds, which could also retrieve compound information through different mechanisms.

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. It doesn't mention when to prefer this over batch_compound_lookup for single compounds, or when to use get_compound_properties versus this more comprehensive information retrieval. There's no context about prerequisites or typical use cases.

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