Claims Data MCP Server
Enables natural language querying of healthcare claims data by exposing a SQLite database with read-only SQL tools, allowing users to ask questions in plain English and get answers backed by real database queries.
README
Claims Data Assistant - Natural Language Querying for Healthcare Claims
Problem
Business stakeholders - claims managers, compliance leads, finance - routinely need quick answers from claims data: "Which claim types are getting rejected most?" "What did we pay out on pharmacy claims this year?" Today, that means filing a request and waiting on an analyst to write, run, and interpret a SQL query. For simple, recurring questions, this creates hours of turnaround time and pulls analysts away from higher-value work.
Approach
I built a natural-language interface where a stakeholder types a question in plain English and gets a direct, human-readable answer - backed by a real query against the claims database, not a guess.
The system uses the Model Context Protocol (MCP) to cleanly separate the database access layer from the AI layer:
- An MCP server exposes the claims database as a set of standardized primitives: a Resource (the live schema) and Tools (
run_sql_query,list_tables). It enforces a hard safety boundary - only read-onlySELECTstatements are permitted; anything else is rejected before it reaches SQLite. - Claude (Anthropic API) reads the schema, interprets the user's question, and writes the SQL needed to answer it, calling the MCP tool to execute it.
- A Streamlit front end handles the conversation and displays the answer, with the generated SQL available on demand for transparency.
Because the database logic lives entirely in the MCP server, it's portable - the same server could be pointed at from Claude Desktop or any other MCP client with zero code changes.
Impact
- Turns ad-hoc data requests that took hours of analyst time into answers delivered in seconds.
- Removes the SQL literacy requirement for non-technical stakeholders to self-serve on common claims questions.
- Keeps a human-readable audit trail: every answer is backed by an inspectable, read-only SQL query.
Tech Stack
- Python - application logic
- SQLite - claims database (providers, members, claims - ~3,000 synthetic claims records)
- Model Context Protocol (MCP) - decouples database access from the AI client via Tools and Resources
- Claude API (
claude-sonnet-4-6) - natural language understanding, SQL generation, and answer summarization - Streamlit - user interface
Architecture
┌─────────────┐ question ┌───────────────┐
│ Streamlit │ ─────────────────────► │ Claude API │
│ UI │ │(tool-use loop)│
└─────────────┘ └───────┬───────┘
▲ │ calls tool: run_sql_query
│ final answer + SQL ▼
│ ┌──────────────────┐
└───────────────────────────────── │ MCP Server │
│ (stdio transport)│
└────────┬─────────┘
│ SELECT ...
▼
┌─────────────────┐
│ SQLite DB │
│ (claims.db) │
└─────────────────┘
How to Run
# 1. Clone and install dependencies
git clone <your-repo-url>
cd claims-ai-analyst
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# 2. Build the sample database
python3 db/create_db.py
# 3. Set your Anthropic API key
export ANTHROPIC_API_KEY=your-api-key-here # or paste it into the app's UI field
# 4. Run the app
streamlit run app.py
Then open the local URL Streamlit prints, and try a question like:
"Which claim types had the highest rejection rate?"
Example Questions
- Which claim types had the highest rejection rate?
- What is the average billed amount for inpatient claims?
- Which provider specialty has submitted the most claims?
- What are the top 3 rejection reasons this year?
- How much total revenue was paid out for pharmacy claims?
Harder / Edge-Case Questions (for demonstrating boundaries)
These aren't in the happy-path demo set on purpose - they're there to show the assistant handles imperfect questions gracefully instead of breaking. Good to run live if an interviewer wants to push on the tool:
- "Which provider should we be worried about?" - Ambiguous by design; there's no
riskcolumn. Claude has to decide what "worried about" means from the schema it has, and reasonably interprets it as rejection rate by provider, filtering out low-volume providers so the answer isn't skewed by a provider with only a handful of claims. (Verified: Provider Group 4, Orthopedics, comes back at a 19% rejection rate over 116 claims - a real, defensible number, not a hallucination.) - "What's driving the pharmacy rejections?" - Partially answerable. The schema has
rejection_reasonbut no true root-cause data, so Claude can break down rejection reasons by count (e.g., "Duplicate claim" is the top reason at 26 occurrences) but can't explain underlying causes beyond that. Good to narrate in an interview: "the assistant answers what the data supports and doesn't overreach into causal claims it can't back up." - "Update claim 105's status to Paid." - An out-of-scope write request. The MCP server's
run_sql_querytool rejects anything that isn't aSELECTbefore it reaches SQLite, so this fails safely with a clear message rather than silently doing nothing or erroring unpredictably. This is the best moment to demo the safety design if someone asks "what stops the AI from messing up the database."
Notes on Design Choices
- Read-only enforcement happens at the MCP tool level, not the prompt level. Prompt instructions telling Claude to "only write SELECT queries" are a suggestion; the server-side keyword check is the actual safety boundary. This matters as soon as an LLM is writing SQL against a real database.
- The schema is read live from the database via an MCP Resource, not hardcoded into the prompt. If the schema changes, the assistant adapts automatically.
- Result sets are capped at 200 rows before being returned to Claude, to keep token usage predictable and avoid flooding the model with raw data it doesn't need to summarize an answer.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。