Humanlearning commited on
Commit
2e51864
·
1 Parent(s): cfd07be

feat: Implement Gradio application with interactive query and expiry sweep, and configure MCP server support.

Browse files
README.md CHANGED
@@ -1,6 +1,109 @@
1
- # CredentialWatch Agent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- MCP-powered agent system for monitoring healthcare provider credentials. This system uses LangGraph to orchestrate workflows for checking credential expiry and answering interactive queries, leveraging Model Context Protocol (MCP) to connect to external data sources.
 
 
 
 
 
 
 
 
 
 
4
 
5
  ## Features
6
 
@@ -39,20 +142,6 @@ CRED_DB_MCP_URL=http://localhost:8002/sse
39
  ALERT_MCP_URL=http://localhost:8003/sse
40
  ```
41
 
42
- ## Running the Application
43
-
44
- To run the agent system with the Gradio UI using `uv`:
45
-
46
- ```bash
47
- uv run python src/credentialwatch_agent/main.py
48
- ```
49
- OR
50
- ```bash
51
- uv run -m credentialwatch_agent.main
52
- ```
53
-
54
- The UI will be available at `http://localhost:7860`.
55
-
56
  ## Architecture
57
 
58
  - **`src/credentialwatch_agent/agents/`**: Contains LangGraph workflow definitions.
 
1
+ ---
2
+ title: CredentialWatch MCP Server
3
+ emoji: 🩺
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: gradio
7
+ python_version: 3.10
8
+ sdk_version: 6.0.0
9
+ app_file: src/credentialwatch_agent/main.py
10
+ short_description: "MCP-enabled Gradio Space for healthcare credential monitoring."
11
+ tags:
12
+ - mcp
13
+ - gradio
14
+ - healthcare
15
+ - tools
16
+ pinned: false
17
+ ---
18
+
19
+ # CredentialWatch MCP Server
20
+
21
+ Agent-ready Gradio Space that exposes healthcare credential tools (lookups, expiry checks, risk scoring) over **Model Context Protocol (MCP)**.
22
+
23
+ ## Hugging Face Space
24
+
25
+ - **SDK**: Gradio
26
+ - **Entry file**: `src/credentialwatch_agent/main.py`
27
+ - **Python**: 3.10+
28
+
29
+ Deploy this repo as a Gradio Space and it will automatically serve both the web UI and an MCP server.
30
+
31
+ ## MCP Server
32
+
33
+ This Space exposes its tools via Model Context Protocol (MCP) using Gradio.
34
+
35
+ ### How MCP is enabled
36
+ In `src/credentialwatch_agent/main.py` we:
37
+ 1. Install Gradio with MCP support: `pip install "gradio[mcp]"`
38
+ 2. Define typed Python functions with docstrings
39
+ 3. Launch the app with MCP support:
40
+ ```python
41
+ demo.launch(mcp_server=True)
42
+ ```
43
+
44
+ Alternatively, you can set the environment variable:
45
+ ```bash
46
+ export GRADIO_MCP_SERVER=True
47
+ ```
48
+
49
+ ### MCP endpoints
50
+ When the Space is running, Gradio exposes:
51
+ - **MCP SSE endpoint**: `https://<space-host>/gradio_api/mcp/sse`
52
+ - **MCP schema**: `https://<space-host>/gradio_api/mcp/schema`
53
+
54
+ ## Using this Space from an MCP client
55
+
56
+ ### Easiest: Hugging Face MCP Server (no manual config)
57
+ 1. Go to your HF **MCP settings**: https://huggingface.co/settings/mcp
58
+ 2. Add this Space under **Spaces Tools** (look for the MCP badge on the Space).
59
+ 3. Restart your MCP client (VS Code, Cursor, Claude Code, etc.).
60
+ 4. The tools from this Space will appear as MCP tools and can be called directly.
61
+
62
+ ### Manual config (generic MCP client using mcp-remote)
63
+ If your MCP client uses a JSON config, you can point it to the SSE endpoint via `mcp-remote`:
64
+
65
+ ```jsonc
66
+ {
67
+ "mcpServers": {
68
+ "credentialwatch": {
69
+ "command": "npx",
70
+ "args": [
71
+ "mcp-remote",
72
+ "https://<space-host>/gradio_api/mcp/sse"
73
+ ]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+ Replace `<space-host>` with the full URL of your Space.
79
+
80
+ ## Local development
81
+
82
+ ```bash
83
+ # 1. Install deps
84
+ uv sync
85
+
86
+ # 2. Run locally
87
+ uv run python src/credentialwatch_agent/main.py
88
+ # or
89
+ GRADIO_MCP_SERVER=True uv run python src/credentialwatch_agent/main.py
90
+ ```
91
+
92
+ 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`.
93
+
94
+ ## Deploying to Hugging Face Spaces
95
 
96
+ 1. Create a new Space with SDK = **Gradio**.
97
+ 2. Push this repo to the Space (Git or `huggingface_hub`).
98
+ 3. Ensure the YAML header in `README.md` is present and correct.
99
+ 4. Wait for the Space to build and start — it should show an **MCP badge** automatically.
100
+
101
+ ## Troubleshooting
102
+
103
+ - **README.md location**: Must be at the repo root and named `README.md` (all caps).
104
+ - **YAML Header**: Must be the very first thing in the file, delimited by `---`.
105
+ - **Configuration Error**: Check `sdk`, `app_file`, and `python_version` in the YAML.
106
+ - **MCP Badge Missing**: Ensure `demo.launch(mcp_server=True)` is called or `GRADIO_MCP_SERVER=True` is set, and the Space is public.
107
 
108
  ## Features
109
 
 
142
  ALERT_MCP_URL=http://localhost:8003/sse
143
  ```
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  ## Architecture
146
 
147
  - **`src/credentialwatch_agent/agents/`**: Contains LangGraph workflow definitions.
pyproject.toml CHANGED
@@ -9,7 +9,7 @@ dependencies = [
9
  "langchain-openai>=0.0.5",
10
  "pydantic>=2.0.0",
11
  "mcp>=0.1.0",
12
- "gradio>=4.0.0",
13
  "python-dotenv>=1.0.0",
14
  "httpx>=0.25.0"
15
  ]
 
9
  "langchain-openai>=0.0.5",
10
  "pydantic>=2.0.0",
11
  "mcp>=0.1.0",
12
+ "gradio[mcp]>=4.0.0",
13
  "python-dotenv>=1.0.0",
14
  "httpx>=0.25.0"
15
  ]
src/credentialwatch_agent/__pycache__/main.cpython-313.pyc CHANGED
Binary files a/src/credentialwatch_agent/__pycache__/main.cpython-313.pyc and b/src/credentialwatch_agent/__pycache__/main.cpython-313.pyc differ
 
src/credentialwatch_agent/main.py CHANGED
@@ -105,7 +105,7 @@ if __name__ == "__main__":
105
 
106
  try:
107
  loop.run_until_complete(mcp_client.connect())
108
- demo.launch(server_name="0.0.0.0", server_port=7860)
109
  except KeyboardInterrupt:
110
  pass
111
  finally:
 
105
 
106
  try:
107
  loop.run_until_complete(mcp_client.connect())
108
+ demo.launch(server_name="0.0.0.0", server_port=7860, mcp_server=True)
109
  except KeyboardInterrupt:
110
  pass
111
  finally:
uv.lock CHANGED
@@ -338,7 +338,7 @@ name = "credentialwatch-agent"
338
  version = "0.1.0"
339
  source = { editable = "." }
340
  dependencies = [
341
- { name = "gradio" },
342
  { name = "httpx" },
343
  { name = "langchain-openai" },
344
  { name = "langgraph" },
@@ -349,7 +349,7 @@ dependencies = [
349
 
350
  [package.metadata]
351
  requires-dist = [
352
- { name = "gradio", specifier = ">=4.0.0" },
353
  { name = "httpx", specifier = ">=0.25.0" },
354
  { name = "langchain-openai", specifier = ">=0.0.5" },
355
  { name = "langgraph", specifier = ">=0.0.10" },
@@ -510,6 +510,12 @@ wheels = [
510
  { url = "https://files.pythonhosted.org/packages/09/21/27ae5f4b2191a5d58707fc610e67453781a2b948a675a7cf06c99497ffa1/gradio-6.0.1-py3-none-any.whl", hash = "sha256:0f98dc8b414a3f3773cbf3caf5a354507c8ae309ed8266e2f30ca9fa53f379b8", size = 21559963, upload-time = "2025-11-25T18:44:01.544Z" },
511
  ]
512
 
 
 
 
 
 
 
513
  [[package]]
514
  name = "gradio-client"
515
  version = "2.0.0"
 
338
  version = "0.1.0"
339
  source = { editable = "." }
340
  dependencies = [
341
+ { name = "gradio", extra = ["mcp"] },
342
  { name = "httpx" },
343
  { name = "langchain-openai" },
344
  { name = "langgraph" },
 
349
 
350
  [package.metadata]
351
  requires-dist = [
352
+ { name = "gradio", extras = ["mcp"], specifier = ">=4.0.0" },
353
  { name = "httpx", specifier = ">=0.25.0" },
354
  { name = "langchain-openai", specifier = ">=0.0.5" },
355
  { name = "langgraph", specifier = ">=0.0.10" },
 
510
  { url = "https://files.pythonhosted.org/packages/09/21/27ae5f4b2191a5d58707fc610e67453781a2b948a675a7cf06c99497ffa1/gradio-6.0.1-py3-none-any.whl", hash = "sha256:0f98dc8b414a3f3773cbf3caf5a354507c8ae309ed8266e2f30ca9fa53f379b8", size = 21559963, upload-time = "2025-11-25T18:44:01.544Z" },
511
  ]
512
 
513
+ [package.optional-dependencies]
514
+ mcp = [
515
+ { name = "mcp" },
516
+ { name = "pydantic" },
517
+ ]
518
+
519
  [[package]]
520
  name = "gradio-client"
521
  version = "2.0.0"