Skip to main content
Glama

advanced_search

Perform complex chemical and biological data queries on the ChEMBL MCP Server using multiple filters like molecular weight, LogP, hydrogen bond donors, and acceptors to retrieve precise results.

Instructions

Complex queries with multiple chemical and biological filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of results to return (1-1000, default: 25)
max_hbaNoMaximum hydrogen bond acceptors
max_hbdNoMaximum hydrogen bond donors
max_logpNoMaximum LogP value
max_mwNoMaximum molecular weight (Da)
min_logpNoMinimum LogP value
min_mwNoMinimum molecular weight (Da)

Implementation Reference

  • The handler function that executes the 'advanced_search' tool. It validates input using isValidPropertyFilterArgs, builds a filter query for ChEMBL API based on molecular properties (MW, logP, HBD, HBA), fetches matching molecules, and returns the filtered results.
    private async handleAdvancedSearch(args: any) { if (!isValidPropertyFilterArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid advanced search arguments'); } try { // Build filter query for ChEMBL API const filters: string[] = []; if (args.min_mw !== undefined) { filters.push(`molecule_properties__mw_freebase__gte=${args.min_mw}`); } if (args.max_mw !== undefined) { filters.push(`molecule_properties__mw_freebase__lte=${args.max_mw}`); } if (args.min_logp !== undefined) { filters.push(`molecule_properties__alogp__gte=${args.min_logp}`); } if (args.max_logp !== undefined) { filters.push(`molecule_properties__alogp__lte=${args.max_logp}`); } if (args.max_hbd !== undefined) { filters.push(`molecule_properties__hbd__lte=${args.max_hbd}`); } if (args.max_hba !== undefined) { filters.push(`molecule_properties__hba__lte=${args.max_hba}`); } const filterString = filters.join('&'); const response = await this.apiClient.get(`/molecule.json?${filterString}&limit=${args.limit || 25}`); return { content: [ { type: 'text', text: JSON.stringify({ filters: args, results: response.data, }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to perform advanced search: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
  • The tool definition in the ListTools response, including name, description, and inputSchema defining the parameters for property-based filtering.
    name: 'advanced_search', description: 'Complex queries with multiple chemical and biological filters', inputSchema: { type: 'object', properties: { min_mw: { type: 'number', description: 'Minimum molecular weight (Da)', minimum: 0 }, max_mw: { type: 'number', description: 'Maximum molecular weight (Da)', minimum: 0 }, min_logp: { type: 'number', description: 'Minimum LogP value' }, max_logp: { type: 'number', description: 'Maximum LogP value' }, max_hbd: { type: 'number', description: 'Maximum hydrogen bond donors', minimum: 0 }, max_hba: { type: 'number', description: 'Maximum hydrogen bond acceptors', minimum: 0 }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: [], }, },
  • src/index.ts:802-803 (registration)
    The switch case in the CallToolRequestSchema handler that routes calls to the 'advanced_search' tool to its handler function.
    case 'advanced_search': return await this.handleAdvancedSearch(args);
  • Type guard function used by the handler to validate input arguments for the 'advanced_search' tool, checking types and ranges for property filters.
    const isValidPropertyFilterArgs = ( args: any ): args is { min_mw?: number; max_mw?: number; min_logp?: number; max_logp?: number; max_hbd?: number; max_hba?: number; limit?: number } => { return ( typeof args === 'object' && args !== null && (args.min_mw === undefined || (typeof args.min_mw === 'number' && args.min_mw >= 0)) && (args.max_mw === undefined || (typeof args.max_mw === 'number' && args.max_mw >= 0)) && (args.min_logp === undefined || typeof args.min_logp === 'number') && (args.max_logp === undefined || typeof args.max_logp === 'number') && (args.max_hbd === undefined || (typeof args.max_hbd === 'number' && args.max_hbd >= 0)) && (args.max_hba === undefined || (typeof args.max_hba === 'number' && args.max_hba >= 0)) && (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