CLI and Python SDK for biomedical literature search with MeSH, PICO, and intelligent query expansion
Project description
PubMed Search
CLI and Python SDK for biomedical literature search, query analysis, citation export, full-text lookup, and multi-source academic enrichment.
This repository is CLI/SDK-first. The primary runtime surface is the pubmed-search shell command, which is friendly to Codex-like coding agents, terminal workflows, and scripts. The Python package also exposes reusable clients and application services for projects that need direct imports.
Origin and Attribution
This CLI/SDK mainline is maintained at PiaoyangGuohai1/pubmed-search. It is derived from and inspired by u9401066/pubmed-search-mcp, with the Apache-2.0 license and upstream attribution preserved. The original MCP-oriented fork remains a legacy reference; this repository maintains the terminal and Python SDK surfaces.
Install
pip install pubmed-search
For local development from this repository:
pip install -e .
Optional NCBI credentials can be provided through flags or environment variables:
export NCBI_EMAIL="you@example.com"
export NCBI_API_KEY="optional_ncbi_key"
CLI
pubmed-search --help
pubmed-search search "MASLD cardiovascular risk" --format json --limit 5
pubmed-search strategy "MASLD cardiovascular risk" --format json
pubmed-search analyze-query "MASLD cardiovascular risk" --format json
pubmed-search details 38905512 --format markdown
pubmed-search export 38905512 --format ris
pubmed-search fulltext 38905512 --format markdown
pubmed-search timeline "MASLD cardiovascular risk" --limit 20 --format markdown
Core commands:
| Command | Purpose |
|---|---|
search |
Search biomedical literature across PubMed and optional academic sources. |
strategy |
Generate MeSH expansion and search strategy materials. |
analyze-query |
Analyze intent, complexity, identifiers, PICO, and source recommendations without running a search. |
details |
Fetch detailed metadata for one or more PMIDs. |
export |
Export citations as BibTeX, RIS, CSV, MEDLINE, CSL JSON, or JSON. |
fulltext |
Locate full-text access through available source resolvers. |
text-mined |
Retrieve text-mined biomedical terms when source data is available. |
related |
Find related articles for a PMID. |
metrics |
Fetch citation metrics where supported. |
timeline |
Build research timeline summaries from a query or PMID set. |
cite-tree |
Explore citation/reference relationships around a root PMID. |
pico |
Parse a clinical question into PICO-style components. |
gene, compound, clinvar |
Query NCBI extended databases. |
Use --format json for agent and script workflows. Use --output path to write command output directly to a file.
Python SDK
from pubmed_search import LiteratureSearcher, QueryAnalyzer, export_articles
searcher = LiteratureSearcher(email="you@example.com")
articles = searcher.search("MASLD cardiovascular risk", limit=5)
for article in articles:
print(article["pmid"], article["title"])
analysis = QueryAnalyzer().analyze("MASLD cardiovascular risk")
print(analysis.intent, analysis.complexity)
bibtex = export_articles(articles, fmt="bibtex")
Useful imports include:
LiteratureSearcherfor PubMed search/details/citation metrics.SearchStrategyGeneratorfor MeSH and query strategy generation.QueryAnalyzerandResultAggregatorfor application-level search planning.EuropePMCClient,NCBIExtendedClient, and source client factories for external data sources.export_articles,export_bibtex,export_ris,export_csv,export_medline, andexport_jsonfor citation output.
Architecture
The codebase keeps the retrieval product independent from any host application:
src/pubmed_search/
cli/ click commands and terminal formatting
application/ search planning, export, fulltext, timeline, and session services
domain/ article and pipeline entities
infrastructure/ NCBI, Europe PMC, OpenAlex, Semantic Scholar, Crossref, Unpaywall, and other adapters
shared/ settings, logging, cache, and cross-cutting helpers
The CLI imports application services directly. Presentation-specific protocol servers are not part of the main package. If a protocol adapter is needed again later, it should live in a separate package that depends on pubmed-search.
Development
pip install -e .[all]
pytest
ruff check .
The editable package installs only the pubmed-search console command.
Citation
If you use this software in research or internal methods documentation, cite the repository metadata in CITATION.cff.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pubmed_search-0.6.0.tar.gz.
File metadata
- Download URL: pubmed_search-0.6.0.tar.gz
- Upload date:
- Size: 303.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b12774a8897bebcbb6e449f43efffaf00449f4e8ead1dc846b5f6f25475f5a07
|
|
| MD5 |
108c7f377746f45b2f74de1c325ea80a
|
|
| BLAKE2b-256 |
d25bb29ed03dd1f5012be6b3f517543070107fcc75c56d9e035ee30a02dabc67
|
File details
Details for the file pubmed_search-0.6.0-py3-none-any.whl.
File metadata
- Download URL: pubmed_search-0.6.0-py3-none-any.whl
- Upload date:
- Size: 381.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74cceab0eea17262c82cd86104c39e88178f97dce8ea7f5bfa90e5c369fd64ef
|
|
| MD5 |
5d7a06c665fd2cbd20ef2469e57e0d6b
|
|
| BLAKE2b-256 |
355a54d2e98bd7235f81d3c69cfc27f741f833b56b0c5b6f0b08cffa1416c65d
|