Skip to main content
Glama
Kartha-AI

MCP Server for Google Cloud Healthcare API

by Kartha-AI

search-pubmed

Search PubMed to retrieve medical literature based on specific queries, supporting healthcare workflows and clinical decision-making within MCP Server for Google Cloud Healthcare API.

Instructions

Search PubMed for medical literature

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxResultsNo
queryYes

Implementation Reference

  • Main handler function for executing the 'search-pubmed' tool. Parses arguments, uses caching, calls searchArticles, and formats response as MCP content.
    async getArticles(args: any, cache: CacheManager) {
      const { query, maxResults } = args;
      const cacheKey = cache.createKey('pubmed', { query, maxResults });
      
      const articles = await cache.getOrFetch(
        cacheKey,
        () => this.searchArticles(query, maxResults)
      );
    
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(articles, null, 2)
        }]
      };
    }
  • Helper function that performs the actual PubMed search using EUtils esearch.fcgi for IDs and esummary.fcgi for details, then maps to PubMedArticle format.
    async searchArticles(query: string, maxResults: number = 10): Promise<PubMedArticle[]> {
      // Search for article IDs
      const searchUrl = new URL(`${this.baseUrl}/esearch.fcgi`);
      searchUrl.searchParams.append('db', 'pubmed');
      searchUrl.searchParams.append('term', query);
      searchUrl.searchParams.append('retmax', maxResults.toString());
      searchUrl.searchParams.append('retmode', 'json');
      searchUrl.searchParams.append('api_key', this.apiKey);
    
      const searchResponse = await fetch(searchUrl);
      const searchData = await searchResponse.json() as PubMedSearchResponse;
      const pmids = searchData.esearchresult.idlist;
    
      if (!pmids.length) {
        return [];
      }
    
      // Get article details
      const summaryUrl = new URL(`${this.baseUrl}/esummary.fcgi`);
      summaryUrl.searchParams.append('db', 'pubmed');
      summaryUrl.searchParams.append('id', pmids.join(','));
      summaryUrl.searchParams.append('retmode', 'json');
      summaryUrl.searchParams.append('api_key', this.apiKey);
    
      const summaryResponse = await fetch(summaryUrl);
      const summaryData = await summaryResponse.json() as PubMedSummaryResponse;
    
      return pmids.map((pmid: string) => {
        const article = summaryData.result[pmid];
        return {
          title: article.title,
          authors: article.authors.map((a: any) => a.name),
          journal: article.fulljournalname,
          pubDate: article.pubdate,
          doi: article.elocationid,
          abstract: article.abstract,
          pmid: pmid
        };
      });
    }
  • Tool definition including name, description, and input schema for 'search-pubmed'.
    {
      name: 'search-pubmed',
      description: 'Search PubMed for medical literature',
      inputSchema: {
        type: 'object',
        properties: {
          query: { type: 'string' },
          maxResults: { type: 'number' }
        },
        required: ['query']
      }
    },
  • The handleList function that returns all tool definitions, including search-pubmed, to the MCP server.
    private handleList = async () => ({
      tools: TOOL_DEFINITIONS
    });
  • Switch case in handleCall that routes 'search-pubmed' tool calls to the PubMed API handler.
    case "search-pubmed":
      return await this.pubmedApi.getArticles(request.params.arguments,this.cache);

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Related Tools

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/Kartha-AI/google-cloud-healthcare-api-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server