create_board_label
Add a custom label to a Trello board by specifying its name and color for better organization and visual categorization of tasks.
Instructions
Create label for a specific board.
Args:
board_id (str): The ID of the board whose to add label to.
name (str): The name of the label.
color (str): The color of the label.
Returns:
TrelloLabel: A label object for the board.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| board_id | Yes | ||
| payload | Yes |
Implementation Reference
- server/tools/board.py:80-100 (handler)The MCP tool handler for 'create_board_label' that processes the input payload, calls the BoardService, handles errors, and returns the created TrelloLabel.async def create_board_label(ctx: Context, board_id: str, payload: CreateLabelPayload) -> TrelloLabel: """Create label for a specific board. Args: board_id (str): The ID of the board whose to add label to. name (str): The name of the label. color (str): The color of the label. Returns: TrelloLabel: A label object for the board. """ try: logger.info(f"Creating label {payload.name} label for board: {board_id}") result = await service.create_board_label(board_id, **payload.model_dump(exclude_unset=True)) logger.info(f"Successfully created label {payload.name} labels for board: {board_id}") return result except Exception as e: error_msg = f"Failed to get board labels: {str(e)}" logger.error(error_msg) await ctx.error(error_msg) raise
- server/dtos/create_label.py:1-14 (schema)Pydantic model defining the input schema for the create_board_label tool, with required 'name' and optional 'color' fields.from pydantic import BaseModel class CreateLabelPayload(BaseModel): """ Payload for creating a label. Attributes: name (str): The name of the label. color (str): The color of the label. """ name: str color: str | None = None
- server/tools/tools.py:14-14 (registration)Tool registration line where create_board_label is added to the MCP server.mcp.add_tool(board.create_board_label)
- server/services/board.py:55-66 (helper)Helper method in BoardService that makes the Trello API POST request to create the label and parses the response into TrelloLabel.async def create_board_label(self, board_id: str, **kwargs) -> TrelloLabel: """Create label for a specific board. Args: board_id (str): The ID of the board whose to add label. Returns: List[TrelloLabel]: A list of label objects for the board. """ response = await self.client.POST(f"/boards/{board_id}/labels", data=kwargs) return TrelloLabel(**response)