create-card
Add new cards to Trello lists to organize tasks and projects, specifying name, description, and target list for structured project management.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the card | |
| description | No | Description of the card | |
| listId | Yes | ID of the list to create the card in |
Implementation Reference
- src/tools/cards.ts:18-56 (handler)The asynchronous handler function that executes the logic to create a new Trello card by making a POST request to the Trello API.async ({ name, description, listId }) => { try { const response = await fetch( `https://api.trello.com/1/cards?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name, desc: description || '', idList: listId, pos: 'bottom', }), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating card: ${error}`, }, ], isError: true, }; } } );
- src/tools/cards.ts:14-17 (schema)Zod schema defining the input parameters for the create-card tool: name (required), description (optional), listId (required).name: z.string().describe('Name of the card'), description: z.string().optional().describe('Description of the card'), listId: z.string().describe('ID of the list to create the card in'), },
- src/tools/cards.ts:11-56 (registration)The server.tool() call that registers the 'create-card' tool with its schema and handler function.server.tool( 'create-card', { name: z.string().describe('Name of the card'), description: z.string().optional().describe('Description of the card'), listId: z.string().describe('ID of the list to create the card in'), }, async ({ name, description, listId }) => { try { const response = await fetch( `https://api.trello.com/1/cards?key=${credentials.apiKey}&token=${credentials.apiToken}`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name, desc: description || '', idList: listId, pos: 'bottom', }), } ); const data = await response.json(); return { content: [ { type: 'text', text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating card: ${error}`, }, ], isError: true, }; } } );
- src/index.ts:90-90 (registration)Call to registerCardsTools which includes the create-card tool registration.registerCardsTools(server, credentials);