Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -659,84 +659,132 @@ def format_validation_summary(result: dict) -> str:
|
|
| 659 |
# Default URLs for testing
|
| 660 |
DEFAULT_URLS = """https://huggingface.co/spaces/abidlabs/mcp-tools"""
|
| 661 |
|
| 662 |
-
# Create Gradio interfaces with
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
)
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
)
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 740 |
|
| 741 |
if __name__ == "__main__":
|
| 742 |
demo.launch(mcp_server=True)
|
|
|
|
| 659 |
# Default URLs for testing
|
| 660 |
DEFAULT_URLS = """https://huggingface.co/spaces/abidlabs/mcp-tools"""
|
| 661 |
|
| 662 |
+
# Create Gradio interfaces with vertical layout and better organization
|
| 663 |
+
with gr.Blocks(title="🚀 MCP Server Health Monitor") as demo:
|
| 664 |
+
gr.Markdown("# 🚀 MCP Server Health Monitor")
|
| 665 |
+
gr.Markdown("Monitor and analyze Hugging Face Spaces configured as MCP servers")
|
| 666 |
+
|
| 667 |
+
with gr.Tabs():
|
| 668 |
+
# Multi-Server Monitor Tab
|
| 669 |
+
with gr.Tab("📊 Multi-Server Monitor"):
|
| 670 |
+
gr.Markdown("### Monitor multiple MCP servers simultaneously")
|
| 671 |
+
|
| 672 |
+
with gr.Column():
|
| 673 |
+
multi_input = gr.Textbox(
|
| 674 |
+
label="Server URLs (one per line)",
|
| 675 |
+
lines=5,
|
| 676 |
+
value=DEFAULT_URLS,
|
| 677 |
+
placeholder="Enter HF Space URLs, one per line\nExample:\nhttps://huggingface.co/spaces/abidlabs/mcp-tools\nhttps://user-space.hf.space"
|
| 678 |
+
)
|
| 679 |
+
multi_submit = gr.Button("🔍 Monitor Servers", variant="primary", size="lg")
|
| 680 |
+
|
| 681 |
+
with gr.Column():
|
| 682 |
+
multi_md = gr.Markdown(label="Summary Report")
|
| 683 |
+
|
| 684 |
+
with gr.Column():
|
| 685 |
+
multi_json = gr.JSON(label="Detailed JSON Data")
|
| 686 |
+
|
| 687 |
+
multi_submit.click(
|
| 688 |
+
fn=monitor_multiple_servers,
|
| 689 |
+
inputs=multi_input,
|
| 690 |
+
outputs=[multi_md, multi_json]
|
| 691 |
+
)
|
| 692 |
+
|
| 693 |
+
# Single Server Health Tab
|
| 694 |
+
with gr.Tab("🏥 Single Server Health"):
|
| 695 |
+
gr.Markdown("### Check health of a single MCP server")
|
| 696 |
+
|
| 697 |
+
with gr.Column():
|
| 698 |
+
single_input = gr.Textbox(
|
| 699 |
+
label="Server URL",
|
| 700 |
+
value="https://huggingface.co/spaces/abidlabs/mcp-tools",
|
| 701 |
+
placeholder="Enter HF Space URL (any format supported)"
|
| 702 |
+
)
|
| 703 |
+
single_submit = gr.Button("🩺 Check Health", variant="primary", size="lg")
|
| 704 |
+
|
| 705 |
+
with gr.Column():
|
| 706 |
+
single_md = gr.Markdown(label="Health Summary")
|
| 707 |
+
|
| 708 |
+
with gr.Column():
|
| 709 |
+
single_json = gr.JSON(label="Detailed JSON Data")
|
| 710 |
+
|
| 711 |
+
single_submit.click(
|
| 712 |
+
fn=check_single_server_health,
|
| 713 |
+
inputs=single_input,
|
| 714 |
+
outputs=[single_md, single_json]
|
| 715 |
+
)
|
| 716 |
+
|
| 717 |
+
# Tools Discovery Tab
|
| 718 |
+
with gr.Tab("🔧 Tools Discovery"):
|
| 719 |
+
gr.Markdown("### Discover available MCP tools from a server")
|
| 720 |
+
|
| 721 |
+
with gr.Column():
|
| 722 |
+
tools_input = gr.Textbox(
|
| 723 |
+
label="Server URL",
|
| 724 |
+
value="https://abidlabs-mcp-tools.hf.space",
|
| 725 |
+
placeholder="Enter HF Space URL to analyze for MCP tools"
|
| 726 |
+
)
|
| 727 |
+
tools_submit = gr.Button("🛠️ Discover Tools", variant="primary", size="lg")
|
| 728 |
+
|
| 729 |
+
with gr.Column():
|
| 730 |
+
tools_md = gr.Markdown(label="Tools Summary")
|
| 731 |
+
|
| 732 |
+
with gr.Column():
|
| 733 |
+
tools_json = gr.JSON(label="Detailed JSON Data")
|
| 734 |
+
|
| 735 |
+
tools_submit.click(
|
| 736 |
+
fn=discover_server_tools,
|
| 737 |
+
inputs=tools_input,
|
| 738 |
+
outputs=[tools_md, tools_json]
|
| 739 |
+
)
|
| 740 |
+
|
| 741 |
+
# MCP Validator Tab
|
| 742 |
+
with gr.Tab("✅ MCP Validator"):
|
| 743 |
+
gr.Markdown("### Validate if a URL is a working MCP endpoint")
|
| 744 |
+
|
| 745 |
+
with gr.Column():
|
| 746 |
+
validator_input = gr.Textbox(
|
| 747 |
+
label="URL to Validate",
|
| 748 |
+
value="https://huggingface.co/spaces/abidlabs/mcp-tools",
|
| 749 |
+
placeholder="Enter URL to validate as MCP endpoint"
|
| 750 |
+
)
|
| 751 |
+
validator_submit = gr.Button("✅ Validate Endpoint", variant="primary", size="lg")
|
| 752 |
+
|
| 753 |
+
with gr.Column():
|
| 754 |
+
validator_md = gr.Markdown(label="Validation Summary")
|
| 755 |
+
|
| 756 |
+
with gr.Column():
|
| 757 |
+
validator_json = gr.JSON(label="Detailed JSON Data")
|
| 758 |
+
|
| 759 |
+
validator_submit.click(
|
| 760 |
+
fn=validate_mcp_endpoint,
|
| 761 |
+
inputs=validator_input,
|
| 762 |
+
outputs=[validator_md, validator_json]
|
| 763 |
+
)
|
| 764 |
+
|
| 765 |
+
# URL Parser Tab
|
| 766 |
+
with gr.Tab("🔍 URL Parser"):
|
| 767 |
+
gr.Markdown("### Parse and analyze HuggingFace URL formats")
|
| 768 |
+
|
| 769 |
+
with gr.Column():
|
| 770 |
+
parser_input = gr.Textbox(
|
| 771 |
+
label="URL to Parse",
|
| 772 |
+
value="https://huggingface.co/spaces/abidlabs/mcp-tools",
|
| 773 |
+
placeholder="Enter any HF Space URL format to parse"
|
| 774 |
+
)
|
| 775 |
+
parser_submit = gr.Button("🔍 Parse URL", variant="primary", size="lg")
|
| 776 |
+
|
| 777 |
+
with gr.Column():
|
| 778 |
+
parser_md = gr.Markdown(label="Parsing Summary")
|
| 779 |
+
|
| 780 |
+
with gr.Column():
|
| 781 |
+
parser_json = gr.JSON(label="Detailed JSON Data")
|
| 782 |
+
|
| 783 |
+
parser_submit.click(
|
| 784 |
+
fn=parse_huggingface_url_with_summary,
|
| 785 |
+
inputs=parser_input,
|
| 786 |
+
outputs=[parser_md, parser_json]
|
| 787 |
+
)
|
| 788 |
|
| 789 |
if __name__ == "__main__":
|
| 790 |
demo.launch(mcp_server=True)
|