get-list-cards
Retrieve cards from a specific Trello list using the list ID, with options to include specific card fields and apply filters like 'open', 'closed', or 'all'.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Comma-separated list of card fields to include | |
| filter | No | Filter for card types (e.g., "open", "closed", "all") | |
| listId | Yes | ID of the list to get cards from |
Implementation Reference
- src/tools/lists.ts:386-427 (handler)The handler function for the 'get-list-cards' tool. It takes listId (required), fields and filter (optional), checks for API credentials, constructs the Trello API URL for /lists/{listId}/cards, appends query params, fetches the data, and returns JSON stringified response or error.async ({ listId, fields, filter }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const url = new URL(`https://api.trello.com/1/lists/${listId}/cards`); url.searchParams.append('key', credentials.apiKey); url.searchParams.append('token', credentials.apiToken); if (fields) url.searchParams.append('fields', fields); if (filter) url.searchParams.append('filter', filter); const response = await fetch(url.toString()); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting list cards: ${error}`, }, ], isError: true, }; } }
- src/tools/lists.ts:382-385 (schema)Zod schema defining the input parameters for the 'get-list-cards' tool: listId (string), optional fields (string), optional filter (string).listId: z.string().describe('ID of the list to get cards from'), fields: z.string().optional().describe('Comma-separated list of card fields to include'), filter: z.string().optional().describe('Filter for card types (e.g., "open", "closed", "all")'), },
- src/tools/lists.ts:378-428 (registration)Registration of the 'get-list-cards' tool using server.tool(), including inline schema and handler function.// GET /lists/{id}/cards - Get cards from a list server.tool( 'get-list-cards', { listId: z.string().describe('ID of the list to get cards from'), fields: z.string().optional().describe('Comma-separated list of card fields to include'), filter: z.string().optional().describe('Filter for card types (e.g., "open", "closed", "all")'), }, async ({ listId, fields, filter }) => { try { if (!credentials.apiKey || !credentials.apiToken) { return { content: [ { type: 'text', text: 'Trello API credentials are not configured', }, ], isError: true, }; } const url = new URL(`https://api.trello.com/1/lists/${listId}/cards`); url.searchParams.append('key', credentials.apiKey); url.searchParams.append('token', credentials.apiToken); if (fields) url.searchParams.append('fields', fields); if (filter) url.searchParams.append('filter', filter); const response = await fetch(url.toString()); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error getting list cards: ${error}`, }, ], isError: true, }; } } );