Spaces:
Sleeping
Sleeping
| # app.py | |
| import gradio as gr | |
| from fastapi import FastAPI | |
| from server import mcp # Importa tu servidor MCP existente | |
| # Crea la aplicación FastAPI | |
| app = FastAPI(title="MCP Server Dashboard") | |
| # Interfaz simple de Gradio | |
| def create_simple_interface(): | |
| with gr.Blocks(title="MCP Server Monitor") as demo: | |
| gr.Markdown("## MCP Server Status") | |
| gr.Markdown("El servidor MCP está funcionando correctamente.") | |
| with gr.Row(): | |
| # Botón para verificar estado | |
| status_btn = gr.Button("Verificar estado del servidor") | |
| status_output = gr.Textbox(label="Estado") | |
| def check_status(): | |
| return "✅ Servidor activo y funcionando en el puerto 7860" | |
| status_btn.click( | |
| fn=check_status, | |
| outputs=status_output | |
| ) | |
| # Sección de endpoints disponibles | |
| gr.Markdown("### Endpoints disponibles:") | |
| gr.Markdown("- `/get_document_info`: Obtiene información de documentos") | |
| gr.Markdown("- `/sse`: Stream de eventos (SSE)") | |
| return demo | |
| # Monta la interfaz de Gradio en la ruta principal | |
| gradio_app = create_simple_interface() | |
| app = gr.mount_gradio_app(app, gradio_app, path="/") | |
| # Si necesitas integrar el MCP de otra forma (ajusta según tu implementación) | |
| # app.mount("/mcp", mcp.app) # Opción alternativa si mcp tiene una propiedad app | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |