Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
23 changes: 13 additions & 10 deletions catchme/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from __future__ import annotations

import asyncio
import json
import logging

Expand All @@ -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")

Expand Down Expand Up @@ -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 ──────────────────────────────────────────────────────────
Expand Down Expand Up @@ -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 ─────────────────────────────────────────────────────────────

Expand All @@ -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())
Expand Down
Loading