get_citations
Retrieve a formatted citation for a given PubMed ID (PMID) in AMA, APA, or Vancouver style.
Instructions
Return a formatted citation for a PMID. Styles: AMA, APA, Vancouver.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pmid | Yes | ||
| style | No | AMA |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:44-57 (handler)The get_citations tool handler. Accepts a PMID and citation style (default 'AMA'), fetches article summary from PubMed eutils, formats authors/title/journal/year/volume/pages into a citation string.
async def get_citations(pmid: str, style: str = "AMA") -> str: """Return a formatted citation for a PMID. Styles: AMA, APA, Vancouver.""" async with httpx.AsyncClient() as client: r = await client.get(f"{PUBMED_BASE}/esummary.fcgi", params={ "db": "pubmed", "id": pmid, "retmode": "json" }) s = r.json()["result"][pmid] authors = ", ".join([a["name"] for a in s.get("authors", [])[:3]]) title = s["title"] journal = s["fulljournalname"] year = s["pubdate"][:4] volume = s.get("volume", "") pages = s.get("pages", "") return f"{authors}. {title} {journal}. {year};{volume}:{pages}. PMID: {pmid}" - server.py:43-43 (registration)The @mcp.tool() decorator registers get_citations as an MCP tool. This is a single-file codebase using FastMCP, so registration is done inline via the decorator.
@mcp.tool() - server.py:44-44 (schema)Input schema defined by the function signature: pmid (required str) and style (optional str, default 'AMA').
async def get_citations(pmid: str, style: str = "AMA") -> str: