search_similar_structures
Identify structurally similar chemicals in SureChEMBL by inputting a reference chemical ID and adjusting similarity thresholds. Retrieve relevant results for research or analysis.
Instructions
Find structurally similar chemicals using similarity search
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of results to return (1-100, default: 25) | |
| reference_id | Yes | Reference chemical ID for similarity search | |
| threshold | No | Similarity threshold (0.0-1.0, default: 0.7) |
Implementation Reference
- src/index.ts:1063-1118 (handler)Handler function implementing the tool logic: validates args, fetches reference chemical, constructs a mock similarity search response explaining API limitations and providing alternatives.private async handleSearchSimilarStructures(args: any) { if (!args || typeof args.reference_id !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid reference chemical ID'); } try { // Get the reference chemical first const refResponse = await this.apiClient.get(`/chemical/id/${args.reference_id}`); const refChemical = refResponse.data.data?.[0]; if (!refChemical) { throw new Error('Reference chemical not found'); } // Since SureChEMBL doesn't have direct similarity search, we'll provide a mock implementation // that explains the limitation and suggests alternatives const similarityResult = { reference_chemical: { id: args.reference_id, name: refChemical.name, smiles: refChemical.smiles, molecular_weight: refChemical.mol_weight }, search_parameters: { threshold: args.threshold || 0.7, limit: args.limit || 25 }, message: 'Direct similarity search not available in SureChEMBL API', suggestions: [ 'Use chemical name variations to find related compounds', 'Search by molecular weight ranges', 'Use external cheminformatics tools for similarity search', 'Try searching by chemical class or functional groups' ], alternative_searches: { by_name_fragments: `Try searching for fragments of "${refChemical.name}"`, by_molecular_weight: `Search for compounds with molecular weight around ${refChemical.mol_weight}`, by_chemical_class: 'Search for compounds in the same chemical class' } }; return { content: [ { type: 'text', text: JSON.stringify(similarityResult, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to search similar structures: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:513-521 (schema)JSON schema defining input parameters for the tool: reference_id (required), threshold, limit.inputSchema: { type: 'object', properties: { reference_id: { type: 'string', description: 'Reference chemical ID for similarity search' }, threshold: { type: 'number', description: 'Similarity threshold (0.0-1.0, default: 0.7)', minimum: 0.0, maximum: 1.0 }, limit: { type: 'number', description: 'Number of results to return (1-100, default: 25)', minimum: 1, maximum: 100 }, }, required: ['reference_id'], },
- src/index.ts:510-522 (registration)Tool registration in the setTools array, including name, description, and schema.{ name: 'search_similar_structures', description: 'Find structurally similar chemicals using similarity search', inputSchema: { type: 'object', properties: { reference_id: { type: 'string', description: 'Reference chemical ID for similarity search' }, threshold: { type: 'number', description: 'Similarity threshold (0.0-1.0, default: 0.7)', minimum: 0.0, maximum: 1.0 }, limit: { type: 'number', description: 'Number of results to return (1-100, default: 25)', minimum: 1, maximum: 100 }, }, required: ['reference_id'], }, },
- src/index.ts:574-575 (registration)Dispatch case in the CallToolRequestSchema handler that routes to the tool handler.case 'search_similar_structures': return await this.handleSearchSimilarStructures(args);