diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f02264400..208422386 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 with: - bun-version: 1.3.4 + bun-version: 1.3.6 - name: Install dependencies run: bun install --frozen-lockfile diff --git a/.github/workflows/publish-ai-sdk.yml b/.github/workflows/publish-ai-sdk.yml index 848c7a71a..27817b200 100644 --- a/.github/workflows/publish-ai-sdk.yml +++ b/.github/workflows/publish-ai-sdk.yml @@ -31,9 +31,6 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - name: Install dependencies run: bun install diff --git a/.github/workflows/publish-memory-graph.yml b/.github/workflows/publish-memory-graph.yml index 295a45f68..66dcbf3c7 100644 --- a/.github/workflows/publish-memory-graph.yml +++ b/.github/workflows/publish-memory-graph.yml @@ -31,9 +31,6 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - name: Install dependencies run: bun install diff --git a/.github/workflows/publish-tools.yml b/.github/workflows/publish-tools.yml index 9d745203c..46a56329a 100644 --- a/.github/workflows/publish-tools.yml +++ b/.github/workflows/publish-tools.yml @@ -31,9 +31,6 @@ jobs: - name: Setup Bun uses: oven-sh/setup-bun@v2 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - name: Install dependencies run: bun install diff --git a/apps/mcp/src/server.ts b/apps/mcp/src/server.ts index d387fde94..682e75c14 100644 --- a/apps/mcp/src/server.ts +++ b/apps/mcp/src/server.ts @@ -24,9 +24,12 @@ type Props = { name?: string } +const CONTAINER_TAGS_TTL_MS = 5 * 60 * 1000 + export class SupermemoryMCP extends McpAgent { private clientInfo: { name: string; version?: string } | null = null private cachedContainerTags: string[] = [] + private containerTagsLastFetchedAt: number | null = null server = new McpServer({ name: "supermemory", @@ -168,8 +171,8 @@ export class SupermemoryMCP extends McpAgent { "supermemory://projects", {}, async () => { - const client = this.getClient() - const projects = await client.getProjects() + await this.ensureContainerTagsFresh() + const projects = this.cachedContainerTags return { contents: [ @@ -193,15 +196,19 @@ export class SupermemoryMCP extends McpAgent { refresh: z .boolean() .optional() - .default(true) - .describe("Refresh the list from the server (default: true)"), + .default(false) + .describe( + "Force refresh from the server (default: false; uses cache with TTL)", + ), }), }, // @ts-expect-error - zod type inference issue with MCP SDK async (args: { refresh?: boolean }) => { try { - if (args.refresh !== false) { + if (args.refresh === true) { await this.refreshContainerTags() + } else { + await this.ensureContainerTagsFresh() } const projects = this.cachedContainerTags @@ -566,6 +573,10 @@ export class SupermemoryMCP extends McpAgent { const result = await client.createMemory(content) + if (!this.cachedContainerTags.includes(result.containerTag)) { + await this.refreshContainerTags() + } + // Track memory added event posthog .memoryAdded({ @@ -758,10 +769,21 @@ export class SupermemoryMCP extends McpAgent { return this.ctx.id.name || "unknown" } + private async ensureContainerTagsFresh(): Promise { + const now = Date.now() + const needsRefresh = + this.containerTagsLastFetchedAt === null || + now - this.containerTagsLastFetchedAt > CONTAINER_TAGS_TTL_MS + if (needsRefresh) { + await this.refreshContainerTags() + } + } + private async refreshContainerTags(): Promise { try { const client = this.getClient() this.cachedContainerTags = await client.getProjects() + this.containerTagsLastFetchedAt = Date.now() } catch (error) { console.error("Failed to fetch container tags:", error) } diff --git a/apps/mcp/tsconfig.json b/apps/mcp/tsconfig.json index 576d11756..67ab2770a 100644 --- a/apps/mcp/tsconfig.json +++ b/apps/mcp/tsconfig.json @@ -13,7 +13,9 @@ "resolveJsonModule": true, "outDir": "dist", "rootDir": "src", - "baseUrl": "." + "paths": { + "*": ["./*"] + } }, "include": ["src/**/*"], "exclude": ["node_modules"] diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index dfc12a0c5..94c238bbc 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -11,6 +11,7 @@ import { Suspense } from "react" import { Toaster } from "@ui/components/sonner" import { NuqsAdapter } from "nuqs/adapters/next/app" import { ThemeProvider } from "@/lib/theme-provider" +import Script from "next/script" const font = Space_Grotesk({ subsets: ["latin"], @@ -69,6 +70,11 @@ export default function RootLayout({ +