MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / classify

Function classify

scripts/mcp_probe/probe.py:302–325  ·  view source on GitHub ↗
(resp, dt)

Source from the content-addressed store, hash-verified

300
301
302def classify(resp, dt) -> tuple[str, str]:
303 if resp is None:
304 return "BAD", "no response"
305 if isinstance(resp, dict) and resp.get("_timeout"):
306 return "TIMEOUT", f"{dt:.1f}s"
307 if "error" in resp:
308 err = resp["error"]
309 msg = err.get("message", "") if isinstance(err, dict) else str(err)
310 return "ERROR", msg[:100]
311 res = resp.get("result")
312 if res is None:
313 return "BAD", "no result"
314 if res.get("isError"):
315 c = res.get("content") or [{}]
316 return "ERROR", (c[0].get("text") or "")[:100]
317 c = res.get("content")
318 if not c:
319 return "EMPTY", "no content"
320 txt = c[0].get("text", "")
321 if not txt.strip():
322 return "EMPTY", "blank"
323 if dt > 10:
324 return "SLOW", f"{dt:.1f}s"
325 return "OK", f"{dt:.2f}s"
326
327
328# ---------------------------------------------------------------------------- main

Callers 2

run_tool_freshFunction · 0.90
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected