""" This module contains tools for managing Trello lists. """ import logging from typing import List from mcp.server.fastmcp import Context from pmcp.mcp_server.trello_server.models import TrelloList from pmcp.mcp_server.trello_server.services.list import ListService from pmcp.mcp_server.trello_server.trello import trello_client service = ListService(trello_client) # List Tools async def get_list(ctx: Context, list_id: str) -> TrelloList: """Retrieves a specific list by its ID. Args: list_id (str): The ID of the list to retrieve. Returns: TrelloList: The list object containing list details. """ try: result = await service.get_list(list_id) return result except Exception as e: error_msg = f"Failed to get list: {str(e)}" await ctx.error(error_msg) raise async def get_lists(ctx: Context, board_id: str) -> List[TrelloList]: """Retrieves all lists on a given board. Args: board_id (str): The ID of the board whose lists to retrieve. Returns: List[TrelloList]: A list of list objects. """ try: result = await service.get_lists(board_id) return result except Exception as e: error_msg = f"Failed to get lists: {str(e)}" await ctx.error(error_msg) raise async def create_list( ctx: Context, board_id: str, name: str, pos: str = "bottom" ) -> TrelloList: """Creates a new list on a given board. Args: board_id (str): The ID of the board to create the list in. name (str): The name of the new list. pos (str, optional): The position of the new list. Can be "top" or "bottom". Defaults to "bottom". Returns: TrelloList: The newly created list object. """ try: result = await service.create_list(board_id, name, pos) return result except Exception as e: error_msg = f"Failed to create list: {str(e)}" await ctx.error(error_msg) raise async def update_list(ctx: Context, list_id: str, name: str) -> TrelloList: """Updates the name of a list. Args: list_id (str): The ID of the list to update. name (str): The new name for the list. Returns: TrelloList: The updated list object. """ try: result = await service.update_list(list_id, name) return result except Exception as e: error_msg = f"Failed to update list: {str(e)}" await ctx.error(error_msg) raise async def delete_list(ctx: Context, list_id: str) -> TrelloList: """Archives a list. Args: list_id (str): The ID of the list to close. Returns: TrelloList: The archived list object. """ try: result = await service.delete_list(list_id) return result except Exception as e: error_msg = f"Failed to delete list: {str(e)}" await ctx.error(error_msg) raise