Skip to main content
Glama
projects.ts1.34 kB
import { getTodoistClient } from '../client'; import { ensureCacheDirectory, tryReadFromCache, createCachedResult, writeToCache, } from '../../cache/project-cache'; import { TodoistProject } from '../../types'; import { getErrorMessage } from '../../utils'; interface ProjectsResponse { projects: TodoistProject[]; total_count: number; } // Helper function to fetch projects from API async function fetchProjectsFromAPI(): Promise<ProjectsResponse> { const todoistClient = getTodoistClient(); const apiResponse = await todoistClient.get<TodoistProject[]>('/projects'); return { projects: apiResponse.data, total_count: apiResponse.data.length, }; } // List projects function with caching - returns structured data export async function listProjects(): Promise< ProjectsResponse & { cached_at?: string } > { try { ensureCacheDirectory(); const cachedData = tryReadFromCache(); if (cachedData) { return cachedData; } const projectsData = await fetchProjectsFromAPI(); const result = createCachedResult(projectsData); writeToCache(result); return result; } catch (error) { throw new Error(`Failed to list projects: ${getErrorMessage(error)}`); } } // Export types for testing - TodoistProject is now imported from types.ts export type { ProjectsResponse };

Implementation Reference

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/bkotos/todoist-mcp'

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