diff --git a/Dockerfile b/Dockerfile index 987d692..cddba7a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,4 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["python", "main.py"] -#harbor.freshbrewed.science/library/vikunjamcp:0.11 \ No newline at end of file +#harbor.freshbrewed.science/library/vikunjamcp:0.12 \ No newline at end of file diff --git a/gemini-extension.json b/gemini-extension.json index 4d2567d..9ac19dd 100644 --- a/gemini-extension.json +++ b/gemini-extension.json @@ -1,6 +1,6 @@ { "name": "vikunja", - "version": "1.0.11", + "version": "1.0.12", "mcpServers": { "nodeServer": { "command": "docker", @@ -14,7 +14,7 @@ "VIKUNJA_USERNAME", "-e", "VIKUNJA_PASSWORD", - "harbor.freshbrewed.science/library/vikunjamcp:0.11" + "harbor.freshbrewed.science/library/vikunjamcp:0.12" ], "env": { "VIKUNJA_URL": "$VIKUNJA_URL", diff --git a/main.py b/main.py index 1a6e6cb..c994f34 100644 --- a/main.py +++ b/main.py @@ -160,6 +160,33 @@ def close_task(task_id: int): except requests.exceptions.RequestException as e: return f"Error closing task: {e}" +@mcp.tool() +def comment_task(task_id: int, description: str): + """ + Adds a comment to a task in Vikunja. + + :param task_id: The ID of the task to comment on. + :param description: The text of the comment to add. + """ + if "Authorization" not in session.headers: + return "Please run the 'login' command first." + + if not (description or "").strip(): + return "Comment description cannot be empty." + + payload = {"text": description} + + try: + response = session.post( + f"{VIKUNJA_URL}/api/v1/tasks/{task_id}/comments", + json=payload + ) + response.raise_for_status() + return response.json() + except requests.exceptions.RequestException as e: + logger.exception("comment_task: request failed for task_id=%s", task_id) + return f"Error adding comment to task: {e}" + @mcp.tool() def lookup_project(): """ @@ -186,6 +213,39 @@ def lookup_project(): except requests.exceptions.RequestException as e: return f"Error retrieving projects: {e}" + +@mcp.tool() +def create_project(title: str, description: str = "", is_favorite: bool = False): + """ + Creates a new project in Vikunja. + + :param title: The title of the project. + :param description: Optional description for the project. + :param is_favorite: Whether the project should be marked as favorite. + """ + if "Authorization" not in session.headers: + return "Please run the 'login' command first." + + if not (title or "").strip(): + return "Project title cannot be empty." + + payload = { + "title": title, + "description": description, + "is_favourite": bool(is_favorite) + } + + try: + response = session.put( + f"{VIKUNJA_URL}/api/v1/projects", + json=payload + ) + response.raise_for_status() + return response.json() + except requests.exceptions.RequestException as e: + logger.exception("create_project: request failed for title=%s", title) + return f"Error creating project: {e}" + if __name__ == "__main__": print("--- Vikunja MCP Client ---") print("Available commands: login, search_tasks, add_task, close_task, lookup_project, help, exit")