Spaces:
Sleeping
Sleeping
kabudadada
commited on
Commit
·
1a0eb0a
1
Parent(s):
5b8f70d
Run FastMCP HTTP on 7860; optionalize ESM imports; expose health
Browse files- Dockerfile +4 -1
- app.py +7 -9
- esm/mcp_output/mcp_plugin/mcp_service.py +11 -4
Dockerfile
CHANGED
|
@@ -9,4 +9,7 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
| 9 |
|
| 10 |
COPY --chown=user . /app
|
| 11 |
EXPOSE 7860
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
COPY --chown=user . /app
|
| 11 |
EXPOSE 7860
|
| 12 |
+
# Run FastMCP HTTP server on port 7860
|
| 13 |
+
ENV MCP_TRANSPORT=http
|
| 14 |
+
ENV MCP_PORT=7860
|
| 15 |
+
CMD ["python", "-m", "esm.mcp_output.start_mcp"]
|
app.py
CHANGED
|
@@ -1,17 +1,15 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
|
|
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
| 5 |
|
| 6 |
@app.get("/")
|
| 7 |
async def root():
|
| 8 |
-
return {
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
await ws.accept()
|
| 14 |
-
await ws.send_text("WebSocket is up. Replace with your MCP/ESM handler.")
|
| 15 |
-
await ws.close()
|
| 16 |
|
| 17 |
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
|
| 7 |
@app.get("/")
|
| 8 |
async def root():
|
| 9 |
+
return {
|
| 10 |
+
"status": "ok",
|
| 11 |
+
"service": "Code2MCP-esm",
|
| 12 |
+
"transport": os.environ.get("MCP_TRANSPORT", "stdio"),
|
| 13 |
+
}
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
esm/mcp_output/mcp_plugin/mcp_service.py
CHANGED
|
@@ -5,10 +5,17 @@ source_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__fil
|
|
| 5 |
sys.path.insert(0, source_path)
|
| 6 |
|
| 7 |
from fastmcp import FastMCP
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
# from examples.
|
| 11 |
-
# from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
mcp = FastMCP("esm_service")
|
| 14 |
|
|
|
|
| 5 |
sys.path.insert(0, source_path)
|
| 6 |
|
| 7 |
from fastmcp import FastMCP
|
| 8 |
+
try:
|
| 9 |
+
from esm import pretrained, data, inverse_folding, model # type: ignore
|
| 10 |
+
# from examples.lm_design.lm_design import lm_design
|
| 11 |
+
# from examples.variant_prediction.predict import predict
|
| 12 |
+
# from scripts import extract, fold
|
| 13 |
+
except Exception as import_error: # pragma: no cover
|
| 14 |
+
pretrained = None # type: ignore
|
| 15 |
+
data = None # type: ignore
|
| 16 |
+
inverse_folding = None # type: ignore
|
| 17 |
+
model = None # type: ignore
|
| 18 |
+
print(f"[warn] Optional ESM modules unavailable: {import_error}")
|
| 19 |
|
| 20 |
mcp = FastMCP("esm_service")
|
| 21 |
|