geronimo-pericoli commited on
Commit
e1339a2
verified
1 Parent(s): 65ce4a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -45
app.py CHANGED
@@ -1,56 +1,49 @@
1
  from fastapi import FastAPI, Request
2
  from fastapi.responses import HTMLResponse
3
- from server import mcp # Tu instancia de FastMCP
4
- import datetime
5
  import socket
 
6
 
7
- app = FastAPI(title="MCP Server")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- # Dashboard HTML simple
10
  @app.get("/", response_class=HTMLResponse)
11
  async def dashboard(request: Request):
12
- html_content = f"""
13
- <!DOCTYPE html>
14
- <html>
15
- <head>
16
- <title>MCP Server</title>
17
- <style>
18
- body {{ font-family: Arial, sans-serif; margin: 20px; }}
19
- .card {{
20
- background: #f8f9fa;
21
- padding: 20px;
22
- border-radius: 5px;
23
- margin-bottom: 20px;
24
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
25
- }}
26
- </style>
27
- </head>
28
- <body>
29
- <div class="card">
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
- # Opci贸n 2: Si prefieres prefijar los endpoints
53
- # app.include_router(mcp.app.router, prefix="/api")
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