Skip to main content
Glama
Ishaan24687

cpt-analysis-mcp-server

by Ishaan24687
README.md
# Healthcare CPT Code Analysis — MCP Server

An MCP (Model Context Protocol) server that connects Claude Desktop to a healthcare claims database, enabling natural-language analysis of CPT codes, reimbursement rates, payer performance, and denial patterns.

Built to demonstrate how MCP bridges the gap between AI assistants and domain-specific data systems in the healthcare/PBM space.

## Architecture

```
Claude Desktop                    MCP Server (Python)                SQLite Database
┌──────────────┐     JSON-RPC    ┌─────────────────┐               ┌───────────────┐
│              │◄──── stdio ────►│                 │◄── queries ──►│ cpt_codes     │
│  User asks   │                 │  6 Tools        │               │ payers        │
│  questions   │                 │  3 Resources    │               │ payer_rates   │
│  in plain    │                 │  2 Prompts      │               │ claims (10K)  │
│  English     │                 │                 │               │ denial_reasons│
└──────────────┘                 └─────────────────┘               └───────────────┘
```

**How it works:**
1. Claude Desktop starts this server as a subprocess
2. The server announces its tools (functions Claude can call)
3. When you ask a question, Claude decides which tool(s) to use
4. The server queries SQLite and returns structured results
5. Claude interprets the data and responds in natural language

## What's Inside

### Tools (Functions Claude Can Call)

| Tool | Purpose | Example Question |
|------|---------|-----------------|
| `lookup_cpt_code` | Get details for a specific CPT code | "What is CPT 27447?" |
| `query_claims` | Filter and search claims data | "Show me denied surgery claims over $5000" |
| `analyze_reimbursement` | Compare rates across payers | "How do payers compare for radiology rates?" |
| `detect_anomalies` | Find pricing outliers | "Where are we billing way above the allowed amount?" |
| `denial_analysis` | Investigate denial patterns | "What are the top denial reasons for Aetna?" |
| `compare_payers` | Side-by-side payer comparison | "Which payer pays the most for cardiac procedures?" |
| `financial_summary` | Revenue and collection reporting | "Show me financials by category for Q2" |

### Resources (Context Claude Can Read)

- **`schema://claims-database`** — Full database schema with column descriptions
- **`schema://cpt-categories`** — CPT code category reference with rate ranges
- **`data://summary-stats`** — Quick overview of the entire dataset

### Prompts (Structured Analysis Templates)

- **`analyze-claim`** — Step-by-step analysis of a specific claim
- **`rate-review`** — Comprehensive payer/category rate review for contract negotiations

## Dataset

- **70 CPT codes** across 5 categories (E&M, Surgery, Radiology, Pathology, Medicine)
- **7 payers** (5 commercial + Medicare + Medicaid)
- **10,000 claims** with realistic denial patterns (~15% denial rate)
- **490 payer rate schedules** (7 payers × 70 codes)
- Medicare rates based on 2024 CMS Physician Fee Schedule
- CARC denial reason codes from real 835 remittance standards

## Setup

### Prerequisites
- Python 3.11+
- Claude Desktop (with MCP support)

### Install

```bash
git clone https://github.com/Ishaan24687/cpt-analysis-mcp-server.git
cd cpt-analysis-mcp-server
pip install -r requirements.txt
```

### Seed the Database

```bash
python -m src.seed_data
```

This creates `cpt_analysis.db` with all reference data and synthetic claims.

### Connect to Claude Desktop

1. Open Claude Desktop settings
2. Go to **Developer > Edit Config**
3. Add the server config from `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "cpt-analysis": {
      "command": "python",
      "args": ["-m", "src.server"],
      "cwd": "/path/to/cpt-analysis-mcp-server"
    }
  }
}
```

4. Restart Claude Desktop
5. You should see "cpt-analysis" in the MCP tools list (hammer icon)

## Demo Conversations

Once connected, try these in Claude Desktop:

**Overview:**
> "Give me an overview of the claims data"

**CPT Lookup:**
> "What is CPT 27447 and how much do different payers reimburse for it?"

**Denial Investigation:**
> "Which CPT codes have the highest denial rates? What are the main reasons?"

**Payer Comparison:**
> "Compare all payers for surgery procedures — who pays the best and who denies the most?"

**Anomaly Detection:**
> "Find pricing anomalies where we're billing more than 3x the allowed amount"

**Contract Negotiation Prep:**
> "I'm preparing for a rate negotiation with UnitedHealthcare for radiology services. Give me a complete analysis."

## Project Structure

```
cpt-analysis-mcp-server/
├── src/
│   ├── __init__.py
│   ├── server.py          # MCP server — tools, resources, prompts
│   ├── database.py         # SQLite schema and connection management
│   └── seed_data.py        # Realistic healthcare data generation
├── claude_desktop_config.json
├── requirements.txt
├── .gitignore
└── README.md
```

## Why MCP?

Traditional approach: Copy data from database → paste into ChatGPT → get generic answer.

MCP approach: Ask Claude a question → Claude queries your actual database → get a specific, data-backed answer.

MCP turns an AI assistant from a "smart text generator" into a "smart analyst with direct access to your systems." For healthcare operations teams dealing with claims data, this means faster root cause analysis, better contract negotiation prep, and real-time anomaly detection — all through natural conversation.

## Tech Stack

- **MCP SDK** (`mcp[cli]`) — Protocol implementation
- **SQLite** — Zero-config database (production would use Azure SQL / PostgreSQL)
- **Python 3.12** — Server runtime
- **Claude Desktop** — MCP host application