delete_list
Delete a list from your RTM account. Lists with existing tasks cannot be removed; move or delete tasks first.
Instructions
Delete a list.
Note: Lists with tasks cannot be deleted. Move or delete tasks first.
Args: list_name: Name of the list to delete
Returns: Deletion confirmation with transaction ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/rtm_mcp/tools/lists.py:142-185 (handler)The delete_list tool handler: decorated with @mcp.tool(), it finds a list by name (case-insensitive), checks if it's locked, calls rtm.lists.delete API, and returns confirmation with transaction ID for undo support.
@mcp.tool() async def delete_list( ctx: Context, list_name: str, ) -> dict[str, Any]: """Delete a list. Note: Lists with tasks cannot be deleted. Move or delete tasks first. Args: list_name: Name of the list to delete Returns: Deletion confirmation with transaction ID """ from ..client import RTMClient client: RTMClient = await get_client() # Find list by name lists_result = await client.call("rtm.lists.getList") lists = parse_lists_response(lists_result) list_id = None for lst in lists: if lst["name"].lower() == list_name.lower(): if lst["locked"]: return build_response(data={"error": f"Cannot delete locked list: {list_name}"}) list_id = lst["id"] break if not list_id: return build_response(data={"error": f"List not found: {list_name}"}) result = await client.call( "rtm.lists.delete", require_timeline=True, list_id=list_id, ) return build_response( data={"message": f"Deleted list: {list_name}"}, transaction_id=get_transaction_id(result), ) - src/rtm_mcp/tools/lists.py:142-185 (registration)The @mcp.tool() decorator registers delete_list as an MCP tool. The containing function register_list_tools() is called from server.py line 104.
@mcp.tool() async def delete_list( ctx: Context, list_name: str, ) -> dict[str, Any]: """Delete a list. Note: Lists with tasks cannot be deleted. Move or delete tasks first. Args: list_name: Name of the list to delete Returns: Deletion confirmation with transaction ID """ from ..client import RTMClient client: RTMClient = await get_client() # Find list by name lists_result = await client.call("rtm.lists.getList") lists = parse_lists_response(lists_result) list_id = None for lst in lists: if lst["name"].lower() == list_name.lower(): if lst["locked"]: return build_response(data={"error": f"Cannot delete locked list: {list_name}"}) list_id = lst["id"] break if not list_id: return build_response(data={"error": f"List not found: {list_name}"}) result = await client.call( "rtm.lists.delete", require_timeline=True, list_id=list_id, ) return build_response( data={"message": f"Deleted list: {list_name}"}, transaction_id=get_transaction_id(result), ) - src/rtm_mcp/tools/lists.py:15-16 (registration)The register_list_tools function that wraps all list tool registrations including delete_list.
def register_list_tools(mcp: Any, get_client: Any) -> None: """Register all list-related tools.""" - src/rtm_mcp/server.py:102-106 (registration)Registration call: register_list_tools(mcp, get_client) at server startup which includes delete_list.
# Register all tools register_task_tools(mcp, get_client) register_list_tools(mcp, get_client) register_note_tools(mcp, get_client) register_utility_tools(mcp, get_client) - parse_lists_response helper used by delete_list to find the list by name.
def parse_lists_response(result: dict[str, Any]) -> list[dict[str, Any]]: """Parse RTM lists response.""" lists = result.get("lists", {}).get("list", []) if isinstance(lists, dict): lists = [lists] return [ { "id": lst.get("id"), "name": lst.get("name"), "deleted": lst.get("deleted") == "1", "locked": lst.get("locked") == "1", "archived": lst.get("archived") == "1", "position": int(lst.get("position", -1)), "smart": lst.get("smart") == "1", "filter": lst.get("filter"), "sort_order": lst.get("sort_order"), } for lst in lists ] def get_transaction_id(result: dict[str, Any]) -> str | None: """Extract transaction ID from response for undo support.""" transaction = result.get("transaction", {}) return transaction.get("id")