---
slug: "pi-pubmed"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/dspachos/pi-pubmed@main/README.md"
repo: "https://github.com/dspachos/pi-pubmed"
source_file: "README.md"
branch: "main"
---
# pi-pubmed

A [Pi](https://pi.dev) package for searching [PubMed](https://pubmed.ncbi.nlm.nih.gov/) and fetching biomedical literature articles directly from your coding agent.

## Features

- **Search PubMed** — Find articles using full PubMed query syntax (boolean operators, field tags, MeSH terms, date ranges)
- **Fetch article details** — Retrieve titles, authors, journals, publication dates, DOIs, and full abstracts
- **Zero dependencies** — Uses the NCBI E-utilities REST API directly
- **Configurable** — Optional API key support for higher rate limits

## Installation

```bash
pi install npm:pi-pubmed
```

Or install from a local path:

```bash
pi install /path/to/pi-pubmed
```

## Tools

### `pubmed_search`

Search PubMed for articles matching a query.

| Parameter       | Type     | Required | Description                                                                        |
|----------------|----------|----------|------------------------------------------------------------------------------------|
| `query`        | string   | ✅       | PubMed search query (supports boolean operators, field tags, MeSH terms)          |
| `max_results`  | number   | ❌       | Max results to return (1–100, default 10)                                         |
| `sort_by`      | string   | ❌       | Sort: `relevance`, `pub_date`, `Author`, `JournalName`                            |
| `date_range`   | string   | ❌       | Date range as `YYYY:YYYY` or `YYYY/MM:YYYY/MM`                                   |

### `pubmed_fetch`

Fetch detailed article information for specific PubMed IDs.

| Parameter          | Type       | Required | Description                                     |
|-------------------|------------|----------|-------------------------------------------------|
| `pmids`           | string[]   | ✅       | List of PubMed IDs to fetch                     |
| `include_abstract`| boolean    | ❌       | Include full abstract (default true)            |

## Usage Examples

Once installed, just ask Pi naturally:

```
Search PubMed for recent articles about CRISPR gene therapy
```

```
Find review articles about machine learning in drug discovery from the last 5 years
```

```
Fetch the abstract for PMID 38312345
```

## Configuration (Optional)

Set environment variables for enhanced access:

| Variable       | Description                                        |
|---------------|----------------------------------------------------|
| `NCBI_API_KEY`| NCBI API key — increases rate limit to 10 req/s    |
| `NCBI_EMAIL`  | Your email — helps NCBI contact you if needed      |

Get a free API key at: https://www.ncbi.nlm.nih.gov/account/settings/

## Package Structure

```
pi-pubmed/
├── package.json          # Package manifest with Pi configuration
├── extensions/
│   └── pubmed.ts         # Extension with pubmed_search & pubmed_fetch tools
├── skills/
│   └── pubmed/
│       └── SKILL.md      # Skill instructions for the agent
└── README.md
```

## License

MIT
