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

Function text_of

scripts/mcp_probe/probe.py:222–237  ·  view source on GitHub ↗

Return the first content block that parses as JSON, else content[0].

(resp)

Source from the content-addressed store, hash-verified

220# ---------------------------------------------------------------------------- helpers
221
222def text_of(resp) -> str | None:
223 """Return the first content block that parses as JSON, else content[0]."""
224 if not isinstance(resp, dict):
225 return None
226 res = resp.get("result")
227 if not isinstance(res, dict):
228 return None
229 content = res.get("content") or []
230 for block in content:
231 t = block.get("text", "")
232 try:
233 json.loads(t)
234 return t
235 except Exception:
236 continue
237 return content[0].get("text") if content else None
238
239
240def discover(cli: McpClient) -> dict:

Callers 1

discoverFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected