Skip to main content
Glama

get_article

Retrieve complete metadata for PubMed articles using PMID, including title, abstract, authors, journal details, publication date, DOI, and MeSH terms.

Instructions

Get full metadata for a specific PubMed article by PMID, including title, abstract, authors, journal, publication date, DOI, and MeSH terms.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pmidYesPubMed ID

Implementation Reference

  • Main handler function getArticle that executes the tool logic - fetches article XML from NCBI client, parses it using parseArticles utility, and returns the first article as JSON or an error message if not found.
    export async function getArticle(args: z.infer<typeof getArticleSchema>): Promise<string> {
      const xml = await client.efetch([args.pmid]);
      const articles = parseArticles(xml);
      if (articles.length === 0) {
        return JSON.stringify({ error: `No article found for PMID ${args.pmid}` });
      }
      return JSON.stringify(articles[0], null, 2);
    }
  • Zod schema definition for getArticleSchema - validates input requiring a pmid (PubMed ID) string parameter.
    export const getArticleSchema = z.object({
      pmid: z.string().describe("PubMed ID"),
    });
  • src/index.ts:34-41 (registration)
    MCP server tool registration for 'get_article' - registers the tool with its name, description, schema shape, and async handler that parses arguments and calls getArticle function.
    server.tool(
      "get_article",
      "Get full metadata for a specific PubMed article by PMID, including title, abstract, authors, journal, publication date, DOI, and MeSH terms.",
      getArticleSchema.shape,
      async (args) => ({
        content: [{ type: "text", text: await getArticle(getArticleSchema.parse(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/PetrefiedThunder/mcp-pubmed'

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