payer-reference MCP Server
by gowthams96
README.md
# payer-reference-mcp
[](https://github.com/gowthams96/payer-reference-mcp/actions/workflows/ci.yml)
[](LICENSE)
AI agents that handle health-insurance claims need authoritative code data. Left
to themselves, they can invent ICD-10 or HCPCS codes or accept invalid NPIs, so
this MCP server answers code and identifier lookups from CMS's own public files
instead.
**Topics:** `mcp` · `health-insurance` · `claims` · `agent-skills`
Only CMS public data is used. There are no AMA CPT descriptions and no member data.
## Architecture
```mermaid
flowchart LR
A["Agent<br/>(any MCP client)"] <-->|"MCP over stdio<br/>tools/list · tools/call"| S
subgraph S["payer-reference MCP server — src/payer_reference/server.py"]
T1["icd10_lookup"]
T2["hcpcs_lookup"]
T3["npi_validate"]
end
T1 --> ICD[("ICD-10-CM FY2027<br/>CMS order file")]
T2 --> HC[("HCPCS Level II Jan 2027<br/>CMS ANWEB file")]
T3 --> L["Luhn check digit<br/>80840 prefix"]
S -.->|planned| N[("NCCI edit table")]
S -.->|planned| F[("Synthetic formulary")]
S -.->|planned| C["Cost-share function"]
K["claim-code-validation skill"] -.->|planned| A
classDef planned stroke-dasharray: 5 5,color:#777
class N,F,C,K planned
```
Solid lines are built in v0.1. Dashed boxes are planned and **not in this
repo yet** (see [Roadmap](#roadmap)).
## Quickstart
Requires Python 3.11+, [uv](https://docs.astral.sh/uv/), and Node.js (only for MCP Inspector).
```sh
git clone https://github.com/gowthams96/payer-reference-mcp.git
cd payer-reference-mcp
uv sync
uv run python scripts/fetch_codes.py # CMS ICD-10-CM FY2027 + HCPCS Jan 2027 -> data/
uv run pytest # offline: tests/fixtures only, no secrets
```
Run the server over stdio. It waits for an MCP client on stdin/stdout:
```sh
uv run payer-reference
```
Inspect it with [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
The first command opens the web UI, where you choose Connect, then Tools, then
List Tools. The second lists the tools from the terminal:
```sh
npx @modelcontextprotocol/inspector uv run payer-reference
npx @modelcontextprotocol/inspector --cli uv run payer-reference --method tools/list
```
No API keys or `.env` are needed. To serve the small test fixture instead of the
full files, set `PAYER_REFERENCE_DATA_DIR=tests/fixtures`.
### Use from an MCP client
```json
{
"mcpServers": {
"payer-reference": {
"command": "uv",
"args": ["--directory", "/path/to/payer-reference-mcp", "run", "payer-reference"]
}
}
}
```
## Tools
Every tool publishes an input JSON schema and an output schema, and returns
structured content.
| Tool | Inputs | Outputs | Example call |
|---|---|---|---|
| `icd10_lookup` | `query`: an ICD-10-CM code (dot optional: `E11.9` or `E119`) or words | `query`, `match_type` (`code`/`text`), `code_set`, `results[]` (`code`, `description`, `valid`, `note`), `truncated` | `{"query": "E11.9"}` → `E11.9` "Type 2 diabetes mellitus without complications", `valid: true` |
| `hcpcs_lookup` | `query`: a HCPCS Level II code (`G0008`) or words | Same as `icd10_lookup` | `{"query": "influenza vaccine"}` → 10 codes, starting `G0008` (valid), `G0919` (terminated), …, `truncated: true` |
| `npi_validate` | `npi`: a string | `npi`, `valid`, `reason` | `{"npi": "1234567893"}` → `valid: true` |
From the terminal:
```sh
npx @modelcontextprotocol/inspector --cli uv run payer-reference \
--method tools/call --tool-name icd10_lookup --tool-arg query=E11.9
```
**`valid` flag**
| Code set | `valid=true` | `valid=false` (code still returned, with a `note`) |
|---|---|---|
| ICD-10-CM | Billable (order-file flag 1) | Header/category codes, e.g. `E11` |
| HCPCS Level II | No termination date, or terminated on/after the file's effective date (2027-01-01) | Terminated earlier, e.g. `A4397` (2021-12-31) |
| NPI | 10 digits and the Luhn check digit over `80840` + the first 9 digits matches | Malformed input or a wrong check digit, with a `reason`. There is no error path. |
**Queries**
- **Code lookup:** a query that looks like a code gets an exact lookup
(case-insensitive). For ICD-10-CM, a query must also contain a digit to count
as a code.
- **Text search:** any other query returns up to 10 entries whose description
contains every word (case-insensitive), ordered by code.
**Errors** are tool results with `isError: true` and structured content:
```json
{"error": {"type": "unknown_code", "message": "'Z99.9' is not in ICD-10-CM FY2027", "query": "Z99.9"}}
```
| `type` | When |
|---|---|
| `unknown_code` | A code that isn't in the file |
| `no_match` | A text search with no results |
| `invalid_query` | A blank query |
| `not_supported` | CPT-style numeric codes (AMA) or D-codes (CDT, ADA) |
| `data_unavailable` | `data/` hasn't been downloaded yet |
## claim-code-validation skill
**Not built yet.** No skill ships in v0.1, so there is nothing to install. It is
planned as an agent skill that walks an agent through checking a claim's
diagnosis codes, procedure codes and NPI with these tools. Install steps will be
added here when it exists. See [Roadmap](#roadmap).
## Data sources and licensing
| Data | Source (CMS public files) | File used |
|---|---|---|
| ICD-10-CM FY2027 | [`2027-code-descriptions-tabular-order.zip`](https://www.cms.gov/files/zip/2027-code-descriptions-tabular-order.zip) from [CMS ICD-10](https://www.cms.gov/medicare/coding-billing/icd-10-codes) | `icd10cm_order_2027.txt` |
| HCPCS Level II, January 2027 | [`january-2027-alpha-numeric-hcpcs-file.zip`](https://www.cms.gov/files/zip/january-2027-alpha-numeric-hcpcs-file.zip) from [CMS HCPCS quarterly update](https://www.cms.gov/medicare/coding-billing/healthcare-common-procedure-system/quarterly-update) | `HCPC2027_JAN_ANWEB.txt` |
- **The URLs were confirmed on 2026-12-02.** `scripts/fetch_codes.py` downloads
both files into `data/`, which is git-ignored, so no full code files are
committed.
- **No AMA CPT content.** Only HCPCS **Level II** is loaded. The parser skips
numeric (CPT, Level I) codes and modifier records, and `hcpcs_lookup` refuses
CPT-style codes.
- **No ADA CDT content.** The HCPCS record layout says D-codes carry the ADA's
copyrighted CDT descriptions, so D-codes are skipped too. The January 2027
file contains none.
- **The test fixture is real CMS data.** `tests/fixtures/` holds 27 ICD-10-CM
and 15 HCPCS codes plus 2 Level II modifier records, copied verbatim by
`scripts/make_fixture.py`.
- **Checked against CMS's own counts.** The parser finds 74,879 billable
ICD-10-CM codes, which matches CMS's `icd10cm_codes_2027.txt`, and 8,929
HCPCS procedure codes.
- **No member data and no PHI.** None are used anywhere.
- **The code is MIT-licensed** ([LICENSE](LICENSE)). The CMS code sets are
public data from CMS.
## Limitations
- **Plain word search.** Text search has no synonyms, stemming or ranking.
- **HCPCS validity is judged at the file's effective date.** It doesn't check
against today's date or a date of service, and HCPCS modifiers aren't
available.
- **`npi_validate` only checks format and the check digit.** It doesn't query
NPPES, so `valid: true` doesn't mean the NPI is assigned to a provider.
- **One release of each code set.** Updating to a new fiscal year or quarter
means changing the URLs in `scripts/fetch_codes.py`.
- **No CPT or dental codes**, by design (see licensing).
- **Not production software.** It's a reference tool, not a claims editor or
billing advice.
## Roadmap
These are not in v0.1:
- **NCCI edit table:** procedure-to-procedure edits.
- **Synthetic formulary:** synthetic data only.
- **Cost-share function.**
- **claim-code-validation agent skill:** with install instructions.
## Development
- **CI.** [`.github/workflows/ci.yml`](.github/workflows/ci.yml) runs
`uv sync --locked`, `ruff check`, `ruff format --check` and `pytest` on every
push and pull request, with no secrets.
- **Tests run offline.** An autouse fixture in `tests/conftest.py` fails any
test that opens a network connection.
- **SDK version.** Built on the official Python MCP SDK `mcp` 2.3.0
(`mcp.server.MCPServer`, spec 2026-07-28). Code written for `mcp` 1.x should
note:
- `FastMCP` was renamed `MCPServer`.
- `run()` defaults to stdio.
- Tests connect in-process with `Client(server)`.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues