Skip to main content
Glama
Augmented-Nature

PubChem MCP Server

search_similar_compounds

Find chemically similar compounds in PubChem using Tanimoto similarity. Input a SMILES string, set a similarity threshold, and retrieve relevant results for chemical analysis.

Instructions

Find chemically similar compounds using Tanimoto similarity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_recordsNoMaximum number of results (1-10000, default: 100)
smilesYesSMILES string of the query molecule
thresholdNoSimilarity threshold (0-100, default: 90)

Implementation Reference

  • The main handler function that validates input using isValidSmilesArgs, performs POST request to PubChem similarity endpoint with SMILES, threshold, and maxRecords, and returns the JSON response.
    private async handleSearchSimilarCompounds(args: any) {
      if (!isValidSmilesArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Invalid similarity search arguments');
      }
    
      try {
        const threshold = args.threshold || 90;
        const maxRecords = args.max_records || 100;
    
        const response = await this.apiClient.post('/compound/similarity/smiles/JSON', {
          smiles: args.smiles,
          Threshold: threshold,
          MaxRecords: maxRecords,
        });
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to search similar compounds: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • Input schema definition for the search_similar_compounds tool, specifying required SMILES and optional threshold/max_records parameters.
    inputSchema: {
      type: 'object',
      properties: {
        smiles: { type: 'string', description: 'SMILES string of the query molecule' },
        threshold: { type: 'number', description: 'Similarity threshold (0-100, default: 90)', minimum: 0, maximum: 100 },
        max_records: { type: 'number', description: 'Maximum number of results (1-10000, default: 100)', minimum: 1, maximum: 10000 },
      },
      required: ['smiles'],
    },
  • src/index.ts:754-755 (registration)
    Switch case in the main CallToolRequestSchema handler that routes calls to search_similar_compounds to the specific handler function.
    case 'search_similar_compounds':
      return await this.handleSearchSimilarCompounds(args);
  • src/index.ts:441-453 (registration)
    Tool registration in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: 'search_similar_compounds',
      description: 'Find chemically similar compounds using Tanimoto similarity',
      inputSchema: {
        type: 'object',
        properties: {
          smiles: { type: 'string', description: 'SMILES string of the query molecule' },
          threshold: { type: 'number', description: 'Similarity threshold (0-100, default: 90)', minimum: 0, maximum: 100 },
          max_records: { type: 'number', description: 'Maximum number of results (1-10000, default: 100)', minimum: 1, maximum: 10000 },
        },
        required: ['smiles'],
      },
    },
  • Type guard function used to validate inputs for SMILES-based searches, including similarity search.
    const isValidSmilesArgs = (
      args: any
    ): args is { smiles: string; threshold?: number; max_records?: number } => {
      return (
        typeof args === 'object' &&
        args !== null &&
        typeof args.smiles === 'string' &&
        args.smiles.length > 0 &&
        (args.threshold === undefined || (typeof args.threshold === 'number' && args.threshold >= 0 && args.threshold <= 100)) &&
        (args.max_records === undefined || (typeof args.max_records === 'number' && args.max_records > 0 && args.max_records <= 10000))
      );
    };
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 mentions the similarity method ('Tanimoto similarity') but doesn't describe key behavioral traits: what the output looks like (e.g., list of compounds with scores), whether it's a read-only operation (implied but not stated), performance characteristics (e.g., speed, limitations), or error handling. For a search tool with no annotation coverage, this is a significant gap in transparency.

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: 'Find chemically similar compounds using Tanimoto similarity.' It is front-loaded with the core purpose, has zero wasted words, and appropriately sized for the tool's complexity. Every part of the sentence earns its place by specifying the action, resource, and method.

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 the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is incomplete. It lacks information on output format (critical for a search tool), behavioral context (e.g., read-only nature, performance), and usage guidelines relative to siblings. Without an output schema, the description should ideally hint at return values, but it doesn't, leaving the agent with insufficient context for effective use.

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%, with all parameters well-documented in the schema (e.g., 'smiles' as 'SMILES string of the query molecule'). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain parameter interactions, default behaviors beyond defaults listed, or usage nuances. Thus, it meets the baseline score of 3, as the 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 clearly states the tool's purpose: 'Find chemically similar compounds using Tanimoto similarity.' It specifies the action ('Find'), resource ('chemically similar compounds'), and method ('Tanimoto similarity'), which distinguishes it from siblings like 'search_compounds' or 'substructure_search' that likely use different search methods. However, it doesn't explicitly differentiate from all siblings (e.g., 'search_by_smiles' might also use SMILES input), keeping it from a perfect score.

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 choose this over siblings like 'search_compounds' (which might be a general search) or 'substructure_search' (which uses structural matching), nor does it specify prerequisites or exclusions. This lack of contextual direction leaves the agent to infer usage from the tool name and parameters alone.

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