Spaces:
Sleeping
Sleeping
| """ | |
| 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() | |