Spaces:
Sleeping
Sleeping
Merge pull request #4 from humandotlearning/update-for-hf-space
Browse files- README.md +119 -47
- src/cred_db_mcp_server/main.py +4 -4
README.md
CHANGED
|
@@ -1,7 +1,125 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
**CredentialWatch** is a proactive healthcare credential management system built for the **Hugging Face MCP 1st Birthday / Gradio Agents Hackathon**. It leverages the **Model Context Protocol (MCP)**, **LangGraph** agents, **Gradio**, and **Modal** to unify fragmented credential data and alert on upcoming expiries.
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
## 🎯 Project Goal
|
| 6 |
|
| 7 |
CredentialWatch transforms messy, decentralized provider data (state licenses, board certifications, DEA numbers) into:
|
|
@@ -58,52 +176,6 @@ The server exposes the following MCP tools (via Gradio's MCP support):
|
|
| 58 |
* Returns provider info + all credentials + alerts.
|
| 59 |
* *Usage*: Context retrieval for user queries.
|
| 60 |
|
| 61 |
-
## 🚀 Getting Started
|
| 62 |
-
|
| 63 |
-
### Prerequisites
|
| 64 |
-
|
| 65 |
-
* **Python 3.11+**
|
| 66 |
-
* **uv** (recommended) or `pip`
|
| 67 |
-
* Access to the **Credential API Backend** (running locally or on Modal).
|
| 68 |
-
|
| 69 |
-
### Installation
|
| 70 |
-
|
| 71 |
-
1. Clone the repository:
|
| 72 |
-
```bash
|
| 73 |
-
git clone https://github.com/your-username/credential-watch-cred-db-mcp.git
|
| 74 |
-
cd credential-watch-cred-db-mcp
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
2. Install dependencies using `uv`:
|
| 78 |
-
```bash
|
| 79 |
-
uv sync
|
| 80 |
-
```
|
| 81 |
-
Or with `pip`:
|
| 82 |
-
```bash
|
| 83 |
-
pip install -e .
|
| 84 |
-
```
|
| 85 |
-
|
| 86 |
-
### Configuration
|
| 87 |
-
|
| 88 |
-
The server requires the backend API URL to be configured. Create a `.env` file in the root directory:
|
| 89 |
-
|
| 90 |
-
```env
|
| 91 |
-
# URL of the backend Credential API service
|
| 92 |
-
CRED_API_BASE_URL=http://localhost:8000
|
| 93 |
-
```
|
| 94 |
-
|
| 95 |
-
### Running the Server
|
| 96 |
-
|
| 97 |
-
Start the Gradio MCP server:
|
| 98 |
-
|
| 99 |
-
```bash
|
| 100 |
-
uv run src/cred_db_mcp_server/main.py
|
| 101 |
-
```
|
| 102 |
-
|
| 103 |
-
The server will launch and:
|
| 104 |
-
1. Open a Gradio UI in your browser (usually `http://127.0.0.1:7860`) where you can manually test the tools.
|
| 105 |
-
2. Expose the MCP endpoints via SSE for the agent to connect to.
|
| 106 |
-
|
| 107 |
## 🧪 Testing
|
| 108 |
|
| 109 |
Run the unit tests using `pytest`:
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: CredentialWatch MCP Server
|
| 3 |
+
emoji: 🩺
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
python_version: 3.11
|
| 8 |
+
sdk_version: 6.0.1
|
| 9 |
+
app_file: app.py
|
| 10 |
+
fullWidth: true
|
| 11 |
+
short_description: "Gradio MCP server exposing healthcare credential tools."
|
| 12 |
+
tags:
|
| 13 |
+
- mcp
|
| 14 |
+
- gradio
|
| 15 |
+
- tools
|
| 16 |
+
- healthcare
|
| 17 |
+
pinned: false
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# CredentialWatch MCP Server
|
| 21 |
|
| 22 |
**CredentialWatch** is a proactive healthcare credential management system built for the **Hugging Face MCP 1st Birthday / Gradio Agents Hackathon**. It leverages the **Model Context Protocol (MCP)**, **LangGraph** agents, **Gradio**, and **Modal** to unify fragmented credential data and alert on upcoming expiries.
|
| 23 |
|
| 24 |
+
## Hugging Face Space
|
| 25 |
+
|
| 26 |
+
This repository is designed to run as a **Gradio Space**.
|
| 27 |
+
|
| 28 |
+
- SDK: Gradio (`sdk: gradio` in the README header)
|
| 29 |
+
- Entry file: `app.py` (set via `app_file` in the YAML header)
|
| 30 |
+
- Python: 3.11+ (pinned with `python_version`)
|
| 31 |
+
|
| 32 |
+
When you push this repo to a Space with SDK = **Gradio**, the UI and the MCP server will be started automatically.
|
| 33 |
+
|
| 34 |
+
### Configuration
|
| 35 |
+
|
| 36 |
+
The server requires the backend Credential API URL to be configured. In your Space settings (or local `.env` file), add:
|
| 37 |
+
|
| 38 |
+
```env
|
| 39 |
+
CRED_API_BASE_URL=http://localhost:8000 # Replace with actual backend URL
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## MCP Server
|
| 43 |
+
|
| 44 |
+
This Space exposes its tools via **Model Context Protocol (MCP)** using Gradio.
|
| 45 |
+
|
| 46 |
+
### How MCP is enabled
|
| 47 |
+
|
| 48 |
+
In `app.py` we:
|
| 49 |
+
|
| 50 |
+
- install Gradio with MCP support: `pip install "gradio[mcp]"`
|
| 51 |
+
- define typed Python functions with docstrings
|
| 52 |
+
- launch the app with MCP support:
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
demo.launch(mcp_server=True)
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### MCP endpoints
|
| 59 |
+
|
| 60 |
+
When the Space is running, Gradio exposes:
|
| 61 |
+
|
| 62 |
+
- MCP SSE endpoint: `https://<space-host>/gradio_api/mcp/sse`
|
| 63 |
+
- MCP schema: `https://<space-host>/gradio_api/mcp/schema`
|
| 64 |
+
|
| 65 |
+
## Using this Space from an MCP client
|
| 66 |
+
|
| 67 |
+
### Easiest: Hugging Face MCP Server (no manual config)
|
| 68 |
+
|
| 69 |
+
1. Go to your HF **MCP settings**: https://huggingface.co/settings/mcp
|
| 70 |
+
2. Add this Space under **Spaces Tools** (look for the MCP badge on the Space).
|
| 71 |
+
3. Restart your MCP client (VS Code, Cursor, Claude Code, etc.).
|
| 72 |
+
4. The tools from this Space will appear as MCP tools and can be called directly.
|
| 73 |
+
|
| 74 |
+
### Manual config (generic MCP client using mcp-remote)
|
| 75 |
+
|
| 76 |
+
If your MCP client uses a JSON config, you can point it to the SSE endpoint via `mcp-remote`:
|
| 77 |
+
|
| 78 |
+
```jsonc
|
| 79 |
+
{
|
| 80 |
+
"mcpServers": {
|
| 81 |
+
"credentialwatch": {
|
| 82 |
+
"command": "npx",
|
| 83 |
+
"args": [
|
| 84 |
+
"mcp-remote",
|
| 85 |
+
"https://<space-host>/gradio_api/mcp/sse"
|
| 86 |
+
]
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
Replace `<space-host>` with the full URL of your Space.
|
| 93 |
+
|
| 94 |
+
## Local development
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
# 1. Install deps
|
| 98 |
+
uv sync
|
| 99 |
+
# or
|
| 100 |
+
pip install -r requirements.txt
|
| 101 |
+
|
| 102 |
+
# 2. Run locally
|
| 103 |
+
uv run python app.py
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
The local server will be available at http://127.0.0.1:7860, and MCP at http://127.0.0.1:7860/gradio_api/mcp/sse.
|
| 107 |
+
|
| 108 |
+
## Deploying to Hugging Face Spaces
|
| 109 |
+
|
| 110 |
+
1. Create a new Space with SDK = **Gradio**.
|
| 111 |
+
2. Push this repo to the Space (Git or `huggingface_hub`).
|
| 112 |
+
3. Ensure the YAML header in `README.md` is present and correct.
|
| 113 |
+
4. Wait for the Space to build and start — it should show an **MCP badge** automatically.
|
| 114 |
+
|
| 115 |
+
## Troubleshooting
|
| 116 |
+
|
| 117 |
+
- **Configuration error**: Verify `sdk`, `app_file`, and `python_version` in the YAML header. The header must be the first thing in the file (no blank lines before `---`).
|
| 118 |
+
- **MCP badge missing**: Check that your app calls `demo.launch(mcp_server=True)` and confirm the Space is public.
|
| 119 |
+
- **LFS issues**: Ensure `README.md` is NOT tracked via Git LFS.
|
| 120 |
+
|
| 121 |
+
---
|
| 122 |
+
|
| 123 |
## 🎯 Project Goal
|
| 124 |
|
| 125 |
CredentialWatch transforms messy, decentralized provider data (state licenses, board certifications, DEA numbers) into:
|
|
|
|
| 176 |
* Returns provider info + all credentials + alerts.
|
| 177 |
* *Usage*: Context retrieval for user queries.
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
## 🧪 Testing
|
| 180 |
|
| 181 |
Run the unit tests using `pytest`:
|
src/cred_db_mcp_server/main.py
CHANGED
|
@@ -20,7 +20,7 @@ def create_demo():
|
|
| 20 |
inputs=[gr.Textbox(label="NPI")],
|
| 21 |
outputs=gr.JSON(label="Provider Data"),
|
| 22 |
description="Syncs a provider's data from the NPI registry.",
|
| 23 |
-
|
| 24 |
)
|
| 25 |
|
| 26 |
# Tool 2: add_or_update_credential
|
|
@@ -35,7 +35,7 @@ def create_demo():
|
|
| 35 |
],
|
| 36 |
outputs=gr.JSON(label="Credential Data"),
|
| 37 |
description="Adds or updates a credential for a provider.",
|
| 38 |
-
|
| 39 |
)
|
| 40 |
|
| 41 |
# Tool 3: list_expiring_credentials
|
|
@@ -48,7 +48,7 @@ def create_demo():
|
|
| 48 |
],
|
| 49 |
outputs=gr.JSON(label="Expiring Credentials"),
|
| 50 |
description="Lists credentials expiring within a certain number of days.",
|
| 51 |
-
|
| 52 |
)
|
| 53 |
|
| 54 |
# Tool 4: get_provider_snapshot
|
|
@@ -60,7 +60,7 @@ def create_demo():
|
|
| 60 |
],
|
| 61 |
outputs=gr.JSON(label="Provider Snapshot"),
|
| 62 |
description="Gets a snapshot of a provider's data including credentials and alerts.",
|
| 63 |
-
|
| 64 |
)
|
| 65 |
|
| 66 |
demo = gr.TabbedInterface(
|
|
|
|
| 20 |
inputs=[gr.Textbox(label="NPI")],
|
| 21 |
outputs=gr.JSON(label="Provider Data"),
|
| 22 |
description="Syncs a provider's data from the NPI registry.",
|
| 23 |
+
flagging_mode="never"
|
| 24 |
)
|
| 25 |
|
| 26 |
# Tool 2: add_or_update_credential
|
|
|
|
| 35 |
],
|
| 36 |
outputs=gr.JSON(label="Credential Data"),
|
| 37 |
description="Adds or updates a credential for a provider.",
|
| 38 |
+
flagging_mode="never"
|
| 39 |
)
|
| 40 |
|
| 41 |
# Tool 3: list_expiring_credentials
|
|
|
|
| 48 |
],
|
| 49 |
outputs=gr.JSON(label="Expiring Credentials"),
|
| 50 |
description="Lists credentials expiring within a certain number of days.",
|
| 51 |
+
flagging_mode="never"
|
| 52 |
)
|
| 53 |
|
| 54 |
# Tool 4: get_provider_snapshot
|
|
|
|
| 60 |
],
|
| 61 |
outputs=gr.JSON(label="Provider Snapshot"),
|
| 62 |
description="Gets a snapshot of a provider's data including credentials and alerts.",
|
| 63 |
+
flagging_mode="never"
|
| 64 |
)
|
| 65 |
|
| 66 |
demo = gr.TabbedInterface(
|