search-medical-databases
Search across PubMed, Google Scholar, Cochrane, and ClinicalTrials.gov to find comprehensive medical research and clinical trial information for any medical topic or condition.
Instructions
Search across multiple medical databases (PubMed, Google Scholar, Cochrane, ClinicalTrials.gov) for comprehensive results
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Medical topic or condition to search for across multiple databases |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"description": "Medical topic or condition to search for across multiple databases",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/utils.ts:1010-1067 (handler)Core implementation of the tool handler: performs parallel searches across PubMed, Google Scholar, Cochrane Library, and ClinicalTrials.gov, processes results, removes duplicates, and limits to 20 results.export async function searchMedicalDatabases( query: string, ): Promise<GoogleScholarArticle[]> { console.log(`š Searching medical databases for: ${query}`); // Try multiple medical databases in parallel const searches = await Promise.allSettled([ searchPubMedArticles(query, 5), searchGoogleScholar(query), searchCochraneLibrary(query), searchClinicalTrials(query), ]); const results: GoogleScholarArticle[] = []; // Process PubMed results if (searches[0].status === "fulfilled" && searches[0].value) { searches[0].value.forEach((article) => { results.push({ title: article.title, authors: article.authors.join(", "), abstract: article.abstract, journal: article.journal, year: article.publication_date.split("-")[0], citations: "", url: `https://pubmed.ncbi.nlm.nih.gov/${article.pmid}/`, }); }); } // Process Google Scholar results if (searches[1].status === "fulfilled" && searches[1].value) { results.push(...searches[1].value); } // Process Cochrane Library results if (searches[2].status === "fulfilled" && searches[2].value) { results.push(...searches[2].value); } // Process Clinical Trials results if (searches[3].status === "fulfilled" && searches[3].value) { results.push(...searches[3].value); } // Remove duplicates based on title similarity const uniqueResults = results.filter( (article, index, self) => index === self.findIndex( (a) => a.title.toLowerCase().replace(/[^\w\s]/g, "") === article.title.toLowerCase().replace(/[^\w\s]/g, ""), ), ); return uniqueResults.slice(0, 20); // Limit to 20 results }
- src/index.ts:233-251 (registration)Registration of the 'search-medical-databases' tool with MCP server, including description, Zod input schema, and wrapper handler that calls the core implementation.server.tool( "search-medical-databases", "Search across multiple medical databases (PubMed, Google Scholar, Cochrane, ClinicalTrials.gov) for comprehensive results", { query: z .string() .describe( "Medical topic or condition to search for across multiple databases", ), }, async ({ query }) => { try { const articles = await searchMedicalDatabases(query); return formatMedicalDatabasesSearch(articles, query); } catch (error: any) { return createErrorResponse("searching medical databases", error); } }, );
- src/index.ts:237-242 (schema)Zod input schema for the tool: single string parameter 'query'.query: z .string() .describe( "Medical topic or condition to search for across multiple databases", ), },
- src/utils.ts:581-605 (helper)Helper function to format and enrich the search results with safety warnings and source information before returning as MCP response.export function formatMedicalDatabasesSearch(articles: any[], query: string) { if (articles.length === 0) { return createMCPResponse( `No medical articles found for "${query}" across any databases. This could be due to no results matching your query, database API rate limiting, or network connectivity issues.`, ); } let result = `**Comprehensive Medical Database Search: "${query}"**\n\n`; result += `Found ${articles.length} article(s) across multiple databases\n\n`; articles.forEach((article, index) => { result += formatArticleItem(article, index); }); result += `\nšØ **CRITICAL SAFETY WARNING:**\n`; result += `This comprehensive search retrieves information from multiple medical databases dynamically.\n\n`; result += `**DYNAMIC DATA SOURCES:**\n`; result += `⢠PubMed (National Library of Medicine)\n`; result += `⢠Google Scholar (Academic search)\n`; result += `⢠Cochrane Library (Systematic reviews)\n`; result += `⢠ClinicalTrials.gov (Clinical trials)\n`; result = addDataNote(result); return createMCPResponse(result); }
- src/types.ts:59-90 (helper)Type definition used for the unified article format returned by the handler and helpers.export type GoogleScholarArticle = { title: string; authors?: string; abstract?: string; journal?: string; year?: string; citations?: string; url?: string; pdf_url?: string; related_articles?: string[]; }; export type ClinicalGuideline = { title: string; organization: string; year: string; url: string; description?: string; category?: string; evidence_level?: string; }; export type DrugInteraction = { drug1: string; drug2: string; severity: "Minor" | "Moderate" | "Major" | "Contraindicated"; description: string; clinical_effects: string; management: string; evidence_level: string; };