rootly-mcp-server 2.1.1__py3-none-any.whl → 2.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rootly_mcp_server/och_client.py +71 -0
- rootly_mcp_server/server.py +1323 -0
- {rootly_mcp_server-2.1.1.dist-info → rootly_mcp_server-2.1.3.dist-info}/METADATA +38 -164
- {rootly_mcp_server-2.1.1.dist-info → rootly_mcp_server-2.1.3.dist-info}/RECORD +7 -6
- {rootly_mcp_server-2.1.1.dist-info → rootly_mcp_server-2.1.3.dist-info}/WHEEL +0 -0
- {rootly_mcp_server-2.1.1.dist-info → rootly_mcp_server-2.1.3.dist-info}/entry_points.txt +0 -0
- {rootly_mcp_server-2.1.1.dist-info → rootly_mcp_server-2.1.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""On-Call Health API client for burnout risk analysis."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class OnCallHealthClient:
|
|
10
|
+
def __init__(self, api_key: str | None = None, base_url: str | None = None):
|
|
11
|
+
self.api_key: str = api_key or os.environ.get("ONCALLHEALTH_API_KEY", "")
|
|
12
|
+
self.base_url: str = base_url or os.environ.get(
|
|
13
|
+
"ONCALLHEALTH_API_URL", "https://api.oncallhealth.ai"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
async def get_analysis(self, analysis_id: int) -> dict[str, Any]:
|
|
17
|
+
"""Fetch analysis by ID."""
|
|
18
|
+
async with httpx.AsyncClient() as client:
|
|
19
|
+
response = await client.get(
|
|
20
|
+
f"{self.base_url}/analyses/{analysis_id}",
|
|
21
|
+
headers={"X-API-Key": self.api_key},
|
|
22
|
+
timeout=30.0,
|
|
23
|
+
)
|
|
24
|
+
response.raise_for_status()
|
|
25
|
+
return response.json()
|
|
26
|
+
|
|
27
|
+
async def get_latest_analysis(self) -> dict[str, Any]:
|
|
28
|
+
"""Fetch most recent analysis."""
|
|
29
|
+
async with httpx.AsyncClient() as client:
|
|
30
|
+
response = await client.get(
|
|
31
|
+
f"{self.base_url}/analyses",
|
|
32
|
+
headers={"X-API-Key": self.api_key},
|
|
33
|
+
params={"limit": 1},
|
|
34
|
+
timeout=30.0,
|
|
35
|
+
)
|
|
36
|
+
response.raise_for_status()
|
|
37
|
+
data = response.json()
|
|
38
|
+
analyses = data.get("analyses", [])
|
|
39
|
+
if not analyses:
|
|
40
|
+
raise ValueError("No analyses found")
|
|
41
|
+
return analyses[0]
|
|
42
|
+
|
|
43
|
+
def extract_at_risk_users(
|
|
44
|
+
self, analysis: dict[str, Any], threshold: float = 50.0
|
|
45
|
+
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
|
|
46
|
+
"""Extract at-risk and safe users from analysis."""
|
|
47
|
+
members = analysis.get("analysis_data", {}).get("team_analysis", {}).get("members", [])
|
|
48
|
+
|
|
49
|
+
at_risk: list[dict[str, Any]] = []
|
|
50
|
+
safe: list[dict[str, Any]] = []
|
|
51
|
+
|
|
52
|
+
for member in members:
|
|
53
|
+
user_data: dict[str, Any] = {
|
|
54
|
+
"user_name": member.get("user_name"),
|
|
55
|
+
"rootly_user_id": member.get("rootly_user_id"),
|
|
56
|
+
"och_score": member.get("och_score", 0),
|
|
57
|
+
"risk_level": member.get("risk_level", "unknown"),
|
|
58
|
+
"burnout_score": member.get("burnout_score", 0),
|
|
59
|
+
"incident_count": member.get("incident_count", 0),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if user_data["och_score"] >= threshold:
|
|
63
|
+
at_risk.append(user_data)
|
|
64
|
+
elif user_data["och_score"] < 20: # Safe threshold
|
|
65
|
+
safe.append(user_data)
|
|
66
|
+
|
|
67
|
+
# Sort at-risk by score descending, safe by score ascending
|
|
68
|
+
at_risk.sort(key=lambda x: x["och_score"], reverse=True)
|
|
69
|
+
safe.sort(key=lambda x: x["och_score"])
|
|
70
|
+
|
|
71
|
+
return at_risk, safe
|