INNER CODE UNIT · Python

_safe_tool_argument_payload

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

def _safe_tool_argument_payload(arguments: object) -> dict[str, Any]:
    if not isinstance(arguments, dict):
        return {}
    payload: dict[str, Any] = {
        "ctx.arguments.keys": sorted(str(key) for key in arguments),
    }
    for key in ("top_k", "top_n", "max_hops"):
        value = arguments.get(key)
        if isinstance(value, (int, float)):
            payload[f"ctx.arguments.{key}"] = value
    query = arguments.get("query")
    if isinstance(query, str):
        payload["ctx.query.hash"] = hash_identifier(query)
        payload["ctx.query.length"] = len(query)
    seeds = arguments.get("seeds")
    if isinstance(seeds, (list, tuple)):
        payload["ctx.seeds.count"] = len(seeds)
        payload["ctx.seeds.hash"] = _hash_json_value(list(seeds))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…