Skip to main content
Glama

search_articles

Search biomedical literature in PubMed using advanced queries with field tags, boolean operators, and date filters to find relevant research articles.

Instructions

Search PubMed for biomedical articles. Supports full PubMed query syntax including field tags ([Title], [Author], [MeSH]), boolean operators (AND, OR, NOT), and date ranges.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPubMed search query (supports full PubMed syntax including [Title], [Author], [MeSH], date ranges, boolean operators)
max_resultsNoMaximum results to return (1-100)
sortNoSort orderrelevance
min_dateNoMinimum publication date (YYYY or YYYY/MM or YYYY/MM/DD)
max_dateNoMaximum publication date (YYYY or YYYY/MM or YYYY/MM/DD)

Implementation Reference

  • The main implementation of searchArticles function that executes the PubMed search logic. It uses NCBI client to perform esearch and efetch operations, then parses and formats the results as JSON.
    export async function searchArticles(args: z.infer<typeof searchArticlesSchema>): Promise<string> {
      // Step 1: search
      const searchResult = await client.esearch(args.query, {
        retmax: args.max_results,
        sort: args.sort,
        mindate: args.min_date,
        maxdate: args.max_date,
        datetype: args.min_date || args.max_date ? "pdat" : undefined,
      }) as { esearchresult: { idlist: string[]; count: string; querytranslation: string } };
    
      const ids = searchResult.esearchresult.idlist;
      const totalCount = searchResult.esearchresult.count;
      const queryTranslation = searchResult.esearchresult.querytranslation;
    
      if (ids.length === 0) {
        return JSON.stringify({ total_count: 0, query_translation: queryTranslation, articles: [] }, null, 2);
      }
    
      // Step 2: fetch article details
      const xml = await client.efetch(ids);
      const articles = parseArticles(xml);
    
      return JSON.stringify({
        total_count: parseInt(totalCount),
        query_translation: queryTranslation,
        showing: articles.length,
        articles: articles.map(formatArticleSummary),
      }, null, 2);
    }
  • The Zod schema defining the input validation for search_articles tool. It specifies query (required), max_results (1-100, default 10), sort (enum), and optional min_date/max_date parameters.
    export const searchArticlesSchema = z.object({
      query: z.string().describe("PubMed search query (supports full PubMed syntax including [Title], [Author], [MeSH], date ranges, boolean operators)"),
      max_results: z.number().min(1).max(100).default(10).describe("Maximum results to return (1-100)"),
      sort: z.enum(["relevance", "pub_date", "Author", "JournalName"]).default("relevance").describe("Sort order"),
      min_date: z.string().optional().describe("Minimum publication date (YYYY or YYYY/MM or YYYY/MM/DD)"),
      max_date: z.string().optional().describe("Maximum publication date (YYYY or YYYY/MM or YYYY/MM/DD)"),
    });
  • src/index.ts:25-32 (registration)
    The MCP server tool registration for search_articles. This registers the tool with its name, description, schema shape, and the handler that executes when the tool is called.
    server.tool(
      "search_articles",
      "Search PubMed for biomedical articles. Supports full PubMed query syntax including field tags ([Title], [Author], [MeSH]), boolean operators (AND, OR, NOT), and date ranges.",
      searchArticlesSchema.shape,
      async (args) => ({
        content: [{ type: "text", text: await searchArticles(searchArticlesSchema.parse(args)) }],
      })
    );
  • Helper function used by searchArticles to format article metadata into a summary format, limiting author lists and truncating abstracts to 500 characters.
    function formatArticleSummary(a: ArticleMetadata) {
      return {
        pmid: a.pmid,
        title: a.title,
        authors: a.authors.slice(0, 5).join(", ") + (a.authors.length > 5 ? " et al." : ""),
        journal: a.journal,
        pub_date: a.pubDate,
        doi: a.doi || undefined,
        abstract: a.abstract.length > 500 ? a.abstract.slice(0, 500) + "..." : a.abstract,
      };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the search capabilities (query syntax, boolean operators, date ranges) but doesn't mention important behavioral aspects like rate limits, authentication requirements, pagination behavior, or what the response format looks like. It provides good functional context but lacks operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently communicates the core functionality. Every element (PubMed, biomedical articles, query syntax details) earns its place by providing essential information without redundancy. It's front-loaded with the main purpose and follows with supporting details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 5 parameters, 100% schema coverage, and no output schema, the description provides adequate functional context but lacks completeness. It doesn't describe what the search results look like (structure, fields returned), doesn't mention limitations or constraints beyond query syntax, and doesn't address error conditions or edge cases that would help an agent use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description mentions 'full PubMed query syntax including field tags ([Title], [Author], [MeSH]), boolean operators (AND, OR, NOT), and date ranges' which adds some context about the query parameter's capabilities, but doesn't provide additional meaning beyond what the schema already specifies for individual parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Search PubMed for biomedical articles') and resource ('PubMed'), distinguishing it from sibling tools like get_article (retrieve specific article) or search_mesh (search MeSH terms). It provides a precise verb+resource combination that immediately communicates the tool's function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through the mention of 'PubMed query syntax,' suggesting this is for complex searches. However, it doesn't explicitly state when to use this tool versus alternatives like get_article (for known IDs) or search_mesh (for terminology searches). The guidance is implied rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/PetrefiedThunder/mcp-pubmed'

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