NLarchive commited on
Commit
1d203c6
·
verified ·
1 Parent(s): 9abd46e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +126 -78
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 both markdown and JSON outputs
663
- demo_multiple = gr.Interface(
664
- fn=monitor_multiple_servers,
665
- inputs=gr.Textbox(
666
- label="Server URLs (one per line)",
667
- lines=3,
668
- value=DEFAULT_URLS,
669
- placeholder="Enter HF Space URLs, one per line"
670
- ),
671
- outputs=[
672
- gr.Markdown(label="Summary Report"),
673
- gr.JSON(label="Detailed JSON")
674
- ],
675
- title="📊 Multiple Servers Monitor"
676
- )
677
-
678
- demo_single = gr.Interface(
679
- fn=check_single_server_health,
680
- inputs=gr.Textbox(
681
- label="Server URL",
682
- placeholder="Enter HF Space URL",
683
- value="https://huggingface.co/spaces/abidlabs/mcp-tools"
684
- ),
685
- outputs=[
686
- gr.Markdown(label="Health Summary"),
687
- gr.JSON(label="Detailed JSON")
688
- ],
689
- title="🏥 Server Health Check"
690
- )
691
-
692
- demo_tools = gr.Interface(
693
- fn=discover_server_tools,
694
- inputs=gr.Textbox(
695
- label="Server URL",
696
- placeholder="Enter HF Space URL to discover tools",
697
- value="https://abidlabs-mcp-tools.hf.space"
698
- ),
699
- outputs=[
700
- gr.Markdown(label="Tools Summary"),
701
- gr.JSON(label="Detailed JSON")
702
- ],
703
- title=" Tools Discovery"
704
- )
705
-
706
- demo_validator = gr.Interface(
707
- fn=validate_mcp_endpoint,
708
- inputs=gr.Textbox(
709
- label="URL to Validate",
710
- placeholder="Enter URL to validate as MCP endpoint",
711
- value="https://huggingface.co/spaces/abidlabs/mcp-tools"
712
- ),
713
- outputs=[
714
- gr.Markdown(label="Validation Summary"),
715
- gr.JSON(label="Detailed JSON")
716
- ],
717
- title="✅ MCP Validator"
718
- )
719
-
720
- demo_parser = gr.Interface(
721
- fn=parse_huggingface_url_with_summary,
722
- inputs=gr.Textbox(
723
- label="URL to Parse",
724
- placeholder="Enter any HF Space URL format",
725
- value="https://huggingface.co/spaces/abidlabs/mcp-tools"
726
- ),
727
- outputs=[
728
- gr.Markdown(label="Parsing Summary"),
729
- gr.JSON(label="Detailed JSON")
730
- ],
731
- title="🔍 URL Parser"
732
- )
733
-
734
- # Combine interfaces into tabbed interface
735
- demo = gr.TabbedInterface(
736
- [demo_multiple, demo_single, demo_tools, demo_validator, demo_parser],
737
- ["📊 Multi-Server", "🏥 Single Server", "🔧 Tools Discovery", "✅ MCP Validator", "🔍 URL Parser"],
738
- title="🚀 MCP Server Health Monitor"
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)