add_card_to_list
Create and add a new card to a specified list in Trello, including optional details like description, due date, and labels, for organized task management.
Instructions
Add a new card to a specified list
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Description of the card | |
| dueDate | No | Due date for the card (ISO 8601 format) | |
| labels | No | Array of label IDs to apply to the card | |
| listId | Yes | ID of the list to add the card to | |
| name | Yes | Name of the card |
Implementation Reference
- src/trello-client.ts:100-117 (handler)Core implementation of adding a card to a Trello list via API POST to /cards endpoint with listId, name, etc.async addCard(params: { listId: string; name: string; description?: string; dueDate?: string; labels?: string[]; }): Promise<TrelloCard> { return this.handleRequest(async () => { const response = await this.axiosInstance.post('/cards', { idList: params.listId, name: params.name, desc: params.description, due: params.dueDate, idLabels: params.labels, }); return response.data; }); }
- src/validators.ts:54-71 (schema)Input validation function for add_card_to_list tool parameters.export function validateAddCardRequest(args: Record<string, unknown>): { listId: string; name: string; description?: string; dueDate?: string; labels?: string[]; } { if (!args.listId || !args.name) { throw new McpError(ErrorCode.InvalidParams, 'listId and name are required'); } return { listId: validateString(args.listId, 'listId'), name: validateString(args.name, 'name'), description: validateOptionalString(args.description), dueDate: validateOptionalString(args.dueDate), labels: validateOptionalStringArray(args.labels), }; }
- src/index.ts:98-130 (registration)MCP tool registration including name, description, and input schema for 'add_card_to_list'.{ name: 'add_card_to_list', description: 'Add a new card to a specified list', inputSchema: { type: 'object', properties: { listId: { type: 'string', description: 'ID of the list to add the card to', }, name: { type: 'string', description: 'Name of the card', }, description: { type: 'string', description: 'Description of the card', }, dueDate: { type: 'string', description: 'Due date for the card (ISO 8601 format)', }, labels: { type: 'array', items: { type: 'string', }, description: 'Array of label IDs to apply to the card', }, }, required: ['listId', 'name'], }, },
- src/index.ts:250-256 (handler)MCP CallToolRequest handler case that validates input, calls TrelloClient.addCard, and formats response.case 'add_card_to_list': { const validArgs = validateAddCardRequest(args); const card = await this.trelloClient.addCard(validArgs); return { content: [{ type: 'text', text: JSON.stringify(card, null, 2) }], }; }
- src/types.ts:7-17 (schema)Type definition for TrelloCard, used as return type for addCard operation.export interface TrelloCard { id: string; name: string; desc: string; due: string | null; idList: string; idLabels: string[]; closed: boolean; url: string; dateLastActivity: string; }