Skip to main content
Glama

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
NameRequiredDescriptionDefault
limitNoNumber of results to return (1-1000, default: 25)
similarityNoSimilarity threshold (0-1, default: 0.7)
smilesYesSMILES string of the query molecule

Implementation Reference

  • 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'], }, },
  • 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

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