get_target_compounds
Retrieve compounds tested against a specific biological target from ChEMBL database, filtering by activity type and limiting results.
Instructions
Get compounds tested against a specific target
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_chembl_id | Yes | ChEMBL target ID | |
| activity_type | No | Activity type filter (e.g., IC50, Ki, Kd) | |
| limit | No | Number of results to return (1-1000, default: 25) |
Implementation Reference
- src/index.ts:990-1031 (handler)Implements the core logic for the 'get_target_compounds' tool. Queries the ChEMBL API /activity endpoint with target_chembl_id filter, processes activities to extract unique molecule_chembl_ids, and returns a summary with compound counts and samples.private async handleGetTargetCompounds(args: any) { if (!args || typeof args.target_chembl_id !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid target compounds arguments'); } try { const params: any = { target_chembl_id: args.target_chembl_id, limit: args.limit || 25, }; if (args.activity_type) { params.standard_type = args.activity_type; } const response = await this.apiClient.get('/activity.json', { params }); // Extract unique compounds from activities const activities = response.data.activities || []; const compoundIds = [...new Set(activities.map((a: any) => a.molecule_chembl_id))]; return { content: [ { type: 'text', text: JSON.stringify({ target_chembl_id: args.target_chembl_id, total_activities: activities.length, unique_compounds: compoundIds.length, compound_ids: compoundIds.slice(0, 100), activities: activities.slice(0, 50), }, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get target compounds: ${error instanceof Error ? error.message : 'Unknown error'}` ); } }
- src/index.ts:484-495 (registration)Registers the 'get_target_compounds' tool in the ListToolsRequestSchema response, defining its name, description, and input schema.name: 'get_target_compounds', description: 'Get compounds tested against a specific target', inputSchema: { type: 'object', properties: { target_chembl_id: { type: 'string', description: 'ChEMBL target ID' }, activity_type: { type: 'string', description: 'Activity type filter (e.g., IC50, Ki, Kd)' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['target_chembl_id'], }, },
- src/index.ts:760-761 (registration)Dispatches calls to the 'get_target_compounds' tool to its handler function in the CallToolRequestSchema switch statement.case 'get_target_compounds': return await this.handleGetTargetCompounds(args);
- src/index.ts:486-494 (schema)Defines the input schema (JSON Schema) for validating parameters to the 'get_target_compounds' tool: requires target_chembl_id, optional activity_type and limit.inputSchema: { type: 'object', properties: { target_chembl_id: { type: 'string', description: 'ChEMBL target ID' }, activity_type: { type: 'string', description: 'Activity type filter (e.g., IC50, Ki, Kd)' }, limit: { type: 'number', description: 'Number of results to return (1-1000, default: 25)', minimum: 1, maximum: 1000 }, }, required: ['target_chembl_id'], },