JC321 commited on
Commit
55293d6
·
verified ·
1 Parent(s): a37b342

Upload 6 files

Browse files
Files changed (3) hide show
  1. Dockerfile +4 -3
  2. README.md +0 -1
  3. mcp_server_fastmcp.py +16 -3
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
@@ -13,7 +13,6 @@ RUN pip install --no-cache-dir -r requirements.txt
13
  COPY edgar_client.py .
14
  COPY financial_analyzer.py .
15
  COPY mcp_server_fastmcp.py .
16
- COPY app.py .
17
 
18
  # Expose port
19
  EXPOSE 7860
@@ -21,9 +20,11 @@ EXPOSE 7860
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"]
 
1
+ FROM python:3.10-slim
2
 
3
  WORKDIR /app
4
 
 
13
  COPY edgar_client.py .
14
  COPY financial_analyzer.py .
15
  COPY mcp_server_fastmcp.py .
 
16
 
17
  # Expose port
18
  EXPOSE 7860
 
20
  # Environment variables
21
  ENV PYTHONUNBUFFERED=1
22
  ENV PYTHONDONTWRITEBYTECODE=1
23
+ ENV PORT=7860
24
+ ENV HOST=0.0.0.0
25
 
26
  # Health check
27
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 CMD curl -f http://localhost:7860/ || exit 1
28
 
29
  # Run MCP Server
30
+ CMD ["python", "mcp_server_fastmcp.py"]
README.md CHANGED
@@ -5,7 +5,6 @@ colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
  app_port: 7860
8
- app_file: app.py
9
  pinned: false
10
  ---
11
 
 
5
  colorTo: green
6
  sdk: docker
7
  app_port: 7860
 
8
  pinned: false
9
  ---
10
 
mcp_server_fastmcp.py CHANGED
@@ -1,4 +1,4 @@
1
- """
2
  MCP Server for SEC EDGAR Financial Data - FastMCP Implementation
3
  Uses Anthropic official FastMCP SDK for cleaner, more maintainable code
4
  """
@@ -197,6 +197,19 @@ def advanced_search_company(company_input: str) -> dict:
197
  return result
198
 
199
 
200
- # For production deployment, use the MCP SDK server directly
201
  if __name__ == "__main__":
202
- mcp.run(transport="sse")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
  MCP Server for SEC EDGAR Financial Data - FastMCP Implementation
3
  Uses Anthropic official FastMCP SDK for cleaner, more maintainable code
4
  """
 
197
  return result
198
 
199
 
200
+ # For production deployment
201
  if __name__ == "__main__":
202
+ import os
203
+ import uvicorn
204
+
205
+ # Get port from environment or use 7860 for HF Space
206
+ port = int(os.getenv("PORT", "7860"))
207
+ host = os.getenv("HOST", "0.0.0.0")
208
+
209
+ # Run with uvicorn manually since mcp.run() defaults to port 8000
210
+ # We create a simple ASGI app wrapper
211
+ async def asgi_app(scope, receive, send):
212
+ # Delegate to FastMCP's SSE handler
213
+ await mcp._handle_sse_message(scope, receive, send)
214
+
215
+ uvicorn.run(asgi_app, host=host, port=port)