INNER CODE UNIT · Python

_mcp_result_payload

stevesolun/ctx · src/ctx/mcp_server/server.py:361

def _mcp_result_payload(method: str, result: dict[str, Any]) -> dict[str, Any]:
    payload: dict[str, Any] = {}
    if method == "tools/list":
        tools = result.get("tools")
        if isinstance(tools, list):
            payload["ctx.result.count"] = len(tools)
    elif method == "tools/call":
        payload["ctx.result.is_error"] = bool(result.get("isError"))
        content = result.get("content")
        if isinstance(content, list) and content:
            first = content[0]
            if isinstance(first, dict) and isinstance(first.get("text"), str):
                try:
                    parsed = json.loads(first["text"])
                except json.JSONDecodeError:
                    parsed = None
                if isinstance(parsed, dict):
                    results = parsed.get("results")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…