toggl_warm_cache
Pre-fetches and caches workspace, project, and client data to improve performance for time tracking operations.
Instructions
Pre-fetch and cache workspace, project, and client data for better performance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_id | No | Specific workspace to warm cache for |
Implementation Reference
- src/index.ts:352-364 (registration)Tool registration in the tools array with name, description, and input schema.{ name: 'toggl_warm_cache', description: 'Pre-fetch and cache workspace, project, and client data for better performance', inputSchema: { type: 'object', properties: { workspace_id: { type: 'number', description: 'Specific workspace to warm cache for' } } }, },
- src/index.ts:774-791 (handler)The switch case handler that extracts workspace_id from arguments, calls cache.warmCache, updates cacheWarmed flag, retrieves stats, and returns success response with stats.case 'toggl_warm_cache': { const workspaceId = (args?.workspace_id as number | undefined) || defaultWorkspaceId; await cache.warmCache(workspaceId); cacheWarmed = true; const stats = cache.getStats(); return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Cache warmed successfully', stats }, null, 2) }] }; }
- src/cache-manager.ts:272-302 (helper)The CacheManager.warmCache method which pre-fetches and caches workspaces, projects, clients, and tags for the specified workspace or the first 3 workspaces.async warmCache(workspaceId?: number): Promise<void> { // Log to stderr to avoid interfering with MCP stdio protocol console.error('Warming cache...'); try { // Fetch all workspaces const workspaces = await this.getWorkspaces(); // If workspace specified, fetch its entities if (workspaceId) { await Promise.all([ this.getProjects(workspaceId), this.getClients(workspaceId), this.getTags(workspaceId) ]); } else { // Fetch entities for all workspaces (be careful with rate limits) for (const ws of workspaces.slice(0, 3)) { // Limit to first 3 workspaces await Promise.all([ this.getProjects(ws.id), this.getClients(ws.id), this.getTags(ws.id) ]); } } console.error('Cache warmed successfully'); } catch (error) { console.error('Failed to warm cache:', error); } }