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
| Name | Required | Description | Default |
|---|---|---|---|
| pmid | Yes | PubMed ID |
Implementation Reference
- src/tools.ts:71-78 (handler)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); } - src/tools.ts:17-19 (schema)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)) }], }) );