Spaces:
Sleeping
Sleeping
File size: 573 Bytes
bc7893a 401cfcb a27dc0c 401cfcb 90d0d5d 401cfcb bc7893a 90d0d5d 401cfcb c5052d5 401cfcb bc7893a 401cfcb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP
import requests
def get_public_ip():
try:
response = requests.get('https://api.ipify.org?format=json')
return response.json().get('ip')
except Exception as e:
return f"Error: {e}"
app = FastAPI()
mcp = FastApiMCP(app)
# Print IP immediately when module loads
public_ip = get_public_ip()
print(f"π Public IP address: {public_ip}")
print(f"π MCP Server will be accessible at: http://{public_ip}:7860/mcp")
# Mount the MCP server directly to your FastAPI app
mcp.mount()
|