search_similar_structures
Find chemically similar compounds in patent databases by comparing molecular structures to a reference chemical, enabling discovery of related substances and prior art.
Instructions
Find structurally similar chemicals using similarity search
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| reference_id | Yes | Reference chemical ID for similarity search | |
| threshold | No | Similarity threshold (0.0-1.0, default: 0.7) | |
| limit | No | Number of results to return (1-100, default: 25) |
Implementation Reference
- src/index.ts:1063-1118 (handler)The handler function executing the tool logic. It fetches the reference chemical and returns a mock similarity search result with suggestions since direct similarity search is not supported.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)Input schema defining parameters for the search_similar_structures tool.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 object including name, description, and schema in the tools array.{ 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)Switch case in the request handler dispatching to the tool handler.case 'search_similar_structures': return await this.handleSearchSimilarStructures(args);