Kaballas's picture
ww
c5052d5
raw
history blame contribute delete
573 Bytes
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()