Skip to main content
Glama

search_similar_compounds

Find chemically similar compounds to a query molecule using Tanimoto similarity, with configurable thresholds and result limits.

Instructions

Find chemically similar compounds using Tanimoto similarity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
smilesYesSMILES string of the query molecule
similarityNoSimilarity threshold (0-1, default: 0.7)
limitNoNumber of results to return (1-1000, default: 25)

Implementation Reference

  • The main handler function that implements the 'search_similar_compounds' tool logic. It validates input, calls the ChEMBL similarity search API using the provided SMILES and similarity threshold, and returns the results.
    private async handleSearchSimilarCompounds(args: any) { if (!isValidSimilaritySearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid similarity search arguments'); } try { // ChEMBL similarity search using SMILES const similarity = args.similarity !== undefined ? Math.round(args.similarity * 100) : 70; const response = await this.apiClient.get('/similarity/' + encodeURIComponent(args.smiles) + '/' + similarity + '.json', { params: { limit: args.limit || 25, }, }); 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'}` ); } }
  • The input schema definition for the 'search_similar_compounds' tool, registered in the ListTools handler. Defines parameters: smiles (required), similarity, limit.
    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' }, similarity: { type: 'number', description: 'Similarity threshold (0-1, default: 0.7)', minimum: 0, maximum: 1 }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['smiles'], }, },
  • src/index.ts:753-754 (registration)
    The switch case in the CallToolRequestSchema handler that dispatches calls to the search_similar_compounds tool to its handler function.
    case 'search_similar_compounds': return await this.handleSearchSimilarCompounds(args);
  • Type guard and validation function for the input arguments of the search_similar_compounds tool.
    const isValidSimilaritySearchArgs = ( args: any ): args is { smiles: string; similarity?: number; limit?: number } => { return ( typeof args === 'object' && args !== null && typeof args.smiles === 'string' && args.smiles.length > 0 && (args.similarity === undefined || (typeof args.similarity === 'number' && args.similarity >= 0 && args.similarity <= 1)) && (args.limit === undefined || (typeof args.limit === 'number' && args.limit > 0 && args.limit <= 1000)) ); };

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/ChEMBL-MCP-Server'

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