-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcase_resources.py
More file actions
65 lines (57 loc) · 2.08 KB
/
Copy pathcase_resources.py
File metadata and controls
65 lines (57 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Case law and precedent resources."""
from __future__ import annotations
import json
from demo_mode import demo_data_disabled_payload, demo_payload
from utils import audit, get_data_manager
def register_case_resources(mcp) -> None:
"""Register all case resources with the MCP server."""
data = get_data_manager()
@mcp.resource("legal://case-database")
def case_database() -> str:
"""Legal precedent index."""
audit("resource_case_database")
if not data.demo_mode:
return json.dumps(
demo_data_disabled_payload("Local case database resource"), indent=2
)
index = [
{
"source": "demo_seed",
"authoritative": False,
"id": c["id"],
"name": c["name"],
"citation": c["citation"],
"court": c["court"],
"jurisdiction": c["jurisdiction"],
"year": c["year"],
"topics": c.get("topics", []),
}
for c in data.cases.values()
]
return json.dumps(demo_payload(count=len(index), cases=index), indent=2)
@mcp.resource("legal://case/{case_id}/analysis")
def case_analysis(case_id: str) -> str:
"""Case analysis with holding, summary, and citation graph."""
audit("resource_case_analysis", case_id=case_id)
if not data.demo_mode:
return json.dumps(
demo_data_disabled_payload("Demo case analysis resource"), indent=2
)
case = data.get_case(case_id)
if case is None:
return json.dumps(
demo_payload(case_id=case_id, error="Case not found."), indent=2
)
cited = [
{"id": cid, "name": data.cases.get(cid, {}).get("name")}
for cid in case.get("cites", [])
]
return json.dumps(
demo_payload(
source="demo_seed",
authoritative=False,
**case,
cited_authorities=cited,
),
indent=2,
)