[{'Text': 'Edited point-topic-mcp/src/point_topic_mcp/tools/gbs_tools.py:\n\n```diff\n@@ -19,7 +19,6 @@\n \n import json\n import re\n-from collections import defaultdict\n from typing import Optional\n \n from point_topic_mcp.core.utils import check_env_vars\n@@ -44,129 +43,6 @@\n \n     def _admin_url(operator_id: str) -> str:\n         return f"{ADMIN_BASE}/operators/{operator_id}/statistics"\n-\n-    def _run_status_query(country: str, operator: str | None = None, period: str | None = None) -> dict:\n-        """Single mongosh call: resolve current period + $lookup aggregation."""\n-        match: dict = {"country": country, "isArchived": {"$ne": True}}\n-        if operator:\n-            match["name"] = operator\n-\n-        pipeline = [\n-            {"$match": match},\n-            {"$lookup": {\n-                "from": "Statistics",\n-                "let": {"oid": "$_id", "tp": "__PERIOD__"},\n-                "pipeline": [{"$match": {"$expr": {"$and": [\n-                    {"$eq": ["$operatorId", "$$oid"]},\n-                    {"$eq": ["$period", "$$tp"]}\n-                ]}}}],\n-                "as": "stats"\n-            }},\n-            {"$addFields": {"statCount": {"$size": "$stats"}}},\n-            {"$project": {"name": 1, "techs": "$technologies", "statCount": 1, "stats": 1}},\n-            {"$sort": {"name": 1}},\n-        ]\n-\n-        period_expr = f\'"{period}"\' if period else "null"\n-        pipe_json = json.dumps(pipeline)\n-\n-        js = f"""\n-        const gv = db.GlobalVariables.findOne({{isCurrent: true}});\n-        const cp = gv ? gv.currentStatsPeriod : null;\n-        const tp = {period_expr} || cp;\n-        const pipe = JSON.parse({json.dumps(pipe_json)}.replace(\'"__PERIOD__"\', JSON.stringify(tp)));\n-        const docs = db.Operator.aggregate(pipe).toArray();\n-        EJSON.stringify({{cp, tp, docs}});\n-        """\n-        result = mongo._run_mongosh(js, timeout=60)\n-        parsed = json.loads(result) if result else {}\n-        return parsed if parsed else {"error": "No data returned"}\n-\n-    def get_status(country: str = "", operator: str = "", period: str = "", ctx=None) -> str:\n-        """GBS status at any level: country coverage → operator detail → period drill-down.\n-\n-        country only → coverage overview (total/with/without data, top operators)\n-        + operator   → that operator\'s records, gaps, state breakdown\n-        + period     → specific quarter (default: current from GlobalVariables)\n-        """\n-        if not country:\n-            return "Error: country is required (e.g. \'United Kingdom\')"\n-\n-        data = _run_status_query(country, operator.strip() or None, period.strip() or None)\n-        if data.get("error"):\n-            return f"Query failed: {data[\'error\']}"\n-\n-        cp = data.get("cp", "?") or "?"\n-        tp = data.get("tp", cp) or cp\n-        docs = data.get("docs", [])\n-\n-        if operator.strip():\n-            if not docs:\n-                return f"Operator \'{operator}\' not found in \'{country}\'."\n-            d = docs[0]\n-            return _fmt_operator(d["name"], d.get("_id", {}).get("$oid", "?"), d.get("techs", []), d.get("stats", []), tp, country)\n-\n-        return _fmt_country(docs, cp, country)\n-\n-    def _fmt_country(docs, period, country):\n-        wd = [d for d in docs if d.get("statCount", 0) > 0]\n-        wo = [d for d in docs if d.get("statCount", 0) == 0]\n-        total = len(docs)\n-        lines = [f"GBS STATUS: {country} — period {period}",\n-                 f"Operators: {total} total | {len(wd)} with data | {len(wo)} without data"]\n-        if total > 0:\n-            lines.append(f"Coverage: {round(100 * len(wd) / total, 1)}%")\n-        lines.append("")\n-        if wd:\n-            lines.append("OPERATORS WITH DATA:")\n-            for d in sorted(wd, key=lambda x: -x["statCount"])[:50]:\n-                lines.append(f"  {d[\'name\'][:40]:40s} {d[\'statCount\']} rec")\n-        if wo:\n-            shown = wo[:30]\n-            lines.append(f"\\nOPERATORS WITHOUT DATA ({len(shown)} of {len(wo)}):")\n-            lines.append(f"  {\', \'.join(d[\'name\'] for d in shown)}")\n-            if len(wo) > 30:\n-                lines.append(f"  ... +{len(wo) - 30} more")\n-        lines.append(f"\\nAdmin: {ADMIN_BASE}/admin")\n-        return "\\n".join(lines)\n-\n-    def _fmt_operator(name, oid, techs, stats, period, country):\n-        by_state, by_type, records, combos = defaultdict(int), defaultdict(int), [], set()\n-        state_names = {1: "pending", 2: "approved", 3: "published"}\n-\n-        for s in stats:\n-            by_state[s.get("state", 0)] += 1\n-            by_type[s.get("type", "?")] += 1\n-            combos.add((s.get("type"), s.get("tech"), s.get("channel"), s.get("domain")))\n-            records.append(f"  {s.get(\'type\',\'?\'):10s} {s.get(\'tech\',\'?\'):18s} {s.get(\'channel\',\'?\'):15s} "\n-                           f"{s.get(\'domain\',\'?\'):12s} {s.get(\'subscribers\',0):>10,}  "\n-                           f"{state_names.get(s.get(\'state\',0), \'?\')}")\n-\n-        tus = sorted(set(s.get("tech") for s in stats)) or techs[:3] or ["?"]\n-        gaps = [f"  {t}/{tech}/{ch}/{dom}" for t in VALID_TYPES\n-                for tech in tus for ch in VALID_CHANNELS for dom in VALID_DOMAINS\n-                if (t, tech, ch, dom) not in combos]\n-\n-        sf = ", ".join(f"{state_names.get(k, k)}: {v}" for k, v in sorted(by_state.items())) or "none"\n-        tf = ", ".join(f"{k}: {v}" for k, v in sorted(by_type.items())) or "none"\n-        tstr = ", ".join(techs[:10]) + ("..." if len(techs) > 10 else "")\n-\n-        lines = [f"GBS STATUS: {name} ({country}) — {period}", "",\n-                 f"ID:        {oid}", f"Techs:     {tstr}",\n-                 f"Records:   {len(stats)} | Filled: {len(combos)} combos | Gaps: {len(gaps)}",\n-                 f"States:    {sf}", f"By type:   {tf}",\n-                 f"Admin:     {_admin_url(oid)}", ""]\n-        if records:\n-            lines.append("EXISTING RECORDS:")\n-            lines.extend(records)\n-            lines.append("")\n-        if gaps:\n-            lines.append(f"GAPS ({len(gaps)}):")\n-            lines.extend(gaps[:20])\n-            if len(gaps) > 20:\n-                lines.append(f"  ... +{len(gaps) - 20} more")\n-\n-        return "\\n".join(lines)\n \n     def add_statistic(type: str, operator_id: str, period: str, tech: str, channel: str,\n                       domain: str, subscribers: int, is_estimate: bool = False,\n\n```'}]