Update to add two new tools, update tag to 0.11
CICD / Explore-Gitea-Actions (push) Successful in 35s Details

This commit is contained in:
Isaac Johnson 2025-10-09 09:46:10 -05:00
parent 0a067c37ba
commit a429c41153
2 changed files with 52 additions and 2 deletions

View File

@ -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
#harbor.freshbrewed.science/library/vikunjamcp:0.11

52
main.py
View File

@ -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()