Entz commited on
Commit
3d072c5
·
verified ·
1 Parent(s): c29f774

Upload 8 files

Browse files
Files changed (4) hide show
  1. Dockerfile +5 -2
  2. arithmetic_server.py +1 -1
  3. backend.py +6 -4
  4. stock_server.py +1 -1
Dockerfile CHANGED
@@ -3,6 +3,9 @@ FROM python:3.10-slim
3
  # Set working directory in the container
4
  WORKDIR /app
5
 
 
 
 
6
  # Copy requirements and install dependencies
7
  COPY requirements.txt .
8
  RUN pip install --no-cache-dir -r requirements.txt
@@ -24,5 +27,5 @@ EXPOSE 8501
24
  # Health check for Streamlit
25
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
26
 
27
- # Run MCP servers in background, then Streamlit (using shell for &)
28
- CMD sh -c "python /app/arithmetic_server.py & python /app/stock_server.py & sleep 5 && streamlit run /app/frontend.py --server.port=8501 --server.address=0.0.0.0"
 
3
  # Set working directory in the container
4
  WORKDIR /app
5
 
6
+ # Unbuffer STDIO for subprocess pipes (fixes hanging in MCP stdio)
7
+ ENV PYTHONUNBUFFERED=1
8
+
9
  # Copy requirements and install dependencies
10
  COPY requirements.txt .
11
  RUN pip install --no-cache-dir -r requirements.txt
 
27
  # Health check for Streamlit
28
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
29
 
30
+ # Run Streamlit
31
+ CMD ["streamlit", "run", "frontend.py", "--server.port=8501", "--server.address=0.0.0.0"]
arithmetic_server.py CHANGED
@@ -41,4 +41,4 @@ app = Starlette(
41
  )
42
 
43
  if __name__ == "__main__":
44
- uvicorn.run(app, host="0.0.0.0", port=8001)
 
41
  )
42
 
43
  if __name__ == "__main__":
44
+ mcp.run(transport="stdio")
backend.py CHANGED
@@ -174,12 +174,14 @@ class MCPAgent:
174
  # Start the Stock server separately first: `python stockserver.py`
175
  self.client = MultiServerMCPClient({
176
  "arithmetic": {
177
- "url": "http://localhost:8001",
178
- "transport": "streamable_http",
 
179
  },
180
  "stocks": {
181
- "url": "http://localhost:8002",
182
- "transport": "streamable_http",
 
183
  },
184
  }
185
  )
 
174
  # Start the Stock server separately first: `python stockserver.py`
175
  self.client = MultiServerMCPClient({
176
  "arithmetic": {
177
+ "command": sys.executable,
178
+ "args": [str(here / "arithmetic_server.py")],
179
+ "transport": "stdio",
180
  },
181
  "stocks": {
182
+ "command": sys.executable,
183
+ "args": [str(here / "stock_server.py")],
184
+ "transport": "stdio",
185
  },
186
  }
187
  )
stock_server.py CHANGED
@@ -75,4 +75,4 @@ app = Starlette(
75
  )
76
 
77
  if __name__ == "__main__":
78
- uvicorn.run(app, host="0.0.0.0", port=8002)
 
75
  )
76
 
77
  if __name__ == "__main__":
78
+ mcp.run(transport="stdio")