Spaces:
Sleeping
Sleeping
File size: 2,506 Bytes
8e07f8c f09a8be 8e07f8c f09a8be 8e07f8c 108bca8 8e07f8c 108bca8 8e07f8c 108bca8 8e07f8c 108bca8 8e07f8c f09a8be 8e07f8c f09a8be 8e07f8c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import gradio as gr
from .tools import (
sync_provider_from_npi,
add_or_update_credential,
list_expiring_credentials,
get_provider_snapshot
)
def create_demo():
"""
Creates the Gradio interface for the MCP server.
"""
# Create the Gradio interface
# We use a TabbedInterface to organize the tools if accessed via UI,
# but primarily they are exposed as MCP tools.
# Tool 1: sync_provider_from_npi
iface_sync = gr.Interface(
fn=sync_provider_from_npi,
inputs=[gr.Textbox(label="NPI")],
outputs=gr.JSON(label="Provider Data"),
description="Syncs a provider's data from the NPI registry.",
flagging_mode="never"
)
# Tool 2: add_or_update_credential
iface_add_cred = gr.Interface(
fn=add_or_update_credential,
inputs=[
gr.Number(label="Provider ID", precision=0),
gr.Textbox(label="Type"),
gr.Textbox(label="Issuer"),
gr.Textbox(label="Number"),
gr.Textbox(label="Expiry Date (YYYY-MM-DD)"),
],
outputs=gr.JSON(label="Credential Data"),
description="Adds or updates a credential for a provider.",
flagging_mode="never"
)
# Tool 3: list_expiring_credentials
iface_expiring = gr.Interface(
fn=list_expiring_credentials,
inputs=[
gr.Number(label="Window Days", precision=0),
gr.Textbox(label="Department", value=None),
gr.Textbox(label="Location", value=None),
],
outputs=gr.JSON(label="Expiring Credentials"),
description="Lists credentials expiring within a certain number of days.",
flagging_mode="never"
)
# Tool 4: get_provider_snapshot
iface_snapshot = gr.Interface(
fn=get_provider_snapshot,
inputs=[
gr.Number(label="Provider ID", precision=0, value=None),
gr.Textbox(label="NPI", value=None),
],
outputs=gr.JSON(label="Provider Snapshot"),
description="Gets a snapshot of a provider's data including credentials and alerts.",
flagging_mode="never"
)
demo = gr.TabbedInterface(
[iface_sync, iface_add_cred, iface_expiring, iface_snapshot],
["Sync Provider", "Add/Update Credential", "List Expiring", "Provider Snapshot"]
)
return demo
if __name__ == "__main__":
demo = create_demo()
# Launch with mcp_server=True to enable MCP endpoints
demo.launch(mcp_server=True)
|