$npx -y skills add QSong-github/DrugClaw --skill medlineplusQuery MedlinePlus for consumer-oriented drug and health-topic information. Accepts drug names, RxCUI codes, NDC codes, or ICD-10-CM diagnosis codes. Uses two free, keyless NLM APIs: the Web Service (keyword search) and MedlinePlus Connect (code-based lookup).
| 1 | # MedlinePlus Drug Info Skill |
| 2 | |
| 3 | Search MedlinePlus drug / health-topic pages. Auto-detects input type: |
| 4 | |
| 5 | | Input Pattern | Detected As | Example | Endpoint Used | |
| 6 | |---|---|---|---| |
| 7 | | `0069-3060-30` | NDC code | NDC → drug page | Connect (NDC) | |
| 8 | | `637188` (5-7 digits) | RxCUI | RxNorm concept | Connect (RxCUI) | |
| 9 | | `E11.9`, `J45.20` | ICD-10-CM | Diagnosis code → topic | Connect (ICD-10) | |
| 10 | | anything else | free text | `metformin`, `aspirin` | Connect (name) + wsearch | |
| 11 | |
| 12 | Both APIs are free, require no API key, and are rate-limited to 85 req/min. |
| 13 | |
| 14 | ## API |
| 15 | |
| 16 | | Function | Input | Returns | |
| 17 | |---|---|---| |
| 18 | | `search(query, max_results=10)` | single entity string | `dict` with `connect_results`, `wsearch_results` | |
| 19 | | `search_batch(queries, max_results=10)` | list of entity strings | `dict[str, dict]` | |
| 20 | | `summarize(result)` | one `search()` result dict | compact text for LLM | |
| 21 | | `to_json(result)` | one `search()` result dict | `list[dict]` flat records | |
| 22 | |
| 23 | ### Result dict structure |
| 24 | |
| 25 | ```python |
| 26 | { |
| 27 | "query": "metformin", |
| 28 | "input_type": "text", # ndc | rxcui | icd10 | text |
| 29 | "connect_results": [ # from MedlinePlus Connect |
| 30 | {"title": "...", "url": "...", "summary": "...", "source": "..."}, |
| 31 | ], |
| 32 | "wsearch_results": [ # from keyword web service |
| 33 | {"title": "...", "url": "...", "snippet": "...", "rank": "..."}, |
| 34 | ], |
| 35 | "errors": [], |
| 36 | } |
| 37 | ``` |
| 38 | |
| 39 | ## Usage |
| 40 | |
| 41 | See `if __name__ == "__main__"` block in `57_MEDLINEPLUS_DRUG_INFO.py` for |
| 42 | runnable examples covering: drug name, RxCUI, NDC, ICD-10, batch search, |
| 43 | summarize, and JSON output. |
| 44 | |
| 45 | ## Key Fields |
| 46 | |
| 47 | | Field | Source | Description | |
| 48 | |---|---|---| |
| 49 | | `title` | Connect / wsearch | MedlinePlus page title | |
| 50 | | `url` | Connect / wsearch | Direct link to MedlinePlus page | |
| 51 | | `summary` | Connect | HTML-stripped page summary (≤400 chars) | |
| 52 | | `snippet` | wsearch | Keyword-in-context excerpt (≤300 chars) | |
| 53 | | `source` | Connect | Content attribution (e.g., AHFS, ASHP) | |
| 54 | | `rank` | wsearch | Relevance rank returned by NLM | |
| 55 | |
| 56 | ## Data Source |
| 57 | |
| 58 | - **Provider**: U.S. National Library of Medicine (NLM) |
| 59 | - **Web Service**: `https://wsearch.nlm.nih.gov/ws/query` (XML, keyword search) |
| 60 | - **Connect API**: `https://connect.medlineplus.gov/service` (JSON, code-based) |
| 61 | - **Rate limit**: 85 requests / minute / IP |
| 62 | - **Update frequency**: daily (Tue–Sat) |
| 63 | - **License**: Public domain (U.S. Government work); attribution to MedlinePlus.gov requested |