Skip to main content
Glama

get_external_references

Retrieve external database links for ChEMBL compounds or targets, connecting to PubChem, DrugBank, PDB, and other resources.

Instructions

Get links to external databases (PubChem, DrugBank, PDB, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chembl_idYesChEMBL compound or target ID

Implementation Reference

  • The handler function that executes the tool logic: validates input, fetches ChEMBL entity data (molecule or target), extracts cross_references, groups them by database source, generates URLs using helper, and returns formatted JSON.
    private async handleGetExternalReferences(args: any) { if (!isValidChemblIdArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid external references arguments'); } try { // Try to get molecule data first let response; let entityType = 'molecule'; try { response = await this.apiClient.get(`/molecule/${args.chembl_id}.json`); } catch (e) { // If not a molecule, try target try { response = await this.apiClient.get(`/target/${args.chembl_id}.json`); entityType = 'target'; } catch (e2) { throw new McpError(ErrorCode.InvalidParams, 'ChEMBL ID not found as molecule or target'); } } const entity = response.data; const crossRefs = entity.cross_references || []; // Organize external references by database const externalReferences = { chembl_id: args.chembl_id, entity_type: entityType, databases: {} as any, }; // Group references by source crossRefs.forEach((ref: any) => { const source = ref.xref_src || ref.xref_name; if (!externalReferences.databases[source]) { externalReferences.databases[source] = []; } externalReferences.databases[source].push({ id: ref.xref_id, name: ref.xref_name, url: this.getExternalUrl(source, ref.xref_id), }); }); return { content: [ { type: 'text', text: JSON.stringify(externalReferences, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to get external references: ${error instanceof Error ? error.message : 'Unknown error'}` ); }
  • Input schema definition for the tool, specifying required chembl_id parameter.
    inputSchema: { type: 'object', properties: { chembl_id: { type: 'string', description: 'ChEMBL compound or target ID' }, }, required: ['chembl_id'], },
  • src/index.ts:708-718 (registration)
    Tool registration in the listTools response, defining name, description, and input schema.
    { name: 'get_external_references', description: 'Get links to external databases (PubChem, DrugBank, PDB, etc.)', inputSchema: { type: 'object', properties: { chembl_id: { type: 'string', description: 'ChEMBL compound or target ID' }, }, required: ['chembl_id'], }, },
  • src/index.ts:800-801 (registration)
    Dispatch registration in the CallToolRequestSchema handler switch statement.
    case 'get_external_references': return await this.handleGetExternalReferences(args);
  • Helper utility to map external database sources to their corresponding URLs.
    private getExternalUrl(source: string, id: string): string { const urlMap: { [key: string]: string } = { 'PubChem': `https://pubchem.ncbi.nlm.nih.gov/compound/${id}`, 'DrugBank': `https://www.drugbank.ca/drugs/${id}`, 'PDB': `https://www.rcsb.org/structure/${id}`, 'UniProt': `https://www.uniprot.org/uniprot/${id}`, 'Wikipedia': `https://en.wikipedia.org/wiki/${id}`, 'KEGG': `https://www.genome.jp/entry/${id}`, 'Reactome': `https://reactome.org/content/detail/${id}`, }; return urlMap[source] || `https://www.ebi.ac.uk/chembl/`; }

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