Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,56 +1,49 @@
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
-
from
|
| 4 |
-
import
|
| 5 |
import socket
|
|
|
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
# Dashboard HTML simple
|
| 10 |
@app.get("/", response_class=HTMLResponse)
|
| 11 |
async def dashboard(request: Request):
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
<h1>MCP Server Status</h1>
|
| 31 |
-
<p>馃煝 <strong>Running</strong></p>
|
| 32 |
-
<p>Hostname: {socket.gethostname()}</p>
|
| 33 |
-
<p>Time: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}</p>
|
| 34 |
-
</div>
|
| 35 |
-
|
| 36 |
-
<div class="card">
|
| 37 |
-
<h2>Available Endpoints</h2>
|
| 38 |
-
<ul>
|
| 39 |
-
<li><code>GET /get_document_info</code></li>
|
| 40 |
-
<li><code>GET /sse</code></li>
|
| 41 |
-
</ul>
|
| 42 |
-
</div>
|
| 43 |
-
</body>
|
| 44 |
-
</html>
|
| 45 |
-
"""
|
| 46 |
-
return HTMLResponse(content=html_content)
|
| 47 |
-
|
| 48 |
-
# Integraci贸n CORRECTA con FastMCP (seg煤n su documentaci贸n)
|
| 49 |
-
# Opci贸n 1: Si mcp fue creado con FastMCP.from_fastapi()
|
| 50 |
-
app.mount("/api", mcp.app) # Monta toda la aplicaci贸n FastAPI
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
|
| 54 |
|
| 55 |
if __name__ == "__main__":
|
| 56 |
import uvicorn
|
|
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
+
from fastapi.templating import Jinja2Templates
|
| 4 |
+
import os
|
| 5 |
import socket
|
| 6 |
+
from server import mcp # Importa tu servidor MCP existente
|
| 7 |
|
| 8 |
+
# Crea la aplicaci贸n FastAPI
|
| 9 |
+
app = FastAPI(title="MCP Server Dashboard")
|
| 10 |
+
|
| 11 |
+
# Configurar templates
|
| 12 |
+
templates = Jinja2Templates(directory="templates")
|
| 13 |
+
|
| 14 |
+
def get_system_info():
|
| 15 |
+
"""Obtiene informaci贸n del sistema"""
|
| 16 |
+
return {
|
| 17 |
+
"hostname": socket.gethostname(),
|
| 18 |
+
"python_version": platform.python_version(),
|
| 19 |
+
"system": platform.system(),
|
| 20 |
+
"cpu_count": os.cpu_count(),
|
| 21 |
+
"current_time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 22 |
+
}
|
| 23 |
|
|
|
|
| 24 |
@app.get("/", response_class=HTMLResponse)
|
| 25 |
async def dashboard(request: Request):
|
| 26 |
+
"""Dashboard principal con informaci贸n del servidor"""
|
| 27 |
+
system_info = get_system_info()
|
| 28 |
+
mcp_info = {
|
| 29 |
+
"server_name": "OnBase MCP Server",
|
| 30 |
+
"status": "Running",
|
| 31 |
+
"port": 7860,
|
| 32 |
+
"endpoints": [
|
| 33 |
+
{"name": "Document Info", "path": "/get_document_info"},
|
| 34 |
+
{"name": "SSE Stream", "path": "/sse"}
|
| 35 |
+
]
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
return templates.TemplateResponse("dashboard.html", {
|
| 39 |
+
"request": request,
|
| 40 |
+
"system_info": system_info,
|
| 41 |
+
"mcp_info": mcp_info,
|
| 42 |
+
"title": "MCP Server Dashboard"
|
| 43 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
# Incluye los endpoints de MCP directamente en la aplicaci贸n principal
|
| 46 |
+
app.include_router(mcp.router)
|
| 47 |
|
| 48 |
if __name__ == "__main__":
|
| 49 |
import uvicorn
|