diff --git a/mcp-server/src/legal_mcp/server.py b/mcp-server/src/legal_mcp/server.py index a9420e3..3922e89 100644 --- a/mcp-server/src/legal_mcp/server.py +++ b/mcp-server/src/legal_mcp/server.py @@ -922,6 +922,18 @@ async def list_chair_feedback( return await workflow.list_chair_feedback(case_number, category, unresolved_only) +@mcp.tool() +async def halacha_corroboration(halacha_id: str) -> dict: + """החזר את ה-corroboration של הלכה: הציטוטים שמתקפים אותה, הטיפול, וסיכום (X11, read-only).""" + from uuid import UUID + from legal_mcp.services import corroboration as cor, db + links = await db.list_corroboration_for_halacha(UUID(halacha_id)) + agg = cor.aggregate( + [{"source_id": (l["citing_case_law_id"] or l["citing_decision_id"] or ""), "treatment": l["treatment"]} for l in links] + ) + return {"halacha_id": halacha_id, "summary": agg, "citations": links} + + def main(): mcp.run(transport="stdio") diff --git a/mcp-server/src/legal_mcp/services/db.py b/mcp-server/src/legal_mcp/services/db.py index d2ee6df..e863758 100644 --- a/mcp-server/src/legal_mcp/services/db.py +++ b/mcp-server/src/legal_mcp/services/db.py @@ -3439,6 +3439,28 @@ async def store_corroboration( ) +async def list_corroboration_for_halacha(halacha_id: UUID) -> list[dict]: + """Return all corroboration rows for one halacha, ordered by match_score DESC.""" + pool = await get_pool() + rows = await pool.fetch( + "SELECT treatment, match_score, match_context, citing_case_law_id::text, " + " citing_decision_id::text, created_at " + "FROM halacha_citation_corroboration WHERE halacha_id = $1 " + "ORDER BY match_score DESC", halacha_id, + ) + return [ + { + "treatment": r["treatment"], + "match_score": float(r["match_score"]) if r["match_score"] is not None else None, + "match_context": r["match_context"], + "citing_case_law_id": r["citing_case_law_id"], + "citing_decision_id": r["citing_decision_id"], + "created_at": r["created_at"].isoformat() if r["created_at"] else None, + } + for r in rows + ] + + async def search_precedent_library_semantic( query_embedding: list[float], practice_area: str = "",