Yahya Darman
Initial clean commit on master branch
82cfa24
raw
history blame
1.3 kB
import modal
import os
from dotenv import load_dotenv
# Ensure environment variables are loaded for local testing and deployment to Modal
load_dotenv()
# Define a Modal App
# You can give it a more specific name if you like, e.g., "buffetbot-mcp-server"
app = modal.App("buffetbot-mcp-server")
# Define the Modal Image
# This image will include all the necessary backend files and Python packages.
# The 'backend' directory and its contents are added to the image.
# We also install all packages from requirements.txt.
buffetbot_image = modal.Image.debian_slim(python_version="3.10").pip_install_from_requirements("requirements.txt").add_local_dir(
local_path="backend",
remote_path="/root/backend"
)
# Import the FastAPI app from backend.mcp_server
# This import needs to happen within the Modal image context,
# so we import it after defining the image and copying the files.
with buffetbot_image.imports():
from backend.mcp_server import MCPStockServer
@app.function(image=buffetbot_image, secrets=[
modal.Secret.from_name("buffetbot-mcp-server-secrets"),
modal.Secret.from_name("buffetbot-serper-config")
])
@modal.asgi_app()
def fastapi_app():
# Instantiate the MCPStockServer, which contains the FastAPI app
server = MCPStockServer()
return server.app