Skip to main content
Glama
Augmented-Nature

Unofficial PubChem MCP Server

search_similar_compounds

Find chemically similar compounds from PubChem using Tanimoto similarity. Input a SMILES string to retrieve molecules matching your similarity threshold and quantity preferences.

Instructions

Find chemically similar compounds using Tanimoto similarity

Input Schema

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

Implementation Reference

  • The handler function that validates input using isValidSmilesArgs and performs a PubChem API POST request to /compound/similarity/smiles/JSON for Tanimoto similarity search based on SMILES, returning the JSON results.
    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 with validation constraints.
    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:442-453 (registration)
    Tool registration in the ListToolsRequestSchema response, defining 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'],
      },
    },
  • src/index.ts:754-755 (registration)
    Switch case in CallToolRequestSchema handler that routes calls to the specific handler function.
    case 'search_similar_compounds':
      return await this.handleSearchSimilarCompounds(args);
  • Validation helper function used by the handler to check input arguments match the schema.
    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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the similarity method but doesn't describe what happens when no matches are found, whether results are paginated, what format results take, or any performance characteristics. For a search tool with no annotation coverage, this leaves significant behavioral gaps.

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 communicates the core purpose without unnecessary words. It's appropriately sized and front-loaded with the essential information. Every word earns its place in this concise formulation.

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 search tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (compound IDs, structures, similarity scores), how results are ordered, or what happens at the threshold boundaries. Given the complexity of chemical similarity searching and the lack of structured output information, the description should provide more contextual guidance.

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 clear parameter documentation, so the description doesn't need to add parameter details. The description doesn't provide additional parameter semantics beyond what's in the schema, which is acceptable given the comprehensive schema coverage. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Find chemically similar compounds') and method ('using Tanimoto similarity'), distinguishing it from sibling tools like 'search_compounds' or 'substructure_search' which use different search approaches. It provides a precise verb+resource combination that immediately communicates the tool's function.

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 like 'search_compounds', 'substructure_search', or 'compare_activity_profiles'. While the mention of 'Tanimoto similarity' implies a specific similarity metric, there's no explicit comparison to other search methods or clarification of use cases where this approach is preferred.

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

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/Augmented-Nature-PubChem-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server