UNPKG

@cyanheads/pubmed-mcp-server

Version:

Search PubMed/Europe PMC, fetch articles and full text (PMC/EPMC/Unpaywall), citations, MeSH terms via MCP. STDIO or Streamable HTTP.

98 lines 5.02 kB
/** * @fileoverview Helper functions for parsing detailed PubMed Article XML structures, * typically from EFetch results. * @module src/services/ncbi/parsing/article-parser */ import type { ParsedArticle, ParsedArticleAuthor, ParsedArticleDate, ParsedGrant, ParsedJournalInfo, ParsedMeshTerm, ParseFullArticleOptions, XmlArticle, XmlArticleIdList, XmlAuthorList, XmlGrantList, XmlJournal, XmlKeywordList, XmlMedlineCitation, XmlMeshHeadingList, XmlPublicationTypeList, XmlPubmedArticle } from '../types.js'; /** * Result of extracting authors with deduplicated affiliations. */ export interface ExtractedAuthors { affiliations: string[]; authors: ParsedArticleAuthor[]; } /** * Extracts and formats author information from XML, deduplicating affiliations. * Affiliations are collected into a single array; each author references them by index. * This avoids repeating identical institutional strings per-author (common in multi-center papers). * @param authorListXml - The XML AuthorList element. * @returns Authors and a deduplicated affiliations list. */ export declare function extractAuthors(authorListXml?: XmlAuthorList): ExtractedAuthors; /** * Extracts and formats journal information from XML. * @param journalXml - The XML Journal element from an Article. * @param articleXml - The XML Article element (for Pagination). * @returns Formatted journal information. */ export declare function extractJournalInfo(journalXml?: XmlJournal, articleXml?: XmlArticle): ParsedJournalInfo | undefined; /** * Extracts and formats MeSH terms from XML. * @param meshHeadingListXml - The XML MeshHeadingList element. * @returns An array of formatted MeSH term objects. */ export declare function extractMeshTerms(meshHeadingListXml?: XmlMeshHeadingList): ParsedMeshTerm[]; /** * Extracts and formats grant information from XML. * @param grantListXml - The XML GrantList element. * @returns An array of formatted grant objects. */ export declare function extractGrants(grantListXml?: XmlGrantList): ParsedGrant[]; /** * Extracts DOI from various possible locations in the XML. * Prioritizes ELocationID with ValidYN='Y', then any ELocationID, then ArticleIdList, * then PubmedData.ArticleIdList. * @param articleXml - The XML Article element. * @param pubmedDataArticleIdList - Optional ArticleIdList from PubmedData (sibling of MedlineCitation). * @returns The DOI string or undefined. */ export declare function extractDoi(articleXml?: XmlArticle, pubmedDataArticleIdList?: XmlArticleIdList): string | undefined; /** * Extracts PMC ID from ArticleIdList locations in the XML. * Searches Article.ArticleIdList and PubmedData.ArticleIdList for IdType='pmc'. * @param articleXml - The XML Article element. * @param pubmedDataArticleIdList - Optional ArticleIdList from PubmedData. * @returns The PMC ID string (e.g. 'PMC1234567') or undefined. */ export declare function extractPmcId(articleXml?: XmlArticle, pubmedDataArticleIdList?: XmlArticleIdList): string | undefined; /** * Extracts publication types from XML. * @param publicationTypeListXml - The XML PublicationTypeList element. * @returns An array of publication type strings. */ export declare function extractPublicationTypes(publicationTypeListXml?: XmlPublicationTypeList): string[]; /** * Extracts keywords from XML. Handles single or multiple KeywordList elements. * @param keywordListsXml - The XML KeywordList element or an array of them. * @returns An array of keyword strings. */ export declare function extractKeywords(keywordListsXml?: XmlKeywordList[] | XmlKeywordList): string[]; /** * Extracts abstract text from XML. Handles structured abstracts by concatenating sections. * If AbstractText is an array, joins them. If it's a single object/string, uses it directly. * Prefixes with Label if present. * @param abstractXml - The XML Abstract element from an Article. * @returns The abstract text string, or undefined if not found or empty. */ export declare function extractAbstractText(abstractXml?: XmlArticle['Abstract']): string | undefined; /** * Extracts PMID from MedlineCitation. * @param medlineCitationXml - The XML MedlineCitation element. * @returns The PMID string or undefined. */ export declare function extractPmid(medlineCitationXml?: XmlMedlineCitation): string | undefined; /** * Extracts article dates from XML. * @param articleXml - The XML Article element. * @returns An array of parsed article dates. */ export declare function extractArticleDates(articleXml?: XmlArticle): ParsedArticleDate[]; /** * Parses a full PubMed article XML structure into a ParsedArticle object, * combining all individual extractors. * @param xmlArticle - The raw XML PubmedArticle element. * @param options - Options controlling which optional sections to include. * @returns A fully parsed article object. */ export declare function parseFullArticle(xmlArticle: XmlPubmedArticle, options?: ParseFullArticleOptions): ParsedArticle; //# sourceMappingURL=article-parser.d.ts.map