diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef96528..8c2179a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.11" - - run: pip install ruff>=0.4 + - run: pip install "ruff>=0.4" - run: ruff check catchme/ - run: ruff format --check catchme/ diff --git a/catchme/mcp_server.py b/catchme/mcp_server.py index daf41d9..84c5cbd 100644 --- a/catchme/mcp_server.py +++ b/catchme/mcp_server.py @@ -23,6 +23,7 @@ from __future__ import annotations +import asyncio import json import logging @@ -47,7 +48,7 @@ def serve() -> None: from mcp.server.stdio import stdio_server from mcp.types import TextContent, Tool - from .pipelines.retrieve import retrieve, _load_all_trees, _node_index + from .pipelines.retrieve import _load_all_trees, _node_index, retrieve server = Server("catchme") @@ -163,12 +164,14 @@ def _handle_list_days() -> list[TextContent]: days = [] for t in trees: node = t.get("tree", {}) - days.append({ - "date": t.get("date", node.get("title", "?")), - "node_id": node.get("node_id", ""), - "summary": (node.get("summary") or "")[:300], - "session_count": len(node.get("children", [])), - }) + days.append( + { + "date": t.get("date", node.get("title", "?")), + "node_id": node.get("node_id", ""), + "summary": (node.get("summary") or "")[:300], + "session_count": len(node.get("children", [])), + } + ) return [TextContent(type="text", text=json.dumps(days, ensure_ascii=False, indent=2))] # ── get_session ────────────────────────────────────────────────────────── @@ -197,7 +200,9 @@ def _slim(n: dict, depth: int = 0) -> dict: out["children"] = [_slim(c, depth + 1) for c in n.get("children", [])] return out - return [TextContent(type="text", text=json.dumps(_slim(node), ensure_ascii=False, indent=2))] + return [ + TextContent(type="text", text=json.dumps(_slim(node), ensure_ascii=False, indent=2)) + ] # ── get_tree ───────────────────────────────────────────────────────────── @@ -214,8 +219,6 @@ def _handle_get_tree(args: dict) -> list[TextContent]: # ── run ────────────────────────────────────────────────────────────────── - import asyncio - async def _run(): async with stdio_server() as (read_stream, write_stream): await server.run(read_stream, write_stream, server.create_initialization_options())