todoist_get_label
Retrieve a specific Todoist label by its ID to manage and organize tasks more effectively within the Enhanced Todoist MCP Server Extended.
Instructions
Get a specific label by its ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| labelId | Yes | The ID of the label to retrieve. |
Implementation Reference
- src/index.ts:1550-1563 (handler)The main execution handler for the 'todoist_get_label' tool. It validates the input arguments using the isLabelIdArgs type guard, fetches the label using todoistClient.getLabel(labelId), formats the output with formatLabel, and returns a formatted response or error message.if (name === "todoist_get_label") { if (!isLabelIdArgs(args)) { return { content: [{ type: "text", text: "Invalid arguments for get_label" }], isError: true }; } try { const label = await todoistClient.getLabel(args.labelId); return { content: [{ type: "text", text: `Label details:\n${formatLabel(label)}` }], isError: false }; } catch (error: any) { return { content: [{ type: "text", text: `Error getting label: ${error.message}` }], isError: true }; } }
- src/index.ts:305-315 (schema)Defines the Tool object for 'todoist_get_label', including name, description, and input schema that requires a 'labelId' string.const GET_LABEL_TOOL: Tool = { name: "todoist_get_label", description: "Get a specific label by its ID.", inputSchema: { type: "object", properties: { labelId: { type: "string", description: "The ID of the label to retrieve." } }, required: ["labelId"] } };
- src/index.ts:1108-1113 (registration)Registers the GET_LABEL_TOOL (todoist_get_label) in the array of tools returned by the ListToolsRequestSchema handler.// Label tools CREATE_LABEL_TOOL, GET_LABEL_TOOL, GET_LABELS_TOOL, UPDATE_LABEL_TOOL, DELETE_LABEL_TOOL,
- src/index.ts:727-729 (helper)Helper function to format a Todoist label object into a human-readable string for the tool's response.function formatLabel(label: any): string { return `- ${label.name} (ID: ${label.id})${label.color ? `\n Color: ${label.color}` : ''}${label.isFavorite ? `\n Favorite: Yes` : ''}${label.order ? `\n Order: ${label.order}`: ''}`; }
- src/index.ts:982-992 (helper)Type guard helper to validate that the tool arguments contain a valid 'labelId' string property.function isLabelIdArgs(args: unknown): args is { labelId: string; } { return ( typeof args === "object" && args !== null && "labelId" in args && typeof (args as { labelId: string }).labelId === "string" ); }