Spaces:
Sleeping
Sleeping
www
Browse files
app.py
CHANGED
@@ -1,9 +1,21 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi_mcp import FastApiMCP
|
|
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
5 |
|
|
|
6 |
mcp = FastApiMCP(app)
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
# Mount the MCP server directly to your FastAPI app
|
9 |
-
mcp.mount()
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi_mcp import FastApiMCP
|
3 |
+
import requests
|
4 |
|
5 |
+
def get_public_ip():
|
6 |
+
try:
|
7 |
+
response = requests.get('https://api.ipify.org?format=json')
|
8 |
+
return response.json().get('ip')
|
9 |
+
except Exception as e:
|
10 |
+
return f"Error: {e}"
|
11 |
|
12 |
+
app = FastAPI()
|
13 |
mcp = FastApiMCP(app)
|
14 |
|
15 |
+
# Print IP immediately when module loads
|
16 |
+
public_ip = get_public_ip()
|
17 |
+
print(f"π Public IP address: {public_ip}")
|
18 |
+
print(f"π MCP Server will be accessible at: http://{public_ip}:8000/mcp")
|
19 |
+
|
20 |
# Mount the MCP server directly to your FastAPI app
|
21 |
+
mcp.mount()
|