MCPcopy Create free account
hub / github.com/IBM/mcp-cli / from_raw

Method from_raw

src/mcp_cli/tools/models.py:463–475  ·  view source on GitHub ↗

Convert a raw list item (dict | str | int | …) into a ResourceInfo. If *raw* is not a mapping we treat it as an opaque scalar and store it in ``extra["value"]`` so it is never lost.

(cls, raw: Any)

Source from the content-addressed store, hash-verified

461 # ------------------------------------------------------------------ #
462 @classmethod
463 def from_raw(cls, raw: Any) -> "ResourceInfo":
464 """
465 Convert a raw list item (dict | str | int | …) into a ResourceInfo.
466
467 If *raw* is not a mapping we treat it as an opaque scalar and store it
468 in ``extra["value"]`` so it is never lost.
469 """
470 if isinstance(raw, dict):
471 known = {k: raw.get(k) for k in ("id", "name", "type")}
472 extra = {k: v for k, v in raw.items() if k not in known}
473 return cls(**known, extra=extra)
474 # primitive - wrap it
475 return cls(extra={"value": raw})
476
477
478# ──────────────────────────────────────────────────────────────────────────────

Calls 1

getMethod · 0.45