Skip to main content
Glama

create-card

Create new Trello cards with specified names and descriptions, organizing tasks directly into designated lists for project management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionNo
listIdYes

Implementation Reference

  • The handler function executes the create-card tool by sending a POST request to the Trello API to create a new card in the specified list, returning the card data or error.
    async ({ name, description, listId }) => {
    	try {
    		const response = await fetch(
    			`https://api.trello.com/1/cards?key=${trelloApiKey}&token=${trelloApiToken}`,
    			{
    				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,
    		};
    	}
    }
  • Zod input schema defining parameters: name (required string), description (optional string), listId (required string).
    {
    	name: z.string(),
    	description: z.string().optional(),
    	listId: z.string(),
    },
  • src/index.ts:79-124 (registration)
    Registration of the 'create-card' tool on the MCP server using server.tool(), including inline schema and handler.
    server.tool(
    	'create-card',
    	{
    		name: z.string(),
    		description: z.string().optional(),
    		listId: z.string(),
    	},
    	async ({ name, description, listId }) => {
    		try {
    			const response = await fetch(
    				`https://api.trello.com/1/cards?key=${trelloApiKey}&token=${trelloApiToken}`,
    				{
    					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,
    			};
    		}
    	}
    );

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/praveencs87/trello-mcp'

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