Some checks failed
Build and push DevOpsDash / build (push) Has been cancelled
- Taskz kanban board (create/edit tasks, findings, status/priority) - Worklog timeline + standup summary (proxied from DevOpsMCP MCP API) - Knowledge browser (ADRs, memories, knowledge catalog files) - FastAPI backend reading same Redis as DevOpsMCP - Read-only bind-mount for DevOpsMCP data directory (/data) - Nomad job spec (dash.i80.dk, Traefik TLS, host volume read-only) - Gitea Actions CI → registry.i80.dk/gitea/devops-dash:latest
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
"""MCP proxy client — calls DevOpsMCP's worklog/standup tools over HTTP MCP protocol."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from typing import Any, Dict, Optional
|
|
|
|
import httpx
|
|
|
|
MCP_URL = os.environ.get("DEVOPS_MCP_URL", "http://localhost:8000")
|
|
_MCP_ENDPOINT = f"{MCP_URL}/mcp"
|
|
|
|
|
|
async def _call_tool(tool_name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""Call a DevOpsMCP tool via MCP JSON-RPC 2.0 over HTTP."""
|
|
payload = {
|
|
"jsonrpc": "2.0",
|
|
"method": "tools/call",
|
|
"params": {"name": tool_name, "arguments": arguments},
|
|
"id": 1,
|
|
}
|
|
async with httpx.AsyncClient(timeout=30.0) as client:
|
|
resp = await client.post(_MCP_ENDPOINT, json=payload)
|
|
resp.raise_for_status()
|
|
data = resp.json()
|
|
if "error" in data:
|
|
raise RuntimeError(f"MCP error: {data['error']}")
|
|
result = data.get("result", {})
|
|
content = result.get("content", [])
|
|
if content and isinstance(content[0], dict):
|
|
import json
|
|
text = content[0].get("text", "{}")
|
|
try:
|
|
return json.loads(text)
|
|
except json.JSONDecodeError:
|
|
return {"raw": text}
|
|
return result
|
|
|
|
|
|
async def get_worklog(
|
|
context: str = "egmont",
|
|
days: int = 7,
|
|
group_by: str = "repo",
|
|
since_date: Optional[str] = None,
|
|
until_date: Optional[str] = None,
|
|
) -> Dict[str, Any]:
|
|
args: Dict[str, Any] = {"context": context, "days": days, "group_by": group_by}
|
|
if since_date:
|
|
args["since_date"] = since_date
|
|
if until_date:
|
|
args["until_date"] = until_date
|
|
return await _call_tool("worklog", args)
|
|
|
|
|
|
async def get_standup(days: int = 2, context: str = "egmont") -> Dict[str, Any]:
|
|
return await _call_tool("generate_standup", {"days": days, "context": context})
|