visproj commited on
Commit
82b2148
Β·
verified Β·
1 Parent(s): 0d10048

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +275 -157
README.md CHANGED
@@ -1,157 +1,275 @@
1
- # Healthcare API MCP
2
-
3
- A Model Context Protocol (MCP) server providing access to public healthcare data APIs including FDA adverse events, clinical guidelines, and Medicare pricing information.
4
-
5
- ## Features
6
-
7
- ### OpenFDA Provider (14 tools)
8
- - **Drug Adverse Events**: Query FAERS database for medication safety information
9
- - **Drug Labels**: Search FDA-approved drug labeling information
10
- - **Drug Recalls**: Find drug recall and enforcement reports
11
- - **NDC Directory**: Look up National Drug Codes
12
- - **Drugs@FDA**: Search approved drug products
13
- - **Device Events & Recalls**: Medical device adverse events and recalls
14
- - **Device Classifications**: Device classification database
15
- - **510(k) & PMA**: Device clearances and approvals
16
- - **Food Recalls & Events**: Food safety information
17
-
18
- ### Clinical Guidelines Provider (5 tools)
19
- - **Preventive Recommendations**: USPSTF evidence-based screening guidelines
20
- - **Vaccine Schedule**: CDC immunization recommendations
21
- - **Search Guidelines**: Find guidelines by condition or screening type
22
- - **Lifestyle Recommendations**: Evidence-based wellness guidance
23
- - **Care Plan Generator**: Comprehensive 6-month care planning
24
-
25
- ### CMS Pricing Provider (5 tools)
26
- - **Medicare Fee Schedule**: Get reimbursement rates by HCPCS code
27
- - **Procedure Cost Estimates**: Typical cost ranges by procedure
28
- - **Search Procedure Codes**: Find HCPCS/CPT codes
29
- - **Facility Cost Comparison**: Compare prices across facilities
30
- - **Out-of-Pocket Estimates**: Calculate patient responsibility
31
-
32
- ## Installation
33
-
34
- ```bash
35
- pip install -r requirements.txt
36
- ```
37
-
38
- ## Configuration
39
-
40
- Set environment variables to configure the server:
41
-
42
- ```bash
43
- # Enable specific providers (comma-separated)
44
- export ENABLED_PROVIDERS="openfda,clinical_guidelines,cms_pricing"
45
-
46
- # Optional: OpenFDA API key for higher rate limits
47
- export OPENFDA_API_KEY="your_api_key_here"
48
-
49
- # Logging level
50
- export LOG_LEVEL="INFO"
51
- ```
52
-
53
- ## Usage
54
-
55
- ### Run as MCP Server (stdio)
56
-
57
- ```bash
58
- python -m healthcare_api_mcp
59
- ```
60
-
61
- ### Use with Claude Desktop
62
-
63
- Add to your Claude Desktop config (`claude_desktop_config.json`):
64
-
65
- ```json
66
- {
67
- "mcpServers": {
68
- "healthcare-api": {
69
- "command": "python",
70
- "args": ["-m", "healthcare_api_mcp"],
71
- "env": {
72
- "ENABLED_PROVIDERS": "openfda,clinical_guidelines,cms_pricing"
73
- }
74
- }
75
- }
76
- }
77
- ```
78
-
79
- ### Filter Providers
80
-
81
- Run only specific providers:
82
-
83
- ```bash
84
- # Only FDA data
85
- ENABLED_PROVIDERS=openfda python -m healthcare_api_mcp
86
-
87
- # Only clinical guidelines
88
- ENABLED_PROVIDERS=clinical_guidelines python -m healthcare_api_mcp
89
-
90
- # FDA and CMS pricing
91
- ENABLED_PROVIDERS=openfda,cms_pricing python -m healthcare_api_mcp
92
- ```
93
-
94
- ## Tool Naming
95
-
96
- All tools are namespaced by provider:
97
- - OpenFDA: `openfda_*` (e.g., `openfda_search_adverse_events`)
98
- - Clinical Guidelines: `clinical_*` (e.g., `clinical_get_vaccine_schedule`)
99
- - CMS Pricing: `cms_*` (e.g., `cms_get_medicare_fee`)
100
-
101
- ## Example Queries
102
-
103
- ### Check Drug Safety
104
- ```
105
- Agent: "Check if Simvastatin has any FDA recalls"
106
- β†’ Uses: openfda_search_drug_recalls
107
- ```
108
-
109
- ### Get Preventive Care Recommendations
110
- ```
111
- Agent: "What screenings does a 55-year-old female need?"
112
- β†’ Uses: clinical_get_preventive_recommendations
113
- ```
114
-
115
- ### Estimate Procedure Cost
116
- ```
117
- Agent: "How much does a colonoscopy cost with Medicare?"
118
- β†’ Uses: cms_estimate_procedure_cost, cms_estimate_out_of_pocket
119
- ```
120
-
121
- ## Data Sources
122
-
123
- - **OpenFDA**: Real-time access to FDA's public APIs
124
- - **Clinical Guidelines**: Evidence-based recommendations from USPSTF, CDC, AHRQ
125
- - **CMS Pricing**: Sample data based on Medicare fee schedules (2024)
126
-
127
- ## Architecture
128
-
129
- ```
130
- healthcare_api_mcp/
131
- β”œβ”€β”€ server.py # Main MCP server with stdio
132
- β”œβ”€β”€ config.py # Configuration management
133
- β”œβ”€β”€ core/
134
- β”‚ β”œβ”€β”€ base_provider.py # Abstract provider base class
135
- β”‚ β”œβ”€β”€ decorators.py # @safe_json_return, @with_retry
136
- β”‚ └── http_client.py # Shared HTTP client factory
137
- └── providers/
138
- β”œβ”€β”€ openfda_provider.py # FDA APIs
139
- β”œβ”€β”€ clinical_guidelines_provider.py
140
- └── cms_pricing_provider.py
141
- ```
142
-
143
- ## Benefits
144
-
145
- βœ… **Zero duplication**: Shared utilities across all providers
146
- βœ… **Proper JSON returns**: All tools return JSON strings (no dict inconsistencies)
147
- βœ… **Modular**: Enable only the providers you need
148
- βœ… **Agent-friendly**: Standard MCP stdio protocol
149
- βœ… **Production-ready**: Error handling, retry logic, logging
150
-
151
- ## License
152
-
153
- Copyright (c) 2025. All Rights Reserved.
154
-
155
- ## HuggingFace MCP 1st Birthday Hackathon
156
-
157
- This project is submitted for Track 1 of the HuggingFace MCP 1st Birthday Hackathon.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Healthcare API MCP
3
+ emoji: πŸ₯
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
9
+
10
+ # Healthcare API MCP Server
11
+
12
+ A Model Context Protocol (MCP) server providing structured access to public healthcare data APIs using **HTTP streaming** (no SSE).
13
+
14
+ ## 🎯 Features
15
+
16
+ ### OpenFDA Provider (14 tools)
17
+ - Drug adverse events (FAERS database)
18
+ - FDA drug labels and recalls
19
+ - NDC directory and Drugs@FDA
20
+ - Device safety data
21
+ - Food safety data
22
+
23
+ ### Clinical Guidelines Provider (5 tools)
24
+ - USPSTF preventive care recommendations
25
+ - CDC vaccine schedules
26
+ - Evidence-based lifestyle recommendations
27
+ - Care plan generation
28
+
29
+ ### CMS Pricing Provider (5 tools)
30
+ - Medicare fee schedules
31
+ - Procedure cost estimates
32
+ - Facility cost comparisons
33
+ - Out-of-pocket estimates
34
+
35
+ **Total: 24 healthcare tools**
36
+
37
+ ## πŸ“‘ API Endpoints
38
+
39
+ ### List Tools
40
+ ```bash
41
+ GET /mcp/tools
42
+ ```
43
+
44
+ Returns all available tools with descriptions.
45
+
46
+ ### Call Tool (Standard)
47
+ ```bash
48
+ POST /mcp/call
49
+ Content-Type: application/json
50
+
51
+ {
52
+ "tool": "openfda_get_adverse_event_summary",
53
+ "arguments": {
54
+ "drug_name": "Aspirin"
55
+ }
56
+ }
57
+ ```
58
+
59
+ ### Stream Tool Results (HTTP Streaming)
60
+ ```bash
61
+ POST /mcp/stream
62
+ Content-Type: application/json
63
+
64
+ {
65
+ "tool": "openfda_fetch_adverse_events",
66
+ "arguments": {
67
+ "drug_name": "Aspirin",
68
+ "limit": 100
69
+ }
70
+ }
71
+ ```
72
+
73
+ Returns newline-delimited JSON (NDJSON) stream with chunked transfer encoding.
74
+
75
+ ## πŸš€ Usage
76
+
77
+ ### With curl
78
+
79
+ ```bash
80
+ # List tools
81
+ curl https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/tools
82
+
83
+ # Call a tool
84
+ curl -X POST https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/call \
85
+ -H "Content-Type: application/json" \
86
+ -d '{
87
+ "tool": "openfda_search_drug_recalls",
88
+ "arguments": {"query": "Aspirin", "limit": 5}
89
+ }'
90
+
91
+ # Stream results
92
+ curl -N -X POST https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/stream \
93
+ -H "Content-Type: application/json" \
94
+ -d '{
95
+ "tool": "openfda_fetch_adverse_events",
96
+ "arguments": {"drug_name": "Metformin", "limit": 50}
97
+ }'
98
+ ```
99
+
100
+ ### With Python
101
+
102
+ ```python
103
+ import httpx
104
+ import json
105
+
106
+ # Call a tool
107
+ async with httpx.AsyncClient() as client:
108
+ response = await client.post(
109
+ "https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/call",
110
+ json={
111
+ "tool": "clinical_get_preventive_recommendations",
112
+ "arguments": {"age": 55, "sex": "female"}
113
+ }
114
+ )
115
+ result = response.json()
116
+ print(result)
117
+
118
+ # Stream results
119
+ async with httpx.AsyncClient() as client:
120
+ async with client.stream(
121
+ "POST",
122
+ "https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/stream",
123
+ json={
124
+ "tool": "openfda_fetch_adverse_events",
125
+ "arguments": {"drug_name": "Simvastatin", "limit": 100}
126
+ }
127
+ ) as response:
128
+ async for line in response.aiter_lines():
129
+ if line:
130
+ data = json.loads(line)
131
+ print(data)
132
+ ```
133
+
134
+ ### With JavaScript/Node.js
135
+
136
+ ```javascript
137
+ // Call a tool
138
+ const response = await fetch('https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/call', {
139
+ method: 'POST',
140
+ headers: {'Content-Type': 'application/json'},
141
+ body: JSON.stringify({
142
+ tool: 'cms_estimate_procedure_cost',
143
+ arguments: {procedure_name: 'colonoscopy'}
144
+ })
145
+ });
146
+ const result = await response.json();
147
+ console.log(result);
148
+
149
+ // Stream results
150
+ const streamResponse = await fetch('https://YOUR_USERNAME-healthcare-api-mcp.hf.space/mcp/stream', {
151
+ method: 'POST',
152
+ headers: {'Content-Type': 'application/json'},
153
+ body: JSON.stringify({
154
+ tool: 'openfda_fetch_adverse_events',
155
+ arguments: {drug_name: 'Aspirin', limit: 50}
156
+ })
157
+ });
158
+
159
+ const reader = streamResponse.body.getReader();
160
+ const decoder = new TextDecoder();
161
+
162
+ while (true) {
163
+ const {done, value} = await reader.read();
164
+ if (done) break;
165
+
166
+ const lines = decoder.decode(value).split('\n');
167
+ for (const line of lines) {
168
+ if (line.trim()) {
169
+ const data = JSON.parse(line);
170
+ console.log(data);
171
+ }
172
+ }
173
+ }
174
+ ```
175
+
176
+ ## πŸ—οΈ Architecture
177
+
178
+ - **Protocol**: HTTP with chunked transfer encoding (no SSE)
179
+ - **Format**: JSON for requests/responses, NDJSON for streaming
180
+ - **Framework**: FastAPI + Uvicorn
181
+ - **Transport**: HTTP/1.1 streaming
182
+ - **Providers**: Factory pattern with modular providers
183
+
184
+ ## πŸ”§ Configuration
185
+
186
+ Environment variables (optional):
187
+
188
+ - `ENABLED_PROVIDERS`: Comma-separated list (default: all)
189
+ - `OPENFDA_API_KEY`: Optional for higher FDA rate limits
190
+ - `LOG_LEVEL`: DEBUG, INFO, WARNING, ERROR
191
+
192
+ ## πŸ“š Example Queries
193
+
194
+ **Check Drug Safety:**
195
+ ```bash
196
+ curl -X POST .../mcp/call -H "Content-Type: application/json" \
197
+ -d '{"tool": "openfda_get_adverse_event_summary", "arguments": {"drug_name": "Aspirin"}}'
198
+ ```
199
+
200
+ **Get Preventive Care Recommendations:**
201
+ ```bash
202
+ curl -X POST .../mcp/call -H "Content-Type: application/json" \
203
+ -d '{"tool": "clinical_get_preventive_recommendations", "arguments": {"age": 50, "sex": "female"}}'
204
+ ```
205
+
206
+ **Estimate Medical Costs:**
207
+ ```bash
208
+ curl -X POST .../mcp/call -H "Content-Type: application/json" \
209
+ -d '{"tool": "cms_estimate_procedure_cost", "arguments": {"procedure_name": "mri"}}'
210
+ ```
211
+
212
+ ## πŸ“Š Available Tools
213
+
214
+ See `/mcp/tools` endpoint for complete list with descriptions.
215
+
216
+ ### OpenFDA (14 tools)
217
+ - `openfda_get_adverse_event_summary`
218
+ - `openfda_fetch_adverse_events`
219
+ - `openfda_top_reactions`
220
+ - `openfda_search_drug_labels`
221
+ - `openfda_search_ndc`
222
+ - `openfda_search_drug_recalls`
223
+ - `openfda_search_drugs_fda`
224
+ - `openfda_search_device_events`
225
+ - `openfda_search_device_recalls`
226
+ - `openfda_search_device_classifications`
227
+ - `openfda_search_510k`
228
+ - `openfda_search_pma`
229
+ - `openfda_search_food_recalls`
230
+ - `openfda_search_food_events`
231
+
232
+ ### Clinical Guidelines (5 tools)
233
+ - `clinical_get_preventive_recommendations`
234
+ - `clinical_get_vaccine_schedule`
235
+ - `clinical_search_guidelines`
236
+ - `clinical_get_lifestyle_recommendations`
237
+ - `clinical_generate_care_plan`
238
+
239
+ ### CMS Pricing (5 tools)
240
+ - `cms_get_medicare_fee`
241
+ - `cms_estimate_procedure_cost`
242
+ - `cms_search_procedure_codes`
243
+ - `cms_compare_facility_costs`
244
+ - `cms_estimate_out_of_pocket`
245
+
246
+ ## πŸ”’ Security & Privacy
247
+
248
+ - βœ… Public APIs only (no PHI)
249
+ - βœ… No authentication required
250
+ - βœ… Rate limiting via OpenFDA API
251
+ - βœ… Stateless queries
252
+
253
+ ## πŸ“– Documentation
254
+
255
+ - [GitHub Repository](https://github.com/YOUR_USERNAME/healthcare_mcps)
256
+ - [Full Documentation](https://github.com/YOUR_USERNAME/healthcare_mcps/tree/main/healthcare_api_mcp)
257
+
258
+ ## πŸŽ‰ Hackathon
259
+
260
+ Built for **HuggingFace MCP 1st Birthday Hackathon - Track 1**
261
+
262
+ Demonstrates:
263
+ - HTTP streaming (no SSE)
264
+ - Factory pattern architecture
265
+ - Clean code principles
266
+ - Production-ready error handling
267
+ - Healthcare data integration
268
+
269
+ ## πŸ“ License
270
+
271
+ Copyright (c) 2025. All Rights Reserved.
272
+
273
+ ---
274
+
275
+ **HTTP Streaming | 24 Tools | No SSE | Production Ready**