@pipeworx/mcp-meps 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/bin/cli.js +17 -0
- package/package.json +27 -0
- package/server.json +18 -0
- package/src/conditions.ts +108 -0
- package/src/index.ts +998 -0
- package/src/server.ts +45 -0
- package/tsconfig.json +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mojibake Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# meps
|
|
2
|
+
|
|
3
|
+
What Americans actually take, and what for — US prescription drug use by medical
|
|
4
|
+
condition, from AHRQ's Medical Expenditure Panel Survey.
|
|
5
|
+
|
|
6
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1573+ live data sources.
|
|
7
|
+
|
|
8
|
+
MEPS surveys the whole US civilian non-institutionalized population: every payer,
|
|
9
|
+
every age, commercially insured and uninsured alike. It is the only source in
|
|
10
|
+
this catalog that links a prescription to the **condition it was written for**,
|
|
11
|
+
which is what makes "what do people take for depression" answerable at all.
|
|
12
|
+
|
|
13
|
+
## Tools
|
|
14
|
+
|
|
15
|
+
| Tool | Answers |
|
|
16
|
+
|---|---|
|
|
17
|
+
| `meps_drugs_for_condition` | Which drugs Americans take for a condition, ranked by people treated |
|
|
18
|
+
| `meps_conditions_for_drug` | What a drug is actually prescribed for — the off-label question |
|
|
19
|
+
| `meps_drug_use` | One drug's national volume, total spend and out-of-pocket share |
|
|
20
|
+
| `meps_top_drugs` | The most-used prescription drugs in the US for a year |
|
|
21
|
+
|
|
22
|
+
Conditions are taken in plain words — `"depression"`, `"high cholesterol"`,
|
|
23
|
+
`"type 2 diabetes"` — or as a CCSR code such as `MBD002`. Drug names are MEPS's
|
|
24
|
+
cleaned **generic** names, so `atorvastatin`, not `Lipitor`.
|
|
25
|
+
|
|
26
|
+
## These are survey estimates, and the sample is always in the response
|
|
27
|
+
|
|
28
|
+
Every respondent carries a weight projecting them onto roughly 18,000 Americans.
|
|
29
|
+
A cell backed by three people therefore produces a confident-looking
|
|
30
|
+
"55,000 people" that means almost nothing. So:
|
|
31
|
+
|
|
32
|
+
- every row carries **`sample_persons`** — the real respondents behind it;
|
|
33
|
+
- `reliable: false` marks anything under **60** respondents, which is AHRQ's own
|
|
34
|
+
publication floor;
|
|
35
|
+
- rows default to a minimum of **60** respondents — the same floor — so the
|
|
36
|
+
default answer contains nothing AHRQ would decline to publish. Lower it with
|
|
37
|
+
`min_sample` to see less-common drugs; those come back `reliable: false`.
|
|
38
|
+
|
|
39
|
+
Treat the numbers as *rough magnitude and ranking*, not as counts. Ranking the
|
|
40
|
+
top few drugs for a common condition is what this data is good for. Precise
|
|
41
|
+
totals, small subgroups and year-over-year differences of a few percent are not.
|
|
42
|
+
|
|
43
|
+
## Two things that would otherwise mislead
|
|
44
|
+
|
|
45
|
+
**Fewer than half of prescriptions carry a condition.** 47.5% of fills in 2024
|
|
46
|
+
are linked to any diagnosis; the rest are not attributed to one. So a condition
|
|
47
|
+
total is a subset of prescribing, not a census of it, and an empty result can
|
|
48
|
+
mean "not captured" rather than "not prescribed". Every response states the
|
|
49
|
+
year's actual coverage rather than implying completeness.
|
|
50
|
+
|
|
51
|
+
**One fill can be linked to several conditions.** That is correct for "is this
|
|
52
|
+
drug used for this condition" and wrong for money: the condition tables carry no
|
|
53
|
+
expenditure at all, because summing spend across conditions would invent
|
|
54
|
+
national spending that was never spent. Money lives only in `meps_drug_use` and
|
|
55
|
+
`meps_top_drugs`, where each fill is counted once.
|
|
56
|
+
|
|
57
|
+
**Some "drugs" are therapeutic classes.** MEPS substitutes a class name for the
|
|
58
|
+
product where naming it would identify a respondent — `INTERLEUKIN INHIBITORS`,
|
|
59
|
+
`ANTINEOPLASTICS`, `ANTIDIABETIC AGENTS`. In 2024 that is 49 of 554 names, but
|
|
60
|
+
those 49 carry **31.9% of all recorded spending**, so a ranking by cost is
|
|
61
|
+
dominated by classes rather than products. `meps_drug_use` and `meps_top_drugs`
|
|
62
|
+
say so in every response. A plural or category-sounding name is a class.
|
|
63
|
+
|
|
64
|
+
## Data sources
|
|
65
|
+
|
|
66
|
+
- MEPS public use files, three per year, from
|
|
67
|
+
<https://meps.ahrq.gov/data_files/pufs/> — Prescribed Medicines, the Appendix
|
|
68
|
+
to Event Files (the condition link), and Medical Conditions. Free, no
|
|
69
|
+
credential. The file numbers per year come from AHRQ's own index at
|
|
70
|
+
<https://meps.ahrq.gov/data_files/search_pufs.json>; they are not derivable
|
|
71
|
+
(2024 is HC-254A / HC-254I / HC-255), so they are looked up, never guessed.
|
|
72
|
+
- Condition category labels from the HCUP CCSR reference file,
|
|
73
|
+
<https://hcup-us.ahrq.gov/toolssoftware/ccsr/dxccsr.jsp>.
|
|
74
|
+
|
|
75
|
+
Years 2019 onward. Earlier files code conditions with CCS rather than CCSR and
|
|
76
|
+
are not comparable.
|
|
77
|
+
|
|
78
|
+
`.github/workflows/meps-refresh.yml` checks AHRQ's index on the 3rd of each month
|
|
79
|
+
and loads any year that has all three files and is not already held. AHRQ
|
|
80
|
+
publishes a year roughly annually without pre-announcing it, so the check does
|
|
81
|
+
nothing 11 months out of 12 — that is cheaper than noticing a release late.
|
|
82
|
+
|
|
83
|
+
**MEPStrends is not the source.** AHRQ's own pre-computed estimates at
|
|
84
|
+
`meps.ahrq.gov/mepstrends/` sit behind HTTP Basic auth (`WWW-Authenticate: Basic
|
|
85
|
+
realm="Secured Data Tools"`), so the estimates here are computed from the public
|
|
86
|
+
files rather than read from theirs.
|
|
87
|
+
|
|
88
|
+
## Quick Start
|
|
89
|
+
|
|
90
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"meps": {
|
|
96
|
+
"url": "https://gateway.pipeworx.io/meps/mcp"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### What this endpoint actually serves
|
|
103
|
+
|
|
104
|
+
`tools/list` at `https://gateway.pipeworx.io/meps/mcp` returns the tools in the table
|
|
105
|
+
above **plus the shared Pipeworx meta-tools** — `ask_pipeworx`,
|
|
106
|
+
`discover_tools`, `search_within`, `remember`/`recall` and the rest of the
|
|
107
|
+
gateway-wide set. So the tool count you see is larger than this table: a
|
|
108
|
+
single-pack endpoint currently lists roughly 30 shared tools alongside the
|
|
109
|
+
pack's own. The connection's `initialize` response states its exact scope, and
|
|
110
|
+
is the authoritative answer for a given day.
|
|
111
|
+
|
|
112
|
+
This is deliberate, not multiplexing by accident. The meta-tools are what let a
|
|
113
|
+
scoped connection answer a question this pack does not cover — via
|
|
114
|
+
`ask_pipeworx`, which routes across the whole catalog — without you adding a
|
|
115
|
+
second MCP server. There is currently no way to mount a pack endpoint without
|
|
116
|
+
them; if the extra schemas cost you more context than the routing is worth,
|
|
117
|
+
connect to the full gateway once rather than to several pack endpoints.
|
|
118
|
+
|
|
119
|
+
Or connect to the full Pipeworx gateway to get every pack's tools listed
|
|
120
|
+
directly, instead of just this one's:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"pipeworx": {
|
|
126
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Both URLs reach the same gateway and the same 1573+ data sources. The
|
|
133
|
+
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
|
|
134
|
+
reaches all of them from either one.
|
|
135
|
+
|
|
136
|
+
## Standalone (no gateway account)
|
|
137
|
+
|
|
138
|
+
This package also runs as a local stdio MCP server — no Pipeworx account, no
|
|
139
|
+
gateway round-trip:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"mcpServers": {
|
|
144
|
+
"meps": {
|
|
145
|
+
"command": "npx",
|
|
146
|
+
"args": ["-y", "@pipeworx/mcp-meps"]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Or run it directly to confirm it starts:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npx -y @pipeworx/mcp-meps
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
It speaks MCP over stdin/stdout and answers `initialize`/`tools/list`/`tools/call`
|
|
159
|
+
for **only** this pack's tools — none of the shared meta-tools the gateway
|
|
160
|
+
connection above adds. Same source, same tools, no ask_pipeworx routing.
|
|
161
|
+
|
|
162
|
+
## Using with ask_pipeworx
|
|
163
|
+
|
|
164
|
+
Instead of calling tools directly, you can ask questions in plain English —
|
|
165
|
+
this works on the pack endpoint above as well as on the full gateway:
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
ask_pipeworx({ question: "your question about Meps data" })
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
172
|
+
|
|
173
|
+
## More
|
|
174
|
+
|
|
175
|
+
- [Docs and guides](https://pipeworx.io/docs)
|
|
176
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
//
|
|
3
|
+
// Entry point for `npx @pipeworx/mcp-<slug>`.
|
|
4
|
+
//
|
|
5
|
+
// Packs ship as raw TypeScript (no build step — see publish-pack.sh for why:
|
|
6
|
+
// tsx sidesteps every extensionless-import / bare-JSON-import edge case a
|
|
7
|
+
// per-pack tsc build would have to solve one pack at a time). This file
|
|
8
|
+
// registers tsx's ESM loader programmatically, then hands off to src/server.ts,
|
|
9
|
+
// which wraps the pack's {tools, callTool} export in a stdio MCP server.
|
|
10
|
+
//
|
|
11
|
+
// Copied verbatim into every published pack repo by scripts/publish-pack.sh —
|
|
12
|
+
// edit this file, not a per-pack copy.
|
|
13
|
+
import { register } from 'tsx/esm/api';
|
|
14
|
+
|
|
15
|
+
register();
|
|
16
|
+
|
|
17
|
+
await import('../src/server.ts');
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-meps",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MEPS — what Americans actually take, and what for.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mcp-meps": "bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "meps"],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/pipeworx-io/mcp-meps.git"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
22
|
+
"tsx": "^4.19.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"typescript": "^5.7.0"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/meps",
|
|
4
|
+
"title": "Meps",
|
|
5
|
+
"description": "MEPS — what Americans actually take, and what for.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/meps",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-meps",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/meps/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning what a caller says into a CCSR condition category.
|
|
3
|
+
*
|
|
4
|
+
* MEPS codes conditions as CCSR categories — END010, MBD002 — and nobody asks
|
|
5
|
+
* a question in those terms. An agent asks "what do people take for high
|
|
6
|
+
* cholesterol". Without this the pack answers zero rows to almost every real
|
|
7
|
+
* question, which reads as "we have no data" rather than "you used the wrong
|
|
8
|
+
* vocabulary".
|
|
9
|
+
*
|
|
10
|
+
* Two layers: these hand-written synonyms for the way people actually speak,
|
|
11
|
+
* then a trigram match against the official CCSR labels for everything else.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Everyday phrasing -> CCSR categories. Several codes where the plain word
|
|
15
|
+
* genuinely spans them: "diabetes" is END002 and END003, and returning only
|
|
16
|
+
* one of them would quietly halve the answer. */
|
|
17
|
+
export const CONDITION_SYNONYMS: Record<string, string[]> = {
|
|
18
|
+
// EVERY code below was checked against the HCUP CCSR reference file, because
|
|
19
|
+
// a first pass written from memory got roughly a dozen of them wrong in a way
|
|
20
|
+
// no test would catch: "epilepsy" pointed at cerebral palsy, "psoriasis" at
|
|
21
|
+
// pressure ulcer, "hypothyroidism" at diabetes. Each would have returned a
|
|
22
|
+
// confident, plausible, wrong list of drugs. If you add a synonym, look the
|
|
23
|
+
// code up — do not recall it.
|
|
24
|
+
'high cholesterol': ['END010'],
|
|
25
|
+
cholesterol: ['END010'],
|
|
26
|
+
hyperlipidemia: ['END010'],
|
|
27
|
+
'lipid disorder': ['END010'],
|
|
28
|
+
// END004/005/006 are diabetes categories too, but MEPS does not use them:
|
|
29
|
+
// in the 2024 file every diabetes person sits in END002 or END003. Including
|
|
30
|
+
// the unused codes would only widen the query, but naming them here would
|
|
31
|
+
// imply a coverage that is not in the data.
|
|
32
|
+
diabetes: ['END002', 'END003'],
|
|
33
|
+
'type 2 diabetes': ['END002', 'END003'],
|
|
34
|
+
'blood sugar': ['END002', 'END003'],
|
|
35
|
+
obesity: ['END009'],
|
|
36
|
+
'weight loss': ['END009'],
|
|
37
|
+
thyroid: ['END001'],
|
|
38
|
+
hypothyroidism: ['END001'],
|
|
39
|
+
'high blood pressure': ['CIR007'],
|
|
40
|
+
hypertension: ['CIR007'],
|
|
41
|
+
'heart failure': ['CIR019'],
|
|
42
|
+
'atrial fibrillation': ['CIR017'],
|
|
43
|
+
afib: ['CIR017'],
|
|
44
|
+
arrhythmia: ['CIR017'],
|
|
45
|
+
'coronary artery disease': ['CIR011'],
|
|
46
|
+
'pulmonary embolism': ['CIR013'],
|
|
47
|
+
depression: ['MBD002'],
|
|
48
|
+
depressive: ['MBD002'],
|
|
49
|
+
anxiety: ['MBD005'],
|
|
50
|
+
ocd: ['MBD006'],
|
|
51
|
+
ptsd: ['MBD007'],
|
|
52
|
+
bipolar: ['MBD003'],
|
|
53
|
+
schizophrenia: ['MBD001'],
|
|
54
|
+
psychosis: ['MBD001'],
|
|
55
|
+
'opioid use disorder': ['MBD018'],
|
|
56
|
+
'alcohol use disorder': ['MBD017'],
|
|
57
|
+
smoking: ['MBD024'],
|
|
58
|
+
'tobacco use': ['MBD024'],
|
|
59
|
+
insomnia: ['NVS016'],
|
|
60
|
+
'sleep disorder': ['NVS016'],
|
|
61
|
+
epilepsy: ['NVS009'],
|
|
62
|
+
seizures: ['NVS009'],
|
|
63
|
+
migraine: ['NVS010'],
|
|
64
|
+
headache: ['NVS010'],
|
|
65
|
+
'nerve pain': ['NVS019'],
|
|
66
|
+
asthma: ['RSP009'],
|
|
67
|
+
copd: ['RSP008'],
|
|
68
|
+
emphysema: ['RSP008'],
|
|
69
|
+
'acid reflux': ['DIG004'],
|
|
70
|
+
gerd: ['DIG004'],
|
|
71
|
+
heartburn: ['DIG004'],
|
|
72
|
+
arthritis: ['MUS006', 'MUS003'],
|
|
73
|
+
osteoarthritis: ['MUS006'],
|
|
74
|
+
'rheumatoid arthritis': ['MUS003'],
|
|
75
|
+
osteoporosis: ['MUS013'],
|
|
76
|
+
'back pain': ['MUS038'],
|
|
77
|
+
'low back pain': ['MUS038'],
|
|
78
|
+
'chronic pain': ['MUS010', 'MUS038', 'NVS019'],
|
|
79
|
+
'kidney disease': ['GEN003'],
|
|
80
|
+
ckd: ['GEN003'],
|
|
81
|
+
hiv: ['INF006'],
|
|
82
|
+
glaucoma: ['EYE003'],
|
|
83
|
+
// Deliberately absent: ADHD (CCSR splits it across neurodevelopmental and
|
|
84
|
+
// impulse-control in a way the data does not settle), eczema and psoriasis
|
|
85
|
+
// (no dedicated category — the nearest is "other specified inflammatory
|
|
86
|
+
// condition of skin"), and allergies (the only "allergic" category is an
|
|
87
|
+
// INJURY code for allergic reactions). Those fall through to the label
|
|
88
|
+
// search, which reports which category it matched so a caller can see what
|
|
89
|
+
// they actually got.
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const CCSR_RE = /^[A-Z]{3}\d{3}$/;
|
|
93
|
+
|
|
94
|
+
/** An exact CCSR code if the caller gave one, else the synonym hit, else null
|
|
95
|
+
* meaning "fall through to a label search". */
|
|
96
|
+
export function resolveConditionCodes(raw: string): string[] | null {
|
|
97
|
+
const t = raw.trim();
|
|
98
|
+
if (!t) return null;
|
|
99
|
+
if (CCSR_RE.test(t.toUpperCase())) return [t.toUpperCase()];
|
|
100
|
+
const lower = t.toLowerCase().replace(/\s+/g, ' ');
|
|
101
|
+
if (CONDITION_SYNONYMS[lower]) return CONDITION_SYNONYMS[lower];
|
|
102
|
+
// Longest containing synonym, so "type 2 diabetes mellitus" still resolves
|
|
103
|
+
// and does not lose to the shorter "diabetes".
|
|
104
|
+
const hit = Object.keys(CONDITION_SYNONYMS)
|
|
105
|
+
.filter((k) => lower.includes(k))
|
|
106
|
+
.sort((a, b) => b.length - a.length)[0];
|
|
107
|
+
return hit ? CONDITION_SYNONYMS[hit] : null;
|
|
108
|
+
}
|