diff --git a/Dockerfile b/Dockerfile index 290a985..b98eb56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ FROM python:3.12-slim -RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client && rm -rf /var/lib/apt/lists/* - WORKDIR /app COPY pyproject.toml . RUN pip install --no-cache-dir -e ".[mcp]" diff --git a/corvid/main.py b/corvid/main.py index 8d95dbb..4a76446 100644 --- a/corvid/main.py +++ b/corvid/main.py @@ -34,7 +34,7 @@ async def root(): @app.get("/tickets", response_class=HTMLResponse, include_in_schema=False) async def tickets_page(request: Request): return templates.TemplateResponse( - request, "tickets.html", {"active_page": "tickets"} + "tickets.html", {"request": request, "active_page": "tickets"} ) diff --git a/corvid/router.py b/corvid/router.py index f63331f..2c8df8c 100644 --- a/corvid/router.py +++ b/corvid/router.py @@ -159,7 +159,9 @@ def make_router(api_key: str, get_db, require_user=None) -> APIRouter: return {"username": "claude", "email": "claude@internal"} if require_user is not None: return require_user(request) - return {"username": "local", "email": "local@localhost"} + if not api_key: + return {"username": "local", "email": "local@localhost"} + raise HTTPException(401, "unauthorized") # ── Environment endpoints ───────────────────────────────────────────────── diff --git a/entrypoint.sh b/entrypoint.sh index 1c0f93b..2b9f254 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,10 +1,4 @@ #!/bin/sh set -e - -until pg_isready -q -h postgres; do - echo "Waiting for postgres..." - sleep 2 -done - alembic upgrade head exec uvicorn corvid.main:app --host 0.0.0.0 --port 8080 diff --git a/mcp_server.py b/mcp_server.py index 94974c7..c2232ad 100644 --- a/mcp_server.py +++ b/mcp_server.py @@ -229,30 +229,33 @@ def delete_ticket(ticket_id: int) -> dict: @mcp.tool() def update_ticket( - ticket_id: int, - title: str = "", - description: str = "", - status: str = "", - type: str = "", - user: str = "", - parent_id: int = -1, - effort: int = -1, + ticket_id: int, + title: str = "", + description: str = "", + status: str = "", + type: str = "", + user: str = "", + parent_id: int = -1, + effort: int = -1, + environment_id: int = -1, ) -> dict: """ Update an existing homelab ticket. Only provided (non-empty) fields are changed; omit a field to leave it unchanged. Args: - ticket_id: The integer ID of the ticket to update. - title: New title. - description: New markdown description. - status: open, ongoing, completed, abandoned. - type: feature, bug, chore, project. - user: kevin or claude. - parent_id: Set parent ticket ID; pass 0 to clear the parent. - Omit (default -1) to leave unchanged. - effort: Effort rating 1–10; pass 0 to clear it. - Omit (default -1) to leave unchanged. + ticket_id: The integer ID of the ticket to update. + title: New title. + description: New markdown description. + status: open, ongoing, completed, abandoned. + type: feature, bug, chore, project. + user: kevin or claude. + parent_id: Set parent ticket ID; pass 0 to clear the parent. + Omit (default -1) to leave unchanged. + effort: Effort rating 1–10; pass 0 to clear it. + Omit (default -1) to leave unchanged. + environment_id: Move ticket to a different environment by ID. + Omit (default -1) to leave unchanged. """ body = {} if title: body["title"] = title @@ -264,6 +267,8 @@ def update_ticket( body["parent_id"] = parent_id if parent_id > 0 else None if effort >= 0: body["effort"] = effort if effort > 0 else None + if environment_id >= 0: + body["environment_id"] = environment_id if environment_id > 0 else None if not body: raise ValueError("Provide at least one field to update") with _client() as c: