Skip to main content
Glama

get-label

Retrieve specific Trello label details by ID to access color, name, and board information for project organization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelIdYesID of the label to retrieve
fieldsNoComma-separated list of fields to include

Implementation Reference

  • The handler function for the 'get-label' tool. It retrieves a specific Trello label by its ID using the Trello API, with optional fields parameter, handles credentials check, makes a GET request, and returns the JSON data or error.
    async ({ labelId, fields }) => {
    	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/labels/${labelId}`);
    		url.searchParams.append('key', credentials.apiKey);
    		url.searchParams.append('token', credentials.apiToken);
    		if (fields) url.searchParams.append('fields', fields);
    
    		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 label: ${error}`,
    				},
    			],
    			isError: true,
    		};
    	}
    }
  • Zod input schema for 'get-label' tool: labelId (string, required), fields (string, optional).
    {
    	labelId: z.string().describe('ID of the label to retrieve'),
    	fields: z.string().optional().describe('Comma-separated list of fields to include')
    },
  • Registration of the 'get-label' tool using server.tool(), including the tool name, schema, and handler function.
    server.tool(
    	'get-label',
    	{
    		labelId: z.string().describe('ID of the label to retrieve'),
    		fields: z.string().optional().describe('Comma-separated list of fields to include')
    	},
    	async ({ labelId, fields }) => {
    		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/labels/${labelId}`);
    			url.searchParams.append('key', credentials.apiKey);
    			url.searchParams.append('token', credentials.apiToken);
    			if (fields) url.searchParams.append('fields', fields);
    
    			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 label: ${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/adriangrahldev/advanced-trello-mcp-server'

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