search_similar_compounds
Identify chemically similar compounds by entering a SMILES string, setting a similarity threshold, and specifying result limits on the ChEMBL MCP Server.
Instructions
Find chemically similar compounds using Tanimoto similarity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of results to return (1-1000, default: 25) | |
| similarity | No | Similarity threshold (0-1, default: 0.7) | |
| smiles | Yes | SMILES string of the query molecule |
Implementation Reference
- src/index.ts:935-963 (handler)The handler function that executes the 'search_similar_compounds' tool. It validates input using isValidSimilaritySearchArgs, calls the ChEMBL similarity search API with the provided SMILES and similarity threshold (converted to percentage), and returns the JSON response.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'}` ); } }
- src/index.ts:445-456 (registration)Tool registration in the ListTools response, including name, description, and input schema definition.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:101-112 (schema)Input validation type guard function matching the tool's input schema, used in the handler.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)) ); };
- src/index.ts:754-755 (registration)Dispatch case in the CallToolRequestSchema handler that routes to the tool implementation.return await this.handleSearchSimilarCompounds(args); // Target Analysis & Drug Discovery