diff --git a/Dockerfile b/Dockerfile index 9197ece..987d692 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.10 \ No newline at end of file +#harbor.freshbrewed.science/library/vikunjamcp:0.11 \ No newline at end of file diff --git a/main.py b/main.py index 4f45afa..1a6e6cb 100644 --- a/main.py +++ b/main.py @@ -136,7 +136,57 @@ def add_task(project_id: int, title: str, description: str = ""): except requests.exceptions.RequestException as e: return f"Error adding task: {e}" +@mcp.tool() +def close_task(task_id: int): + """ + Closes (marks as done) a task in Vikunja. + + :param task_id: The ID of the task to close. + """ + if "Authorization" not in session.headers: + return "Please run the 'login' command first." + + task_payload = { + "done": True + } + + try: + response = session.post( + f"{VIKUNJA_URL}/api/v1/tasks/{task_id}", + json=task_payload + ) + response.raise_for_status() + return response.json() + except requests.exceptions.RequestException as e: + return f"Error closing task: {e}" + +@mcp.tool() +def lookup_project(): + """ + Retrieves all projects the user has access to and lists them by name and ID. + """ + if "Authorization" not in session.headers: + return "Please run the 'login' command first." + + try: + response = session.get(f"{VIKUNJA_URL}/api/v1/projects") + response.raise_for_status() + projects = response.json() + + if not projects: + return "No projects found." + + result = [] + for project in projects: + project_id = project.get("id", "N/A") + project_title = project.get("title", "Untitled") + result.append(f"ID: {project_id}, Name: {project_title}") + + return "\n".join(result) + except requests.exceptions.RequestException as e: + return f"Error retrieving projects: {e}" + if __name__ == "__main__": print("--- Vikunja MCP Client ---") - print("Available commands: login, search_tasks, add_task, help, exit") + print("Available commands: login, search_tasks, add_task, close_task, lookup_project, help, exit") mcp.run()