Spaces:
Sleeping
Sleeping
Update biopython/mcp_output/mcp_plugin/mcp_service.py
Browse files
biopython/mcp_output/mcp_plugin/mcp_service.py
CHANGED
|
@@ -160,42 +160,18 @@ def usage_tool(payload: dict | None = None):
|
|
| 160 |
return {"success": False, "result": None, "error": str(e)}
|
| 161 |
|
| 162 |
@mcp.tool(name="notepad", description="Instantiate Scripts/xbbtools/xbb_utils.NotePad")
|
| 163 |
-
def notepad_tool(
|
| 164 |
-
"""NotePad class"""
|
| 165 |
try:
|
| 166 |
NotePad = lazy_import_script("Scripts.xbbtools.xbb_utils", "NotePad")
|
| 167 |
if NotePad is None:
|
| 168 |
return {"success": False, "result": None, "error": "Class NotePad is not available"}
|
| 169 |
|
| 170 |
-
#
|
| 171 |
-
|
| 172 |
-
|
| 173 |
|
| 174 |
-
|
| 175 |
-
for arg in args:
|
| 176 |
-
if isinstance(arg, str):
|
| 177 |
-
try:
|
| 178 |
-
if '.' in arg:
|
| 179 |
-
converted_args.append(float(arg))
|
| 180 |
-
else:
|
| 181 |
-
converted_args.append(int(arg))
|
| 182 |
-
except ValueError:
|
| 183 |
-
converted_args.append(arg)
|
| 184 |
-
else:
|
| 185 |
-
converted_args.append(arg)
|
| 186 |
-
|
| 187 |
-
# Handle keyword argument type conversion
|
| 188 |
-
for key, value in converted_kwargs.items():
|
| 189 |
-
if isinstance(value, str):
|
| 190 |
-
try:
|
| 191 |
-
if '.' in value:
|
| 192 |
-
converted_kwargs[key] = float(value)
|
| 193 |
-
else:
|
| 194 |
-
converted_kwargs[key] = int(value)
|
| 195 |
-
except ValueError:
|
| 196 |
-
pass
|
| 197 |
-
|
| 198 |
-
instance = NotePad(*converted_args, **converted_kwargs)
|
| 199 |
return {"success": True, "result": str(instance), "error": None}
|
| 200 |
except Exception as e:
|
| 201 |
return {"success": False, "result": None, "error": str(e)}
|
|
@@ -223,79 +199,35 @@ def makeTableX_tool(payload: dict):
|
|
| 223 |
return {"success": False, "result": None, "error": str(e)}
|
| 224 |
|
| 225 |
@mcp.tool(name="missingtable", description="Instantiate MissingTable (Scripts/xbbtools/nextorf.py)")
|
| 226 |
-
def missingtable_tool(
|
| 227 |
-
"""MissingTable class"""
|
| 228 |
try:
|
| 229 |
MissingTable = lazy_import_script("Scripts.xbbtools.nextorf", "MissingTable")
|
| 230 |
if MissingTable is None:
|
| 231 |
return {"success": False, "result": None, "error": "Class MissingTable is not available"}
|
| 232 |
|
| 233 |
-
#
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
for arg in args:
|
| 238 |
-
if isinstance(arg, str):
|
| 239 |
-
try:
|
| 240 |
-
if '.' in arg:
|
| 241 |
-
converted_args.append(float(arg))
|
| 242 |
-
else:
|
| 243 |
-
converted_args.append(int(arg))
|
| 244 |
-
except ValueError:
|
| 245 |
-
converted_args.append(arg)
|
| 246 |
-
else:
|
| 247 |
-
converted_args.append(arg)
|
| 248 |
|
| 249 |
-
|
| 250 |
-
if isinstance(value, str):
|
| 251 |
-
try:
|
| 252 |
-
if '.' in value:
|
| 253 |
-
converted_kwargs[key] = float(value)
|
| 254 |
-
else:
|
| 255 |
-
converted_kwargs[key] = int(value)
|
| 256 |
-
except ValueError:
|
| 257 |
-
pass
|
| 258 |
-
|
| 259 |
-
instance = MissingTable(*converted_args, **converted_kwargs)
|
| 260 |
return {"success": True, "result": str(instance), "error": None}
|
| 261 |
except Exception as e:
|
| 262 |
return {"success": False, "result": None, "error": str(e)}
|
| 263 |
|
| 264 |
@mcp.tool(name="nextorf", description="Instantiate NextOrf (Scripts/xbbtools/nextorf.py)")
|
| 265 |
-
def nextorf_tool(
|
| 266 |
-
"""NextOrf class"""
|
| 267 |
try:
|
| 268 |
NextOrf = lazy_import_script("Scripts.xbbtools.nextorf", "NextOrf")
|
| 269 |
if NextOrf is None:
|
| 270 |
return {"success": False, "result": None, "error": "Class NextOrf is not available"}
|
| 271 |
|
| 272 |
-
#
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
for arg in args:
|
| 277 |
-
if isinstance(arg, str):
|
| 278 |
-
try:
|
| 279 |
-
if '.' in arg:
|
| 280 |
-
converted_args.append(float(arg))
|
| 281 |
-
else:
|
| 282 |
-
converted_args.append(int(arg))
|
| 283 |
-
except ValueError:
|
| 284 |
-
converted_args.append(arg)
|
| 285 |
-
else:
|
| 286 |
-
converted_args.append(arg)
|
| 287 |
-
|
| 288 |
-
for key, value in converted_kwargs.items():
|
| 289 |
-
if isinstance(value, str):
|
| 290 |
-
try:
|
| 291 |
-
if '.' in value:
|
| 292 |
-
converted_kwargs[key] = float(value)
|
| 293 |
-
else:
|
| 294 |
-
converted_kwargs[key] = int(value)
|
| 295 |
-
except ValueError:
|
| 296 |
-
pass
|
| 297 |
|
| 298 |
-
instance = NextOrf(*
|
| 299 |
return {"success": True, "result": str(instance), "error": None}
|
| 300 |
except Exception as e:
|
| 301 |
return {"success": False, "result": None, "error": str(e)}
|
|
|
|
| 160 |
return {"success": False, "result": None, "error": str(e)}
|
| 161 |
|
| 162 |
@mcp.tool(name="notepad", description="Instantiate Scripts/xbbtools/xbb_utils.NotePad")
|
| 163 |
+
def notepad_tool(payload: dict):
|
| 164 |
+
"""NotePad class - pass constructor arguments in payload"""
|
| 165 |
try:
|
| 166 |
NotePad = lazy_import_script("Scripts.xbbtools.xbb_utils", "NotePad")
|
| 167 |
if NotePad is None:
|
| 168 |
return {"success": False, "result": None, "error": "Class NotePad is not available"}
|
| 169 |
|
| 170 |
+
# Extract args and kwargs from payload
|
| 171 |
+
args = payload.get("args", [])
|
| 172 |
+
kwargs = payload.get("kwargs", {})
|
| 173 |
|
| 174 |
+
instance = NotePad(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
return {"success": True, "result": str(instance), "error": None}
|
| 176 |
except Exception as e:
|
| 177 |
return {"success": False, "result": None, "error": str(e)}
|
|
|
|
| 199 |
return {"success": False, "result": None, "error": str(e)}
|
| 200 |
|
| 201 |
@mcp.tool(name="missingtable", description="Instantiate MissingTable (Scripts/xbbtools/nextorf.py)")
|
| 202 |
+
def missingtable_tool(payload: dict):
|
| 203 |
+
"""MissingTable class - pass constructor arguments in payload"""
|
| 204 |
try:
|
| 205 |
MissingTable = lazy_import_script("Scripts.xbbtools.nextorf", "MissingTable")
|
| 206 |
if MissingTable is None:
|
| 207 |
return {"success": False, "result": None, "error": "Class MissingTable is not available"}
|
| 208 |
|
| 209 |
+
# Extract args and kwargs from payload
|
| 210 |
+
args = payload.get("args", [])
|
| 211 |
+
kwargs = payload.get("kwargs", {})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
+
instance = MissingTable(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
return {"success": True, "result": str(instance), "error": None}
|
| 215 |
except Exception as e:
|
| 216 |
return {"success": False, "result": None, "error": str(e)}
|
| 217 |
|
| 218 |
@mcp.tool(name="nextorf", description="Instantiate NextOrf (Scripts/xbbtools/nextorf.py)")
|
| 219 |
+
def nextorf_tool(payload: dict):
|
| 220 |
+
"""NextOrf class - pass constructor arguments in payload"""
|
| 221 |
try:
|
| 222 |
NextOrf = lazy_import_script("Scripts.xbbtools.nextorf", "NextOrf")
|
| 223 |
if NextOrf is None:
|
| 224 |
return {"success": False, "result": None, "error": "Class NextOrf is not available"}
|
| 225 |
|
| 226 |
+
# Extract args and kwargs from payload
|
| 227 |
+
args = payload.get("args", [])
|
| 228 |
+
kwargs = payload.get("kwargs", {})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
+
instance = NextOrf(*args, **kwargs)
|
| 231 |
return {"success": True, "result": str(instance), "error": None}
|
| 232 |
except Exception as e:
|
| 233 |
return {"success": False, "result": None, "error": str(e)}
|