@pipeworx/mcp-medicare-pricing 0.1.0 → 0.1.2
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/README.md +48 -2
- package/package.json +5 -1
- package/server.json +1 -1
- package/src/adlt.ts +96 -0
- package/src/index.ts +168 -1
- package/src/server.ts +1 -1
- package/.pipeworx-staged-ok +0 -6
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ What Medicare **pays** — physician fee schedule, lab rates, and per-day unit
|
|
|
4
4
|
limits. The companion to `medicare-coverage`, which answers whether something is
|
|
5
5
|
covered but not what it is worth.
|
|
6
6
|
|
|
7
|
-
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to
|
|
7
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1683+ live data sources.
|
|
8
8
|
|
|
9
9
|
## Tools
|
|
10
10
|
|
|
@@ -12,6 +12,7 @@ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents
|
|
|
12
12
|
|---|---|
|
|
13
13
|
| `medicare_physician_payment` | "How much does Medicare pay for 99213 in Los Angeles?" — RVUs and dollars, locality-adjusted. |
|
|
14
14
|
| `medicare_lab_rate` | "What does a comprehensive metabolic panel reimburse?" — national CLFS rate. |
|
|
15
|
+
| `medicare_lab_test_lookup` | "What does Medicare pay for Signatera, and which MolDX LCD applies?" — brand name → PLA code, current CLFS rate, and the MolDX LCDs/articles for the test's category. |
|
|
15
16
|
| `medicare_dmepos_rate` | "How much does Medicare pay for a CPAP machine (E0601) in Texas?" — state-priced, rural vs non-rural. |
|
|
16
17
|
| `medicare_code_units_limit` | "How many units of this code will they pay for in one day?" — NCCI MUE. |
|
|
17
18
|
| `check_code_pair` | "Can I bill 00142 and 64474 together?" — NCCI PTP edit + modifier indicator for a code pair. |
|
|
@@ -32,6 +33,51 @@ All from CMS, all downloadable files with no API:
|
|
|
32
33
|
- **NCCI Medically Unlikely Edits** — quarterly
|
|
33
34
|
- **NCCI PTP quarterly additions/deletions/revisions files** — quarterly (see below — a narrower source than the other three)
|
|
34
35
|
|
|
36
|
+
## ADLT list — brand name to billing code
|
|
37
|
+
|
|
38
|
+
`medicare_lab_test_lookup` exists because callers name a test by its brand
|
|
39
|
+
("Signatera"), not its code ("0340U"), and nothing else in the catalog maps one
|
|
40
|
+
to the other (fleet #2426).
|
|
41
|
+
|
|
42
|
+
**Source, and why it is the only one.** CMS's list of Advanced Diagnostic
|
|
43
|
+
Laboratory Tests
|
|
44
|
+
(<https://www.cms.gov/files/document/advanced-diagnostic-laboratory-tests-under-medicare-clfs.pdf>)
|
|
45
|
+
gives code, lab, proprietary test name, approval date and initial-period
|
|
46
|
+
payment for 18 tests. It is a US federal work (17 USC 105). The sources that
|
|
47
|
+
were checked and rejected:
|
|
48
|
+
|
|
49
|
+
- **AMA PLA long-descriptor PDF** — "CPT® Copyright 2026 American Medical
|
|
50
|
+
Association. All rights reserved." It also lists only the codes changed in
|
|
51
|
+
the latest cycles (143 of them), and 0340U is not among them.
|
|
52
|
+
- **Palmetto MolDX DEX registry** — needs a registered account, even for the
|
|
53
|
+
"public user" catalog, and hides Z-codes from public users. That's an auth
|
|
54
|
+
wall.
|
|
55
|
+
- **CMS Coverage API article code tables** — need a caller's CMS/AMA licence
|
|
56
|
+
token (already how `medicare-coverage` handles it).
|
|
57
|
+
- **NCBI GTR** — knows Signatera and Guardant360 but its `cptcode` field is
|
|
58
|
+
empty for them.
|
|
59
|
+
|
|
60
|
+
So coverage is limited to ADLTs. A test outside the list gets
|
|
61
|
+
`found: false, reason: not_on_adlt_list` and a pointer to `medicare_lab_rate`.
|
|
62
|
+
|
|
63
|
+
**Copy, not proxy.** The list is a two-page PDF with no API, and the gateway
|
|
64
|
+
has no PDF parser, so the rows are baked into `src/adlt.ts`. The PDF's "Test
|
|
65
|
+
Descriptor" column is AMA PLA text and is **not** copied. Every call sends a
|
|
66
|
+
HEAD to the PDF and compares `Last-Modified` with the snapshot's. If CMS has
|
|
67
|
+
republished, the response carries `snapshot_current: false`. To refresh:
|
|
68
|
+
download the PDF, extract its text (`pypdf` works), update the rows in
|
|
69
|
+
`src/adlt.ts`, and bump `ADLT_DATA_AS_OF` and `SNAPSHOT_LAST_MODIFIED`.
|
|
70
|
+
|
|
71
|
+
**Coverage.** Each test has a `coverage_topic`, a phrase that is ours and not
|
|
72
|
+
CMS's. It matches the title of the MolDX LCD/article family for the test's
|
|
73
|
+
category (for Signatera, "Minimal Residual Disease"). The tool reads the live,
|
|
74
|
+
keyless CMS Coverage API reports and returns the active LCDs and billing
|
|
75
|
+
articles with that title. Retired ones come back only with
|
|
76
|
+
`include_retired: true`. This matters because contractors re-issue MolDX
|
|
77
|
+
policies under new numbers: Noridian's L38816 and A58456 were retired
|
|
78
|
+
2026-02-05 and replaced by L38814 and A58454. Whether a specific test is listed
|
|
79
|
+
is answered by the billing article's code table, not by the title match.
|
|
80
|
+
|
|
35
81
|
## Vintage is not a detail
|
|
36
82
|
|
|
37
83
|
Fee schedules change annually and NCCI/CLFS quarterly. Quoting a 2026 procedure
|
|
@@ -247,7 +293,7 @@ directly, instead of just this one's:
|
|
|
247
293
|
}
|
|
248
294
|
```
|
|
249
295
|
|
|
250
|
-
Both URLs reach the same gateway and the same
|
|
296
|
+
Both URLs reach the same gateway and the same 1683+ data sources. The
|
|
251
297
|
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
|
|
252
298
|
reaches all of them from either one.
|
|
253
299
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeworx/mcp-medicare-pricing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "What does Medicare PAY — physician fee schedule, lab rates, and per-day unit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -24,5 +24,9 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"typescript": "^5.9.3",
|
|
26
26
|
"@cloudflare/workers-types": "^4.20260405.1"
|
|
27
|
+
},
|
|
28
|
+
"pipeworx": {
|
|
29
|
+
"sourceHash": "v1-39abb67f2c97d76656d44948e3ff83744176d3ab644ad6bb0dfb4fe227df10b6",
|
|
30
|
+
"sourceCommit": "6182c4cfebddb94950e060b5d2fca18f18ad1aca"
|
|
27
31
|
}
|
|
28
32
|
}
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.pipeworx-io/medicare-pricing",
|
|
4
4
|
"title": "Medicare Pricing",
|
|
5
5
|
"description": "What does Medicare PAY — physician fee schedule, lab rates, and per-day unit",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.2",
|
|
7
7
|
"websiteUrl": "https://pipeworx.io/packs/medicare-pricing",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/pipeworx-io/mcp-medicare-pricing",
|
package/src/adlt.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMS's list of Advanced Diagnostic Laboratory Tests (ADLTs) — the one public,
|
|
3
|
+
* licence-clean list that maps a lab test's BRAND name to its billing code
|
|
4
|
+
* (fleet #2426: "Signatera" -> 0340U).
|
|
5
|
+
*
|
|
6
|
+
* Source: https://www.cms.gov/files/document/advanced-diagnostic-laboratory-tests-under-medicare-clfs.pdf
|
|
7
|
+
* (linked from cms.gov "ADLT Information"; embedded source name
|
|
8
|
+
* "2025.3.10_List of Approved ADLTs.xlsx"; HTTP Last-Modified
|
|
9
|
+
* Tue, 11 Mar 2025 15:10:55 GMT, 118,376 bytes — checked 2026-09-25).
|
|
10
|
+
*
|
|
11
|
+
* WHY IT IS BAKED, NOT FETCHED. The list is a two-page PDF that changes a few
|
|
12
|
+
* times a year and has no API; the gateway carries no PDF parser. It is a US
|
|
13
|
+
* federal work (17 USC 105), so a copy is fine (CLAUDE.md, "build the copy").
|
|
14
|
+
* The refresh path is the live Last-Modified check in the tool itself
|
|
15
|
+
* (SNAPSHOT_LAST_MODIFIED below): when CMS republishes, every response says
|
|
16
|
+
* so, and the README section "ADLT list" says how to re-extract.
|
|
17
|
+
*
|
|
18
|
+
* WHAT IS NOT HERE. The PDF's "Test Descriptor" column is the AMA's CPT PLA
|
|
19
|
+
* descriptor text ("CPT Copyright ... American Medical Association. All rights
|
|
20
|
+
* reserved") — the same text this pack already refuses to store. Only the CMS
|
|
21
|
+
* facts are kept: code, lab, proprietary test name, approval date, the new-ADLT
|
|
22
|
+
* initial period and its payment.
|
|
23
|
+
*
|
|
24
|
+
* `coverage_topic` is OURS, not CMS's: a phrase that matches the title of the
|
|
25
|
+
* MolDX LCD / billing article for the test's category (each checked against the
|
|
26
|
+
* live LCD title list on 2026-09-25). It finds the policy family; whether this
|
|
27
|
+
* specific test is listed in the article's code table is a separate question
|
|
28
|
+
* the article answers. null where no local policy title fits.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export interface AdltTest {
|
|
32
|
+
code: string;
|
|
33
|
+
code_note: string | null;
|
|
34
|
+
lab: string;
|
|
35
|
+
test_name: string;
|
|
36
|
+
aliases: string[];
|
|
37
|
+
adlt_approval_date: string;
|
|
38
|
+
new_adlt_initial_period: string | null;
|
|
39
|
+
initial_period_payment_usd: number | null;
|
|
40
|
+
existing_adlt: boolean;
|
|
41
|
+
coverage_topic: string | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const ADLT_SOURCE_URL = 'https://www.cms.gov/files/document/advanced-diagnostic-laboratory-tests-under-medicare-clfs.pdf';
|
|
45
|
+
export const ADLT_DATA_AS_OF = '2025-03-10';
|
|
46
|
+
export const SNAPSHOT_LAST_MODIFIED = 'Tue, 11 Mar 2025 15:10:55 GMT';
|
|
47
|
+
|
|
48
|
+
export const ADLT_TESTS: AdltTest[] = [
|
|
49
|
+
{ code: '0537U', code_note: null, lab: 'Guardant Health, Inc.', test_name: 'Shield', aliases: ['Guardant Shield'], adlt_approval_date: '2025-03-10', new_adlt_initial_period: '2025-04-01 to 2025-12-31', initial_period_payment_usd: 1495, existing_adlt: false, coverage_topic: null },
|
|
50
|
+
{ code: '0473U', code_note: null, lab: 'Tempus AI, Inc.', test_name: 'xT CDx', aliases: ['Tempus xT', 'Tempus xT CDx'], adlt_approval_date: '2024-06-26', new_adlt_initial_period: '2024-07-01 to 2025-03-31', initial_period_payment_usd: 4500, existing_adlt: false, coverage_topic: 'Next-Generation Sequencing for Solid Tumors' },
|
|
51
|
+
{ code: '0356U', code_note: null, lab: 'Naveris, Inc.', test_name: 'NavDx', aliases: [], adlt_approval_date: '2024-03-18', new_adlt_initial_period: '2024-04-01 to 2024-12-31', initial_period_payment_usd: 1800, existing_adlt: false, coverage_topic: 'Minimal Residual Disease' },
|
|
52
|
+
{ code: '0315U', code_note: null, lab: 'Castle Biosciences, Inc.', test_name: 'DecisionDx-SCC', aliases: ['DecisionDx SCC'], adlt_approval_date: '2023-06-30', new_adlt_initial_period: '2023-07-01 to 2024-03-31', initial_period_payment_usd: 8500, existing_adlt: false, coverage_topic: 'Risk Stratification of Cutaneous Squamous Cell Carcinoma' },
|
|
53
|
+
{ code: '0360U', code_note: null, lab: 'Biodesix, Inc.', test_name: 'Nodify CDT', aliases: [], adlt_approval_date: '2023-06-30', new_adlt_initial_period: null, initial_period_payment_usd: null, existing_adlt: true, coverage_topic: null },
|
|
54
|
+
{ code: '0295U', code_note: null, lab: 'Prelude Corporation', test_name: 'DCISionRT', aliases: [], adlt_approval_date: '2023-03-23', new_adlt_initial_period: '2023-04-01 to 2023-12-31', initial_period_payment_usd: 5435, existing_adlt: false, coverage_topic: null },
|
|
55
|
+
{ code: '0108U', code_note: null, lab: 'Castle Biosciences, Inc. / Cernostics, Inc.', test_name: "TissueCypher Barrett's Esophagus Assay", aliases: ['TissueCypher'], adlt_approval_date: '2022-03-24', new_adlt_initial_period: '2022-04-01 to 2022-12-31', initial_period_payment_usd: 2350, existing_adlt: false, coverage_topic: 'Upper Gastrointestinal Metaplasia, Dysplasia, and Neoplasia' },
|
|
56
|
+
{ code: '0340U', code_note: null, lab: 'Natera, Inc.', test_name: 'Signatera', aliases: [], adlt_approval_date: '2021-06-17', new_adlt_initial_period: '2021-07-01 to 2022-03-31', initial_period_payment_usd: 3500, existing_adlt: false, coverage_topic: 'Minimal Residual Disease' },
|
|
57
|
+
{ code: '0242U', code_note: null, lab: 'Guardant Health, Inc.', test_name: 'Guardant360 CDx', aliases: ['Guardant360', 'Guardant 360'], adlt_approval_date: '2021-03-18', new_adlt_initial_period: '2021-04-01 to 2021-12-31', initial_period_payment_usd: 5000, existing_adlt: false, coverage_topic: 'Plasma-Based Genomic Profiling in Solid Tumors' },
|
|
58
|
+
{ code: '0239U', code_note: null, lab: 'Foundation Medicine, Inc.', test_name: 'FoundationOne Liquid CDx', aliases: ['F1 Liquid CDx', 'FoundationOne Liquid'], adlt_approval_date: '2021-01-25', new_adlt_initial_period: '2021-04-01 to 2021-12-31', initial_period_payment_usd: 3500, existing_adlt: false, coverage_topic: 'Plasma-Based Genomic Profiling in Solid Tumors' },
|
|
59
|
+
{ code: '81554', code_note: 'Effective 2021-01-01', lab: 'Veracyte', test_name: 'Envisia Genomic Classifier', aliases: ['Envisia'], adlt_approval_date: '2020-09-17', new_adlt_initial_period: '2020-10-01 to 2021-06-30', initial_period_payment_usd: 5500, existing_adlt: false, coverage_topic: 'Idiopathic Pulmonary Fibrosis' },
|
|
60
|
+
{ code: '0172U', code_note: 'Effective 2020-07-01', lab: 'Myriad', test_name: 'myChoice CDx', aliases: ['Myriad myChoice'], adlt_approval_date: '2019-12-11', new_adlt_initial_period: '2020-01-01 to 2020-09-30', initial_period_payment_usd: 4040, existing_adlt: false, coverage_topic: 'Next-Generation Sequencing for Solid Tumors' },
|
|
61
|
+
{ code: '0090U', code_note: null, lab: 'Myriad', test_name: 'myPath Melanoma', aliases: ['Myriad myPath'], adlt_approval_date: '2019-09-06', new_adlt_initial_period: '2019-10-01 to 2020-06-30', initial_period_payment_usd: 1950, existing_adlt: false, coverage_topic: 'Molecular Assays for the Diagnosis of Cutaneous Melanoma' },
|
|
62
|
+
{ code: '0080U', code_note: null, lab: 'Biodesix, Inc.', test_name: 'BDX-XL2', aliases: ['BDX XL2'], adlt_approval_date: '2019-05-17', new_adlt_initial_period: '2019-07-01 to 2020-03-31', initial_period_payment_usd: 3520, existing_adlt: false, coverage_topic: null },
|
|
63
|
+
{ code: '81529', code_note: 'Effective 2021-01-01', lab: 'Castle Biosciences, Inc.', test_name: 'DecisionDx-Melanoma', aliases: ['DecisionDx Melanoma'], adlt_approval_date: '2019-05-17', new_adlt_initial_period: '2019-07-01 to 2020-03-31', initial_period_payment_usd: 7193, existing_adlt: false, coverage_topic: 'Melanoma Risk Stratification' },
|
|
64
|
+
{ code: '81552', code_note: 'Effective 2020-01-01; CMS lists an earlier code for this test ("Previously ...")', lab: 'Castle Biosciences, Inc.', test_name: 'DecisionDx-UM', aliases: ['DecisionDx UM', 'Decision Dx-UM'], adlt_approval_date: '2019-05-17', new_adlt_initial_period: null, initial_period_payment_usd: null, existing_adlt: true, coverage_topic: 'Uveal Melanoma' },
|
|
65
|
+
{ code: '81538', code_note: null, lab: 'Biodesix, Inc.', test_name: 'VeriStrat', aliases: [], adlt_approval_date: '2018-12-21', new_adlt_initial_period: null, initial_period_payment_usd: null, existing_adlt: true, coverage_topic: null },
|
|
66
|
+
{ code: '0037U', code_note: null, lab: 'Foundation Medicine, Inc.', test_name: 'FoundationOne CDx', aliases: ['F1CDx', 'F1 CDx'], adlt_approval_date: '2018-05-18', new_adlt_initial_period: '2018-07-01 to 2019-03-31', initial_period_payment_usd: 3500, existing_adlt: false, coverage_topic: 'Next-Generation Sequencing for Solid Tumors' },
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const norm = (s: string) => s.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Match a caller's free text to ADLT rows: by code, then by test name/alias
|
|
73
|
+
* (either contains the other, so "Signatera MRD test" still resolves), then by
|
|
74
|
+
* lab. A test-name hit wins over a lab hit — "Guardant360" must not return
|
|
75
|
+
* Shield just because both are Guardant's.
|
|
76
|
+
*/
|
|
77
|
+
export function matchAdlt(query: string): { matched_by: 'code' | 'test_name' | 'lab' | null; tests: AdltTest[] } {
|
|
78
|
+
const q = norm(query);
|
|
79
|
+
if (q.length < 3) return { matched_by: null, tests: [] };
|
|
80
|
+
const byCode = ADLT_TESTS.filter((t) => norm(t.code) === q);
|
|
81
|
+
if (byCode.length) return { matched_by: 'code', tests: byCode };
|
|
82
|
+
const names = (t: AdltTest) => [t.test_name, ...t.aliases].map(norm);
|
|
83
|
+
const exact = ADLT_TESTS.filter((t) => names(t).includes(q));
|
|
84
|
+
if (exact.length) return { matched_by: 'test_name', tests: exact };
|
|
85
|
+
const byName = ADLT_TESTS.filter((t) => names(t).some((n) => n.length >= 4 && (n.includes(q) || q.includes(n))));
|
|
86
|
+
if (byName.length) {
|
|
87
|
+
// "Guardant360 CDx" contains "guardant360", and so does nothing else; but a
|
|
88
|
+
// query that CONTAINS two names ("FoundationOne CDx") keeps only the longest.
|
|
89
|
+
const longest = Math.max(...byName.map((t) => Math.max(...names(t).filter((n) => q.includes(n)).map((n) => n.length), 0)));
|
|
90
|
+
const narrowed = longest > 0 ? byName.filter((t) => names(t).some((n) => n.length === longest && q.includes(n))) : byName;
|
|
91
|
+
return { matched_by: 'test_name', tests: narrowed };
|
|
92
|
+
}
|
|
93
|
+
const byLab = ADLT_TESTS.filter((t) => q.length >= 4 && norm(t.lab).includes(q));
|
|
94
|
+
if (byLab.length) return { matched_by: 'lab', tests: byLab };
|
|
95
|
+
return { matched_by: null, tests: [] };
|
|
96
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -452,7 +452,42 @@ async function fetchWithTimeout(
|
|
|
452
452
|
),
|
|
453
453
|
);
|
|
454
454
|
}
|
|
455
|
-
|
|
455
|
+
// Fleet #2382. Everything that isn't a timeout/abort here is a genuine
|
|
456
|
+
// NETWORK-LEVEL failure — DNS resolution, connection refused, TLS handshake,
|
|
457
|
+
// Cloudflare's own "Network connection lost." — meaning `fetch()` itself
|
|
458
|
+
// threw and no HTTP response of any kind was ever received. Until this fix
|
|
459
|
+
// that raw exception was rethrown VERBATIM: a bare `TypeError: fetch failed`
|
|
460
|
+
// (or the Workers-runtime equivalent) names no upstream, carries no class
|
|
461
|
+
// token, and reads exactly like a defect in OUR code — because it says
|
|
462
|
+
// nothing about the call at all. It landed in `error`, the tier that means
|
|
463
|
+
// "Pipeworx has a defect", for every one of the (at the time of writing)
|
|
464
|
+
// ~470 packs that call this helper directly with no wrapper of their own.
|
|
465
|
+
//
|
|
466
|
+
// `dexscreener` hit this independently (fleet #1579) and fixed it with a
|
|
467
|
+
// bespoke per-pack try/catch around `fetchWithTimeout`. That fix is correct
|
|
468
|
+
// but only covers one pack; every other caller of this shared helper still
|
|
469
|
+
// leaked the raw exception. Moving the same fix HERE — the one place that
|
|
470
|
+
// already carries the timeout case — covers every pack that uses
|
|
471
|
+
// `fetchWithTimeout` without a wrapper, for free, and without widening
|
|
472
|
+
// `classifyToolError`'s regex list: the fix is giving the message a proper
|
|
473
|
+
// `upstream_down:` token at the point the two facts (no response was ever
|
|
474
|
+
// received, and which host we were trying to reach) are actually in hand,
|
|
475
|
+
// not teaching the classifier to guess from prose after the fact.
|
|
476
|
+
//
|
|
477
|
+
// Safe on the same grounds as the timeout branch above: no argument a
|
|
478
|
+
// caller passes can make `fetch()` itself throw a connection-level error,
|
|
479
|
+
// so this is always an availability failure, never a caller mistake. Same
|
|
480
|
+
// `markInternalOrigin` treatment — an origin we run that never answered is
|
|
481
|
+
// still ours, not a third party's outage.
|
|
482
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
483
|
+
throw new Error(
|
|
484
|
+
markInternalOrigin(
|
|
485
|
+
`upstream_down: could not reach ${name} at all (${raw.slice(0, 160)}). ` +
|
|
486
|
+
`No request reached ${name}, so this says NOTHING about whether the arguments you passed ` +
|
|
487
|
+
'are valid — do not re-check them on the strength of this error. Retry shortly.',
|
|
488
|
+
url,
|
|
489
|
+
),
|
|
490
|
+
);
|
|
456
491
|
}
|
|
457
492
|
}
|
|
458
493
|
|
|
@@ -704,6 +739,7 @@ function collapse(s: string): string {
|
|
|
704
739
|
* returns year_not_loaded rather than silently substituting another vintage.
|
|
705
740
|
*/
|
|
706
741
|
|
|
742
|
+
import { ADLT_DATA_AS_OF, ADLT_SOURCE_URL, SNAPSHOT_LAST_MODIFIED, matchAdlt, type AdltTest } from './adlt.js';
|
|
707
743
|
|
|
708
744
|
// Bound every fetch() in this pack to a fixed timeout — an upstream that
|
|
709
745
|
// degrades without erroring would otherwise hold the Worker in `await fetch()`
|
|
@@ -857,6 +893,19 @@ const tools: McpToolExport['tools'] = [
|
|
|
857
893
|
required: ['code'],
|
|
858
894
|
},
|
|
859
895
|
},
|
|
896
|
+
{
|
|
897
|
+
name: 'medicare_lab_test_lookup',
|
|
898
|
+
description:
|
|
899
|
+
'Resolve a branded molecular or genomic lab test by its commercial name (e.g. Signatera, Guardant360 CDx, FoundationOne CDx, FoundationOne Liquid CDx, Tempus xT CDx, DecisionDx-Melanoma, Envisia, Shield) to its CPT PLA / HCPCS billing code, the lab that runs it, what Medicare pays for it now on the Clinical Laboratory Fee Schedule, and the MolDX local coverage determinations (LCDs) and billing-and-coding articles for its test category. Answers "what does Medicare pay for Signatera", "what is the PLA code for Guardant360", "which MolDX LCD covers this test". Also accepts a lab name (e.g. "Natera") or a code. Covers the tests on the CMS list of Advanced Diagnostic Laboratory Tests (ADLTs), the only public list that ties a test\'s brand name to its code; a test not on it returns not_found with the reason. Sourced from CMS (ADLT list, Clinical Laboratory Fee Schedule, Medicare Coverage Database).',
|
|
900
|
+
inputSchema: {
|
|
901
|
+
type: 'object' as const,
|
|
902
|
+
properties: {
|
|
903
|
+
test: { type: 'string', description: 'The test\'s brand or commercial name ("Signatera", "Guardant360 CDx"), the lab ("Natera"), or its code ("0340U").' },
|
|
904
|
+
include_retired: { type: 'boolean', description: 'Also list retired LCDs/articles for the test category (default false). Contractors re-issue MolDX policies under new numbers, so an older citation may be a retired document.' },
|
|
905
|
+
},
|
|
906
|
+
required: ['test'],
|
|
907
|
+
},
|
|
908
|
+
},
|
|
860
909
|
{
|
|
861
910
|
name: 'medicare_dmepos_rate',
|
|
862
911
|
description:
|
|
@@ -925,6 +974,57 @@ const tools: McpToolExport['tools'] = [
|
|
|
925
974
|
},
|
|
926
975
|
];
|
|
927
976
|
|
|
977
|
+
/**
|
|
978
|
+
* The ADLT table is a baked copy of a CMS PDF, so every answer re-checks the
|
|
979
|
+
* PDF's Last-Modified against the snapshot. A changed date means CMS has
|
|
980
|
+
* republished the list and the copy may be missing a test — said, not hidden.
|
|
981
|
+
*/
|
|
982
|
+
async function adltSnapshotCheck(): Promise<{ snapshot_current: boolean | null; snapshot_note?: string }> {
|
|
983
|
+
try {
|
|
984
|
+
const res = await pwFetch(ADLT_SOURCE_URL, { method: 'HEAD', headers: { 'User-Agent': 'Mozilla/5.0 (compatible; Pipeworx/1.0; +https://pipeworx.io)' } });
|
|
985
|
+
const lm = res.ok ? res.headers.get('last-modified') : null;
|
|
986
|
+
if (!lm) return { snapshot_current: null, snapshot_note: `Could not re-check the CMS ADLT list (HTTP ${res.status}); results reflect the list as of ${ADLT_DATA_AS_OF}.` };
|
|
987
|
+
if (lm === SNAPSHOT_LAST_MODIFIED) return { snapshot_current: true };
|
|
988
|
+
return { snapshot_current: false, snapshot_note: `CMS republished the ADLT list (Last-Modified ${lm}) after the version these results reflect (${SNAPSHOT_LAST_MODIFIED}); a newly approved ADLT may be missing from these results.` };
|
|
989
|
+
} catch {
|
|
990
|
+
return { snapshot_current: null, snapshot_note: `Could not re-check the CMS ADLT list; results reflect the list as of ${ADLT_DATA_AS_OF}.` };
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
interface CoverageDoc {
|
|
995
|
+
document_display_id: string; document_type: string; title: string; contractor: string;
|
|
996
|
+
effective_date: string; retired: boolean; url: string;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/** CMS writes retirement_date as MM/DD/YYYY or "N/A"; a future date is still in effect. */
|
|
1000
|
+
function retiredBy(d: string): boolean {
|
|
1001
|
+
const m = /^(\d{2})\/(\d{2})\/(\d{4})$/.exec(d);
|
|
1002
|
+
return !!m && Date.UTC(+m[3], +m[1] - 1, +m[2]) <= Date.now();
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** Every final LCD and local article, keyless from the CMS Coverage API reports. null if CMS did not answer. */
|
|
1006
|
+
async function coverageIndex(): Promise<CoverageDoc[] | null> {
|
|
1007
|
+
try {
|
|
1008
|
+
const get = async (path: string) => {
|
|
1009
|
+
const res = await pwFetch(`https://api.coverage.cms.gov/v1/reports/${path}/?page_size=5000`, { headers: { Accept: 'application/json' } });
|
|
1010
|
+
if (!res.ok) throw new Error(String(res.status));
|
|
1011
|
+
return ((await res.json()) as { data?: Record<string, unknown>[] }).data ?? [];
|
|
1012
|
+
};
|
|
1013
|
+
const [lcds, articles] = await Promise.all([get('local-coverage-final-lcds'), get('local-coverage-articles')]);
|
|
1014
|
+
return [...lcds, ...articles].map((r) => ({
|
|
1015
|
+
document_display_id: String(r.document_display_id ?? ''),
|
|
1016
|
+
document_type: String(r.document_type ?? ''),
|
|
1017
|
+
title: String(r.title ?? ''),
|
|
1018
|
+
contractor: String(r.contractor_name_type ?? '').split(/\r?\n/)[0],
|
|
1019
|
+
effective_date: String(r.effective_date ?? ''),
|
|
1020
|
+
retired: /retired/i.test(String(r.note ?? '')) || retiredBy(String(r.retirement_date ?? '')),
|
|
1021
|
+
url: String(r.url ?? ''),
|
|
1022
|
+
}));
|
|
1023
|
+
} catch {
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
928
1028
|
async function resolveLocality(cfg: Cfg, q: unknown, year: number): Promise<{ chosen: Gpci | null; alternatives: Gpci[]; note: string }> {
|
|
929
1029
|
if (typeof q !== 'string' || !q.trim()) {
|
|
930
1030
|
return { chosen: null, alternatives: [], note: 'No locality given, so no geographic adjustment was applied — the RVUs below are national and the payment figures are omitted. Pass locality for an actual dollar amount.' };
|
|
@@ -1032,6 +1132,73 @@ async function callTool(name: string, args: Record<string, unknown>): Promise<un
|
|
|
1032
1132
|
};
|
|
1033
1133
|
}
|
|
1034
1134
|
|
|
1135
|
+
case 'medicare_lab_test_lookup': {
|
|
1136
|
+
const test = typeof args.test === 'string' ? args.test.trim() : '';
|
|
1137
|
+
if (!test) return { found: false, reason: 'no_test', hint: 'Pass test, e.g. "Signatera".' };
|
|
1138
|
+
const includeRetired = args.include_retired === true;
|
|
1139
|
+
const { matched_by, tests } = matchAdlt(test);
|
|
1140
|
+
const [snapshot, coverage] = await Promise.all([adltSnapshotCheck(), tests.some((t) => t.coverage_topic) ? coverageIndex() : Promise.resolve(null)]);
|
|
1141
|
+
const provenance = {
|
|
1142
|
+
source: 'CMS list of Advanced Diagnostic Laboratory Tests (ADLTs) under the Medicare CLFS; rates from the CMS Clinical Laboratory Fee Schedule; policies from the CMS Medicare Coverage Database',
|
|
1143
|
+
source_url: ADLT_SOURCE_URL,
|
|
1144
|
+
data_as_of: ADLT_DATA_AS_OF,
|
|
1145
|
+
...snapshot,
|
|
1146
|
+
};
|
|
1147
|
+
if (!tests.length) {
|
|
1148
|
+
return {
|
|
1149
|
+
found: false,
|
|
1150
|
+
reason: 'not_on_adlt_list',
|
|
1151
|
+
test,
|
|
1152
|
+
hint: 'This test is not on CMS\'s ADLT list, which is the only public list that maps a lab test\'s brand name to its billing code. Most PLA codes are not ADLTs; the full PLA code list with proprietary names is published by the AMA under copyright. If you have the code (it usually ends in U, e.g. "0340U"), medicare_lab_rate gives its rate; medicare_lcd_search finds coverage policies by topic.',
|
|
1153
|
+
...provenance,
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
const results = await Promise.all(tests.map(async (t: AdltTest) => {
|
|
1157
|
+
const rates = await pg<{ year: number; quarter: string; rate: number }>(cfg,
|
|
1158
|
+
`clfs_rates?hcpcs=eq.${t.code}&select=year,quarter,rate&order=year.desc,quarter.desc&limit=1`);
|
|
1159
|
+
// "Response to Comments" articles are the comment period's record, not policy.
|
|
1160
|
+
const docs = t.coverage_topic && coverage
|
|
1161
|
+
? coverage.filter((d) => d.title.toLowerCase().includes(t.coverage_topic!.toLowerCase()) && !/^response to comments/i.test(d.title))
|
|
1162
|
+
: [];
|
|
1163
|
+
const active = docs.filter((d) => !d.retired);
|
|
1164
|
+
const retired = docs.filter((d) => d.retired);
|
|
1165
|
+
return {
|
|
1166
|
+
code: t.code,
|
|
1167
|
+
...(t.code_note ? { code_note: t.code_note } : {}),
|
|
1168
|
+
test_name: t.test_name,
|
|
1169
|
+
lab: t.lab,
|
|
1170
|
+
current_clfs_rate: rates.length
|
|
1171
|
+
? { rate_usd: rates[0].rate, fee_schedule_year: rates[0].year, quarter: rates[0].quarter, note: 'National rate; the CLFS is not adjusted by locality.' }
|
|
1172
|
+
: { rate_usd: null, note: `${t.code} has no rate on the loaded Clinical Laboratory Fee Schedule (it may be contractor-priced).` },
|
|
1173
|
+
adlt: {
|
|
1174
|
+
approval_date: t.adlt_approval_date,
|
|
1175
|
+
existing_adlt: t.existing_adlt,
|
|
1176
|
+
new_adlt_initial_period: t.new_adlt_initial_period,
|
|
1177
|
+
initial_period_payment_usd: t.initial_period_payment_usd,
|
|
1178
|
+
},
|
|
1179
|
+
coverage: t.coverage_topic
|
|
1180
|
+
? {
|
|
1181
|
+
policy_topic: t.coverage_topic,
|
|
1182
|
+
topic_note: 'Policies whose title matches this test\'s category (our topic mapping, not CMS\'s). Whether this specific test is listed is stated in the billing article\'s code table.',
|
|
1183
|
+
active_documents: active.slice(0, 20),
|
|
1184
|
+
active_count: active.length,
|
|
1185
|
+
...(includeRetired ? { retired_documents: retired.slice(0, 20) } : {}),
|
|
1186
|
+
retired_count: retired.length,
|
|
1187
|
+
...(coverage === null ? { error: 'CMS Coverage API did not answer; retry, or use medicare_lcd_search with the policy_topic.' } : {}),
|
|
1188
|
+
}
|
|
1189
|
+
: { policy_topic: null, note: 'No MolDX local policy title matches this test\'s category; it may be covered nationally (NCD) or case by case.' },
|
|
1190
|
+
};
|
|
1191
|
+
}));
|
|
1192
|
+
return {
|
|
1193
|
+
found: true,
|
|
1194
|
+
query: test,
|
|
1195
|
+
matched_by,
|
|
1196
|
+
tests: results,
|
|
1197
|
+
no_descriptors_note: 'The AMA\'s CPT PLA descriptor text is not returned (AMA copyright); the test name and lab are CMS\'s.',
|
|
1198
|
+
...provenance,
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1035
1202
|
case 'medicare_dmepos_rate': {
|
|
1036
1203
|
const hcpcs = code(args.code);
|
|
1037
1204
|
if (!hcpcs) return { found: false, reason: 'no_code', hint: 'Pass code, e.g. "E0601".' };
|
package/src/server.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprot
|
|
|
9
9
|
import pack from './index.js';
|
|
10
10
|
|
|
11
11
|
const server = new Server(
|
|
12
|
-
{ name: '@pipeworx/mcp-medicare-pricing', version: '0.1.
|
|
12
|
+
{ name: '@pipeworx/mcp-medicare-pricing', version: '0.1.2' },
|
|
13
13
|
{ capabilities: { tools: {} } },
|
|
14
14
|
);
|
|
15
15
|
|
package/.pipeworx-staged-ok
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"staged_at": "2026-09-23T20:33:13.962Z",
|
|
3
|
-
"publisher_blob": "da6994091dc9dcc6a7433084251ca4bbd58b4bed",
|
|
4
|
-
"publisher_commit": "1c417b2cfcdac06e2d9210e869265722ef013f20",
|
|
5
|
-
"note": "Written by scripts/publish-pack.sh as its LAST step. Its presence is the ONLY thing that lets stage-unpublished-packs.sh skip this pack. Deleting this dir is the correct way to force a rebuild."
|
|
6
|
-
}
|