Update to add two new tools, update tag to 0.11
	
		
			
	
		
	
	
		
			
				
	
				CICD / Explore-Gitea-Actions (push) Successful in 35s
				
					Details
				
			
		
	
				
					
				
			
				
	
				CICD / Explore-Gitea-Actions (push) Successful in 35s
				
					Details
				
			
		
	This commit is contained in:
		
							parent
							
								
									0a067c37ba
								
							
						
					
					
						commit
						a429c41153
					
				| 
						 | 
				
			
			@ -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
								
								
								
								
							
							
						
						
									
										52
									
								
								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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue