Spaces:
Sleeping
Sleeping
kabudadada commited on
Commit ·
bf433c8
1
Parent(s): 69f64a8
feat(esm mcp): get_prediction_pdb supports optional save_to_path on server
Browse files
esm/mcp_output/mcp_plugin/mcp_service.py
CHANGED
|
@@ -253,8 +253,8 @@ def validate_protein_sequence(sequence: str):
|
|
| 253 |
}
|
| 254 |
|
| 255 |
|
| 256 |
-
@mcp.tool(name="get_prediction_pdb", description="Download saved PDB by filename or latest")
|
| 257 |
-
def get_prediction_pdb(filename: str):
|
| 258 |
"""Return PDB content saved under predictions directory.
|
| 259 |
|
| 260 |
Parameters:
|
|
@@ -290,9 +290,22 @@ def get_prediction_pdb(filename: str):
|
|
| 290 |
with open(target_path, "r") as f:
|
| 291 |
content = f.read()
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
return {
|
| 294 |
"success": True,
|
| 295 |
-
"result": {"filename": filename, "pdb_content": content, "path": target_path},
|
| 296 |
"error": None,
|
| 297 |
}
|
| 298 |
except Exception as e:
|
|
|
|
| 253 |
}
|
| 254 |
|
| 255 |
|
| 256 |
+
@mcp.tool(name="get_prediction_pdb", description="Download saved PDB by filename or latest; optionally re-save on server")
|
| 257 |
+
def get_prediction_pdb(filename: str, save_to_path: str | None = None):
|
| 258 |
"""Return PDB content saved under predictions directory.
|
| 259 |
|
| 260 |
Parameters:
|
|
|
|
| 290 |
with open(target_path, "r") as f:
|
| 291 |
content = f.read()
|
| 292 |
|
| 293 |
+
# Optionally save a copy to a given path (inside container)
|
| 294 |
+
saved_to: str | None = None
|
| 295 |
+
if save_to_path:
|
| 296 |
+
try:
|
| 297 |
+
save_dir = os.path.dirname(save_to_path)
|
| 298 |
+
if save_dir and not os.path.isdir(save_dir):
|
| 299 |
+
os.makedirs(save_dir, exist_ok=True)
|
| 300 |
+
with open(save_to_path, "w") as out_f:
|
| 301 |
+
out_f.write(content)
|
| 302 |
+
saved_to = save_to_path
|
| 303 |
+
except Exception as save_err:
|
| 304 |
+
return {"success": False, "result": None, "error": f"Save failed: {save_err}"}
|
| 305 |
+
|
| 306 |
return {
|
| 307 |
"success": True,
|
| 308 |
+
"result": {"filename": filename, "pdb_content": content, "path": target_path, "saved_copy_path": saved_to},
|
| 309 |
"error": None,
|
| 310 |
}
|
| 311 |
except Exception as e:
|