Skip to main content
Glama
m0xai

Trello MCP Server with Python

by m0xai

create_card

Add new tasks to Trello lists by creating cards with names, descriptions, due dates, and assignees.

Instructions

Creates a new card in a given list.

Args:
    list_id (str): The ID of the list to create the card in.
    name (str): The name of the new card.
    desc (str, optional): The description of the new card. Defaults to None.

Returns:
    TrelloCard: The newly created card object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
payloadYes

Implementation Reference

  • The MCP tool handler function for create_card, which validates input with CreateCardPayload, logs the action, calls the CardService, and handles errors.
    async def create_card(ctx: Context, payload: CreateCardPayload) -> TrelloCard:
        """Creates a new card in a given list.
    
        Args:
            list_id (str): The ID of the list to create the card in.
            name (str): The name of the new card.
            desc (str, optional): The description of the new card. Defaults to None.
    
        Returns:
            TrelloCard: The newly created card object.
        """
        try:
            logger.info(f"Creating card in list {payload.idList} with name: {payload.name}")
            result = await service.create_card(**payload.model_dump(exclude_unset=True))
            logger.info(f"Successfully created card in list: {payload.idList}")
            return result
        except Exception as e:
            error_msg = f"Failed to create card: {str(e)}"
            logger.error(error_msg)
            await ctx.error(error_msg)
            raise
  • Pydantic model defining the input schema (payload) for the create_card tool, including fields like name, idList, desc, etc.
    class CreateCardPayload(BaseModel):
        """
        Payload for creating a card.
    
        Attributes:
            name (str): The name of the card.
            desc (str): The description of the card.
            closed (bool): Whether the card is closed or not.
            idMembers (str): Comma-separated list of member IDs for the card.
            idList (str): The ID of the list the card is in.
            idLabels (str): Comma-separated list of label IDs for the card.
            idBoard (str): The ID of the board the card is in.
            pos (str | int): The position of the card.
            due (str): The due date of the card in ISO 8601 format.
            start (str): The start date of the card in ISO 8601 format.
            dueComplete (bool): Whether the card is due complete or not.
            subscribed (bool): Whether the card is subscribed or not.
        """
    
        name: str
        desc: str | None = None
        closed: bool | None = None
        idMembers: str | None = None
        idList: str
        idLabels: str | None = None
        idBoard: str | None = None
        pos: str | None = None
        due: str | None = None
        start: str | None = None
        dueComplete: bool | None = None
        subscribed: bool | None = None
  • Registration of the create_card tool handler with the MCP server using mcp.add_tool.
    mcp.add_tool(card.create_card)
  • Supporting service method in CardService that performs the actual Trello API call to create a card using POST /cards.
    async def create_card(self, **kwargs) -> TrelloCard:
        """Creates a new card in a given list.
    
        Args
            list_id (str): The ID of the list to create the card in.
            name (str): The name of the new card.
            desc (str, optional): The description of the new card. Defaults to None.
    
        Returns:
            TrelloCard: The newly created card object.
        """
        response = await self.client.POST("/cards", data=kwargs)
        return TrelloCard(**response)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/m0xai/trello-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server