File size: 2,305 Bytes
d13ece1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
77
78
"""
Debug application to identify ASGI error
"""

import os
from mcp_server import create_mcp_interface

# Hugging Face configuration
hf_token = os.environ.get("HF_TOKEN")
if hf_token:
    os.environ["HF_TOKEN"] = hf_token
os.environ["DATASET_ID"] = "HackathonCRA/2024"

def create_simple_interface():
    """Create a simplified interface to test"""
    import gradio as gr
    
    with gr.Blocks(title="Debug MCP") as demo:
        gr.Markdown("# Debug MCP Interface")
        
        with gr.Tab("Test"):
            test_btn = gr.Button("Test Button")
            test_output = gr.Markdown()
            
            def test_function():
                return "Test successful"
            
            test_btn.click(test_function, outputs=[test_output])
    
    return demo

def create_minimal_mcp_interface():
    """Create minimal MCP interface"""
    import gradio as gr
    from mcp_server import mcp_registry
    
    with gr.Blocks(title="MCP Debug") as demo:
        gr.Markdown("# MCP Resources Debug")
        
        with gr.Tab("Resources"):
            list_btn = gr.Button("List Resources")
            output = gr.Markdown()
            
            def list_resources():
                resources = mcp_registry.list_resources()
                result = "## MCP Resources\n\n"
                for uri, info in resources.items():
                    result += f"- `{uri}`: {info['description']}\n"
                return result
            
            list_btn.click(list_resources, outputs=[output])
    
    return demo

if __name__ == "__main__":
    print("Testing simple interface...")
    try:
        demo = create_simple_interface()
        print("βœ… Simple interface created")
    except Exception as e:
        print(f"❌ Simple interface error: {e}")
    
    print("Testing minimal MCP interface...")
    try:
        demo = create_minimal_mcp_interface()
        print("βœ… Minimal MCP interface created")
    except Exception as e:
        print(f"❌ Minimal MCP interface error: {e}")
    
    print("Testing full MCP interface...")
    try:
        demo = create_mcp_interface()
        print("βœ… Full MCP interface created")
    except Exception as e:
        print(f"❌ Full MCP interface error: {e}")
        import traceback
        traceback.print_exc()