Skip to main content
Glama
Augmented-Nature

ChEMBL MCP Server

advanced_search

Search ChEMBL chemical compounds using multiple filters like molecular weight, LogP, and hydrogen bond properties to find specific molecules.

Instructions

Complex queries with multiple chemical and biological filters

Input Schema

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

Implementation Reference

  • The main handler function for the 'advanced_search' tool. It validates input arguments using isValidPropertyFilterArgs, constructs a filter query for molecular properties (MW, LogP, HBD, HBA), queries the ChEMBL molecule endpoint, 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'}`
        );
      }
    }
  • src/index.ts:720-735 (registration)
    Registration of the 'advanced_search' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.
      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)
    Dispatch registration in the CallToolRequestSchema switch statement, routing calls to the handleAdvancedSearch handler.
    case 'advanced_search':
      return await this.handleAdvancedSearch(args);
  • Type guard and validation function for 'advanced_search' input parameters, ensuring proper types and ranges for molecular 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))
      );
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states it performs 'complex queries' without detailing behavioral traits. It doesn't mention whether this is a read-only operation, potential performance impacts, rate limits, authentication needs, or what happens with no results. For a tool with 7 parameters and no annotation coverage, this is a significant gap in disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads key information ('complex queries with multiple chemical and biological filters'). It wastes no words, though it could be slightly more structured by specifying the resource being queried. Every word earns its place in conveying the tool's general purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (7 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what the tool searches (compounds? drugs?), what it returns, or behavioral aspects like error handling. For a tool named 'advanced_search' among many search siblings, more context is needed to guide proper use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with all parameters well-documented in the input schema (e.g., molecular weight, LogP, hydrogen bond properties). The description adds no additional parameter meaning beyond stating 'multiple chemical and biological filters', which is already evident from the schema. Baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Complex queries with multiple chemical and biological filters' indicates a search function with specific filter types, but it's vague about what resource is being searched (compounds, drugs, targets?) and doesn't clearly distinguish from siblings like 'search_compounds' or 'search_targets'. It provides a general category but lacks specificity about the exact operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives is provided. The description mentions 'complex queries with multiple filters' but doesn't specify scenarios where this is preferred over simpler search tools like 'search_compounds' or how it differs from other filter-based tools like 'search_by_activity_type'. Usage context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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