Skip to main content
Glama

get_external_references

Retrieve external database links (e.g., PubChem, DrugBank, PDB) by inputting a ChEMBL compound or target ID to enhance data accessibility and integration.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chembl_idYesChEMBL compound or target ID

Implementation Reference

  • Main handler function implementing the tool logic: validates input, fetches ChEMBL molecule or target data, extracts and organizes cross-references into databases with generated URLs.
    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'}` ); }
  • src/index.ts:708-718 (registration)
    Tool registration entry in ListTools response, including 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'], }, },
  • Helper function used by the handler to generate direct URLs for external database identifiers.
    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/`; }
  • Input validation type guard used by the handler to validate the chembl_id argument.
    const isValidChemblIdArgs = ( args: any ): args is { chembl_id: string } => { return ( typeof args === 'object' && args !== null && typeof args.chembl_id === 'string' && args.chembl_id.length > 0 ); };
  • src/index.ts:800-801 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes to the tool implementation.
    case 'get_external_references': return await this.handleGetExternalReferences(args);

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