PubMed Search
Search and analyze biomedical literature from PubMed using the free E-utilities API. Use when researching medical topics, discovering clinical papers, fetching article metadata by PMID, performing deep paper analysis, or downloading open-access PDFs from PubMed Central. Triggers: pubmed search, search biomedical literature, find medical papers, PMID lookup, pubmed metadata, clinical literature search, biomedical research, life sciences papers, PMC download, ncbi search.
npx skills add github:pantheon-org/tekhne --skill documentation--research--pubmed-searchSearch and analyze biomedical literature from PubMed using the free NCBI E-utilities API.
When to Use
- Discovering biomedical or clinical papers by keyword, author, journal, or date range
- Fetching structured metadata (title, authors, abstract, DOI) for a known PMID
- Performing deep analysis of a paper when only the abstract and metadata are available
- Downloading open-access full-text PDFs from PubMed Central (PMC)
- Building a candidate list before running
triage-paper
When Not to Use
- The paper is already known (DOI, URL) — go straight to
triage-paper - A
semantic-scholarMCP or PubTator MCP is configured — prefer the MCP; it returns structured data with no rate-limit risk - The search is for general academic literature — use
google-scholar-searchorsemantic-scholar-search - A candidate JSON already exists at
/tmp/<topic>-candidates.json— reuse it
Recommended MCP Server
When available, prefer the PubTator MCP server over this script:
{
"mcpServers": {
"pubtator": {
"type": "stdio",
"command": "uvx",
"args": ["pubtator-mcp-server"]
}
}
}
Mindset
Search is discovery, not analysis. The goal is a structured candidate list.
- Rate limits are a gotcha: without an API key the limit is 3 req/s; a pitfall is issuing bulk PMID fetches without a delay, causing silent failures or 429s. ALWAYS add a short delay between batch calls.
- MCP first: ALWAYS check whether a PubTator or PubMed MCP is configured before invoking the Python script. MCPs are faster, structured, and avoid rate-limit risk.
- Open access is not guaranteed: a pitfall is assuming all PMC articles can be downloaded. NEVER attempt to download a PDF without first confirming PMC availability and open-access status.
Workflow
1. Check MCP availability
ALWAYS check for a pubtator or pubmed MCP before running the script. If configured and reachable, prefer it.
2. Set up the environment (first run only)
See setup-and-troubleshooting.md for venv creation and dependency installation.
3. Run the search
Activate the venv, then choose the appropriate subcommand. You may optionally add --show-abstract to keyword searches for a richer preview.
# Basic keyword search
./scripts/pubmed_search.py search --keywords "CRISPR gene editing" --results 10
# Advanced: filter by author, journal, and date range
./scripts/pubmed_search.py search --term "cancer immunotherapy" --author "Smith" \
--journal "Nature" --start-date "2021" --end-date "2024" --results 20
# Fetch metadata for a known PMID
./scripts/pubmed_search.py metadata --pmid "33303479" --format json
# Deep paper analysis
./scripts/pubmed_search.py analyze --pmid "33303479" --output analysis.md
# Download open-access PDF
./scripts/pubmed_search.py download --pmid "33303479" --output-dir ./papers/
# Export candidate list to JSON
./scripts/pubmed_search.py search --keywords "Alzheimer disease biomarkers" \
--results 50 --format json --output /tmp/candidates.json
4. Handle rate-limit errors
If the script returns HTTP 429, wait 30 s and retry once:
sleep 30 && ./scripts/pubmed_search.py search --keywords "<topic>" --results 10
NEVER retry in a tight loop. If still failing, set PUBMED_API_KEY in the environment.
5. Present candidates and hand off
NEVER triage automatically — ALWAYS confirm with the user first:
Found N results. Would you like to triage any of these with
triage-paper?
Anti-Patterns
NEVER auto-triage search results
WHY: Discovery and triage are separate quality gates. Auto-triaging bypasses user review.
BAD Pass every result to triage-paper immediately. → GOOD Present the list; wait for the user to choose.
NEVER retry in a tight loop on 429
WHY: Repeated rapid retries worsen the block and extend the cooldown period.
BAD Loop search until it succeeds. → GOOD Retry once after 30 s; switch to MCP or API key on second failure.
NEVER assume all PMC articles are downloadable
WHY: Many PMC articles are not open access; the download command will fail or return a redirect link.
BAD Call download for every PMID. → GOOD Check PMC availability and open-access status before downloading.
NEVER skip the MCP availability check
WHY: The Python script is the fragile fallback. Skipping the check needlessly risks rate-limiting.
BAD Invoke the script without checking for a PubTator or PubMed MCP. → GOOD ALWAYS check MCP availability first; only fall back to the script if no MCP is configured.
NEVER hardcode API keys in scripts or task files
WHY: API keys committed to source are a production security risk and will be rotated or revoked.
BAD Set api_key = "abc123" inside the script. → GOOD ALWAYS use environment variables (PUBMED_API_KEY) or a .env file that is gitignored.
NEVER treat abstract-based analysis as a full-text review
WHY: PubMed metadata contains only the abstract. Deep analysis based solely on abstracts is incomplete and a pitfall for research quality.
BAD Mark a paper as “fully analysed” from analyze output alone. → GOOD Qualify analysis as “abstract-based” and recommend obtaining the full text for production use.
References
- Setup: setup-and-troubleshooting.md
- Script: pubmed_search.py
- Dependencies: requirements.txt
- Upstream: JackKuo666/pubmed-search-skill
- MCP alternative: PubTator-MCP-Server
Explicit NEVER/WHY/consequence triplets with side-by-side bad/good examples. Generic warnings score low — concrete failure modes with real impact (security, correctness, performance) score high.
Runtime validation via eval scenarios proving the skill actually changes agent behaviour. Requires evals/ directory, instructions.json, ≥3 scenarios, and ≥80% instruction coverage in summary.json.
Appropriate rigidity for the skill type: strict rules for critical/security skills, balanced steps for process skills, flexible options for tool skills. Mismatched calibration (too rigid or too loose) reduces score.
Expert-only knowledge the AI couldn't derive on its own — domain-specific patterns, production gotchas, decision frameworks, and non-obvious tool behaviour. High scores mean <5% redundancy with what the model already knows.
A clear philosophy plus numbered step-by-step workflows with explicit entry/exit points. Should answer: what is the core principle, how to execute it, and when (and when not) to apply it.
Rich activation keywords and trigger scenarios in the description so the skill fires when needed. Best descriptions read like an exhaustive list of the tasks and concepts that should invoke this skill.
Copy-paste-ready code, complete runnable examples, real file paths and commands. Pseudocode and abstract descriptions score low — concrete, executable content scores high.
SKILL.md as a <100-line navigation hub pointing to focused references/ files. Content should be lazy-loaded on demand, not front-loaded. Includes actionable 'When to Use' conditions per reference.
Proper frontmatter, single-task focus, activation keywords, and cross-harness portability. Skills must work across 40+ agentic harnesses without hardcoded paths or agent-specific references.
Expert-only knowledge the AI couldn't derive on its own — domain-specific patterns, production gotchas, decision frameworks, and non-obvious tool behaviour. High scores mean <5% redundancy with what the model already knows.
A clear philosophy plus numbered step-by-step workflows with explicit entry/exit points. Should answer: what is the core principle, how to execute it, and when (and when not) to apply it.
Explicit NEVER/WHY/consequence triplets with side-by-side bad/good examples. Generic warnings score low — concrete failure modes with real impact (security, correctness, performance) score high.
Proper frontmatter, single-task focus, activation keywords, and cross-harness portability. Skills must work across 40+ agentic harnesses without hardcoded paths or agent-specific references.
SKILL.md as a <100-line navigation hub pointing to focused references/ files. Content should be lazy-loaded on demand, not front-loaded. Includes actionable 'When to Use' conditions per reference.
Appropriate rigidity for the skill type: strict rules for critical/security skills, balanced steps for process skills, flexible options for tool skills. Mismatched calibration (too rigid or too loose) reduces score.
Rich activation keywords and trigger scenarios in the description so the skill fires when needed. Best descriptions read like an exhaustive list of the tasks and concepts that should invoke this skill.
Copy-paste-ready code, complete runnable examples, real file paths and commands. Pseudocode and abstract descriptions score low — concrete, executable content scores high.
Runtime validation via eval scenarios proving the skill actually changes agent behaviour. Requires evals/ directory, instructions.json, ≥3 scenarios, and ≥80% instruction coverage in summary.json.
No eval scenarios available.
Setup and Troubleshooting
Reference for installing dependencies and diagnosing common failures.
Installation
Recommended: uv
cd skills/documentation/research/pubmed-search
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
Alternative: standard venv
cd skills/documentation/research/pubmed-search
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Verify
python3 scripts/pubmed_search.py --help
Activating the environment
Every shell session requires activating the venv before running the script:
source skills/documentation/research/pubmed-search/.venv/bin/activate
Optional: API Key Configuration
The script works without an API key using the free PubMed E-utilities API. For higher rate limits, obtain a free key at ncbi.nlm.nih.gov/account and set these environment variables (or add to a .env file in the skill root):
export PUBMED_API_KEY="your-api-key-here"
export PUBMED_EMAIL="your-email@example.com"
Rate limits:
- Without API key: 3 requests per second
- With API key: up to 10 requests per second
Troubleshooting
HTTP 429 / rate limit
PubMed rate-limits unauthenticated requests. If you receive a 429:
- Wait 30 seconds and retry once.
- If still failing, set
PUBMED_API_KEY(see above). - Alternatively, configure the PubTator MCP server (see SKILL.md
When Not to Use). - Do not retry in a loop — it extends the cooldown.
Empty result set on a valid query
If the search URL is correct but returns zero PMIDs, verify the query manually:
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=CRISPR&retmax=5&retmode=xml"
If the response contains <Count>0</Count>, the query genuinely returns no results. Broaden your search terms.
PDF download returns “not open access”
Only articles with a PubMed Central (PMC) ID and an open-access licence can be downloaded automatically. For other articles, the script returns a direct PubMed URL where you can check access options.
requests import error
If the script fails with ModuleNotFoundError: No module named 'requests', the venv is not activated or dependencies are not installed:
source .venv/bin/activate
pip install -r requirements.txt
Wrong Python version
The script requires Python 3.10+. Check with:
python3 --version
If below 3.8, use mise or pyenv to install a compatible version.