Skip to main content
Glama
Augmented-Nature

Unofficial PubChem MCP Server

batch_compound_lookup

Retrieve chemical properties, synonyms, classifications, or descriptions for multiple PubChem compounds simultaneously. Process up to 200 compound IDs in a single query to save time on chemical research.

Instructions

Process multiple compound IDs efficiently

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidsYesArray of PubChem CIDs (1-200)
operationNoOperation to perform (default: property)

Implementation Reference

  • The core execution logic for the batch_compound_lookup tool. Validates input using isValidBatchArgs, processes up to 10 CIDs by fetching MolecularWeight, CanonicalSMILES, IUPACName from PubChem API, collects results with success/error status, and returns JSON-formatted batch results.
    private async handleBatchCompoundLookup(args: any) {
      if (!isValidBatchArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid batch arguments');
      }
    
      try {
        const results = [];
        for (const cid of args.cids.slice(0, 10)) {
          try {
            const response = await this.apiClient.get(`/compound/cid/${cid}/property/MolecularWeight,CanonicalSMILES,IUPACName/JSON`);
            results.push({ cid, data: response.data, success: true });
          } catch (error) {
            results.push({ cid, error: error instanceof Error ? error.message : 'Unknown error', success: false });
          }
        }
    
        return { content: [{ type: 'text', text: JSON.stringify({ batch_results: results }, null, 2) }] };
      } catch (error) {
        throw new McpError(ErrorCode.InternalError, `Batch lookup failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • src/index.ts:719-730 (registration)
    Registration of the batch_compound_lookup tool in the ListTools response, including name, description, and full input schema definition.
    {
      name: 'batch_compound_lookup',
      description: 'Process multiple compound IDs efficiently',
      inputSchema: {
        type: 'object',
        properties: {
          cids: { type: 'array', items: { type: 'number' }, description: 'Array of PubChem CIDs (1-200)', minItems: 1, maxItems: 200 },
          operation: { type: 'string', enum: ['property', 'synonyms', 'classification', 'description'], description: 'Operation to perform (default: property)' },
        },
        required: ['cids'],
      },
    },
  • JSON schema defining the input parameters for batch_compound_lookup: required array of CIDs (1-200 numbers), optional operation enum.
    inputSchema: {
      type: 'object',
      properties: {
        cids: { type: 'array', items: { type: 'number' }, description: 'Array of PubChem CIDs (1-200)', minItems: 1, maxItems: 200 },
        operation: { type: 'string', enum: ['property', 'synonyms', 'classification', 'description'], description: 'Operation to perform (default: property)' },
      },
      required: ['cids'],
  • Type guard and validation helper function for batch_compound_lookup arguments, checking cids array validity and operation enum.
    const isValidBatchArgs = (
      args: any
    ): args is { cids: number[]; operation?: string } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        Array.isArray(args.cids) &&
        args.cids.length > 0 &&
        args.cids.length <= 200 &&
        args.cids.every((cid: any) => typeof cid === 'number' && cid > 0) &&
        (args.operation === undefined || ['property', 'synonyms', 'classification', 'description'].includes(args.operation))
      );
    };
  • src/index.ts:808-809 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement, routing calls to the handleBatchCompoundLookup method.
    case 'batch_compound_lookup':
      return await this.handleBatchCompoundLookup(args);

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?

No annotations are provided, so the description carries full burden. It mentions 'efficiently' which hints at batch optimization, but doesn't disclose critical behavioral traits like rate limits, error handling for invalid CIDs, whether operations are atomic, response format, or performance characteristics. For a batch tool with no annotation coverage, this is inadequate.

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 with zero waste. It's appropriately sized for a tool with good schema documentation and gets straight to the point about batch processing compound IDs.

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?

Given no annotations and no output schema, the description is incomplete for a batch processing tool. It doesn't explain what 'process' means operationally, what results to expect, error conditions, or how this differs from single-compound siblings. For a tool with 2 parameters and multiple operation types, more context is needed.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain what the 'operation' enum values mean in practice or provide examples of CID arrays). Baseline 3 is appropriate when schema does the heavy lifting.

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 'Process multiple compound IDs efficiently' clearly states the verb ('process') and resource ('multiple compound IDs'), and the 'efficiently' hint suggests batch processing. However, it doesn't explicitly distinguish this batch operation from sibling tools like 'get_compound_info' or 'get_compound_properties' that might handle single compounds.

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. With siblings like 'get_compound_info', 'get_compound_properties', and 'get_compound_synonyms', there's no indication whether this tool is preferred for bulk operations or how it relates to those single-compound tools.

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