Jofthomas commited on
Commit
8db0f05
·
1 Parent(s): 05b0328

welcome page !

Browse files
Files changed (1) hide show
  1. server.py +36 -0
server.py CHANGED
@@ -1,5 +1,6 @@
1
  import contextlib
2
  from fastapi import FastAPI
 
3
  from echo_server import mcp as echo_mcp
4
  from math_server import mcp as math_mcp
5
  import os
@@ -15,6 +16,41 @@ async def lifespan(app: FastAPI):
15
 
16
 
17
  app = FastAPI(lifespan=lifespan)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  app.mount("/echo", echo_mcp.streamable_http_app())
19
  app.mount("/math", math_mcp.streamable_http_app())
20
 
 
1
  import contextlib
2
  from fastapi import FastAPI
3
+ from fastapi.responses import HTMLResponse
4
  from echo_server import mcp as echo_mcp
5
  from math_server import mcp as math_mcp
6
  import os
 
16
 
17
 
18
  app = FastAPI(lifespan=lifespan)
19
+
20
+ @app.get("/", response_class=HTMLResponse)
21
+ async def index():
22
+ return """
23
+ <!doctype html>
24
+ <html lang="en">
25
+ <head>
26
+ <meta charset="utf-8" />
27
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
28
+ <title>Multiple MCP Servers Template</title>
29
+ <style>
30
+ body { font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif; margin: 2rem; line-height: 1.5; }
31
+ code, pre { background: #f6f8fa; padding: 0.2rem 0.4rem; border-radius: 4px; }
32
+ a { color: #2563eb; text-decoration: none; }
33
+ a:hover { text-decoration: underline; }
34
+ .container { max-width: 800px; }
35
+ h1 { margin-bottom: 0.5rem; }
36
+ .routes { margin-top: 1rem; }
37
+ </style>
38
+ </head>
39
+ <body>
40
+ <div class="container">
41
+ <h1>Multiple MCP Servers Template</h1>
42
+ <p>This FastAPI app demonstrates how to host multiple Model Context Protocol (MCP) servers on a single server instance.</p>
43
+ <p>The following MCP servers are mounted under this app:</p>
44
+ <ul class="routes">
45
+ <li><a href="/echo">/echo</a> — Echo MCP server</li>
46
+ <li><a href="/math">/math</a> — Math MCP server</li>
47
+ </ul>
48
+ <p>Use these routes as sub-apps or as examples for adding more MCP servers.</p>
49
+ </div>
50
+ </body>
51
+ </html>
52
+ """
53
+
54
  app.mount("/echo", echo_mcp.streamable_http_app())
55
  app.mount("/math", math_mcp.streamable_http_app())
56