Skip to main content
Glama

search_compounds

Search the ChEMBL database to find compounds by name, synonym, or identifier, with options to limit and offset results for precise querying.

Instructions

Search ChEMBL database for compounds by name, synonym, or identifier

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of results to return (1-1000, default: 25)
offsetNoNumber of results to skip (default: 0)
queryYesSearch query (compound name, synonym, or identifier)

Implementation Reference

  • The handler function that executes the 'search_compounds' tool. Validates input arguments and queries the ChEMBL API's molecule/search endpoint with the provided query, limit, and offset parameters, returning the JSON response.
    private async handleSearchCompounds(args: any) { if (!isValidCompoundSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid compound search arguments'); } try { const response = await this.apiClient.get('/molecule/search.json', { params: { q: args.query, limit: args.limit || 25, offset: args.offset || 0, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to search compounds: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
  • src/index.ts:745-746 (registration)
    Registration of the tool handler in the CallToolRequestSchema switch statement, dispatching calls to search_compounds to the appropriate handler method.
    case 'search_compounds': return await this.handleSearchCompounds(args);
  • Input schema definition for the 'search_compounds' tool, specifying the expected parameters: query (required string), optional limit (number 1-1000), and offset (number >=0).
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (compound name, synonym, or identifier)' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, offset: { type: 'number', description: 'Number of results to skip (default: 0)', minimum: 0 }, }, required: ['query'], },
  • src/index.ts:397-408 (registration)
    Tool registration in the ListToolsRequestSchema response, defining the name, description, and input schema for 'search_compounds'.
    name: 'search_compounds', description: 'Search ChEMBL database for compounds by name, synonym, or identifier', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (compound name, synonym, or identifier)' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, offset: { type: 'number', description: 'Number of results to skip (default: 0)', minimum: 0 }, }, required: ['query'], }, },
  • Helper function for input validation specific to search_compounds arguments, checking query is non-empty string, limit between 1-1000, offset >=0.
    const isValidCompoundSearchArgs = ( args: any ): args is { query: string; limit?: number; offset?: number } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.limit === undefined || (typeof args.limit === 'number' && args.limit > 0 && args.limit <= 1000)) && (args.offset === undefined || (typeof args.offset === 'number' && args.offset >= 0)) ); };

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