(workspaceId?: string)
| 781 | } |
| 782 | |
| 783 | async clearCache(workspaceId?: string): Promise<void> { |
| 784 | try { |
| 785 | if (workspaceId) { |
| 786 | // No enabled/deletedAt filter so disabled and soft-deleted rows are |
| 787 | // cleared too. Hard-deleted rows are gone from the table; their keys |
| 788 | // expire via TTL. |
| 789 | const rows = await db |
| 790 | .select({ id: mcpServers.id }) |
| 791 | .from(mcpServers) |
| 792 | .where(eq(mcpServers.workspaceId, workspaceId)) |
| 793 | await Promise.allSettled( |
| 794 | rows.flatMap((r) => [ |
| 795 | this.cacheAdapter.delete(serverCacheKey(workspaceId, r.id)), |
| 796 | this.cacheAdapter.delete(failureCacheKey(workspaceId, r.id)), |
| 797 | ]) |
| 798 | ) |
| 799 | logger.debug(`Cleared MCP tool cache for workspace ${workspaceId} (${rows.length} servers)`) |
| 800 | } else { |
| 801 | await this.cacheAdapter.clear() |
| 802 | logger.debug('Cleared all MCP tool cache') |
| 803 | } |
| 804 | } catch (error) { |
| 805 | logger.warn('Failed to clear cache:', error) |
| 806 | } |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | export const mcpService = new McpService() |
no test coverage detected