JC321 commited on
Commit
6d92a88
·
verified ·
1 Parent(s): f327765

Upload 2 files

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -9
  2. app.py +18 -9
Dockerfile CHANGED
@@ -1,13 +1,11 @@
1
- FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
  # Install curl for health checks
6
- RUN apt-get update && apt-get install -y --no-install-recommends \
7
- curl \
8
- && rm -rf /var/lib/apt/lists/*
9
 
10
- # Copy requirements and install dependencies
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
@@ -20,13 +18,12 @@ COPY app.py .
20
  # Expose port
21
  EXPOSE 7860
22
 
23
- # Set environment variables for production
24
  ENV PYTHONUNBUFFERED=1
25
  ENV PYTHONDONTWRITEBYTECODE=1
26
 
27
  # Health check
28
- HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
29
- CMD curl -f http://localhost:7860/ || exit 1
30
 
31
- # Run MCP Server with FastMCP (SSE transport)
32
  CMD ["python", "app.py"]
 
1
+ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
5
  # Install curl for health checks
6
+ RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
 
 
7
 
8
+ # Copy and install dependencies
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
 
18
  # Expose port
19
  EXPOSE 7860
20
 
21
+ # Environment variables
22
  ENV PYTHONUNBUFFERED=1
23
  ENV PYTHONDONTWRITEBYTECODE=1
24
 
25
  # Health check
26
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 CMD curl -f http://localhost:7860/ || exit 1
 
27
 
28
+ # Run MCP Server
29
  CMD ["python", "app.py"]
app.py CHANGED
@@ -1,12 +1,21 @@
1
- """
2
- MCP Server Entry Point for Hugging Face Space
3
- This file is required by HF Space as the main application entry point.
4
- """
5
 
6
- from mcp_server_fastmcp import mcp
 
 
7
 
8
- # Entry point for Hugging Face Space
9
  if __name__ == "__main__":
10
- # Run with SSE transport
11
- # HF Space will expose this at port 7860
12
- mcp.run(transport="sse")
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
 
 
3
 
4
+ # Configure for HF Space port 7860
5
+ os.environ["UVICORN_PORT"] = "7860"
6
+ os.environ["UVICORN_HOST"] = "0.0.0.0"
7
 
 
8
  if __name__ == "__main__":
9
+ import uvicorn
10
+
11
+ # Import the FastMCP server
12
+ from mcp_server_fastmcp import mcp
13
+
14
+ # Run with custom port
15
+ # We need to monkeypatch uvicorn settings
16
+ uvicorn.run(
17
+ "mcp_server_fastmcp:mcp",
18
+ host="0.0.0.0",
19
+ port=7860,
20
+ log_level="info"
21
+ )