From c98a3b59c5f357bf45b5ad04b147e0ac8668d360 Mon Sep 17 00:00:00 2001 From: Prasanna A P <106952318+Prasanna721@users.noreply.github.com> Date: Tue, 21 Jul 2026 01:06:47 -0700 Subject: [PATCH] avoid workspace state migration --- apps/mcp/src/server/agent.ts | 25 ++++++++++++++++++------- apps/mcp/src/server/index.ts | 6 ++---- apps/mcp/src/server/workspace-state.ts | 13 ------------- apps/mcp/wrangler.jsonc | 8 -------- 4 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 apps/mcp/src/server/workspace-state.ts diff --git a/apps/mcp/src/server/agent.ts b/apps/mcp/src/server/agent.ts index 69c281c7..9c749ed3 100644 --- a/apps/mcp/src/server/agent.ts +++ b/apps/mcp/src/server/agent.ts @@ -9,15 +9,14 @@ import { registerProfileResource } from "./resources/profile" import { registerWidgetResource } from "./resources/widget" import { registerAllTools } from "./tools" import { errorResult } from "./tools/types" -import type { WorkspaceState } from "./workspace-state" type Env = { - MCP_SERVER: DurableObjectNamespace - WORKSPACE_STATE: DurableObjectNamespace + MCP_SERVER: DurableObjectNamespace API_URL?: string } const DEFAULT_API_URL = "https://api.supermemory.ai" +const ACTIVE_CONTAINER_TAG_KEY = "activeContainerTag" export class SupermemoryMCP extends McpAgent { private clientInfo: { name: string; version?: string } | null = null @@ -92,16 +91,28 @@ export class SupermemoryMCP extends McpAgent { } private workspaceState() { - const key = `${this.props.userId}:${this.props.organizationId ?? "default"}` - return this.env.WORKSPACE_STATE.getByName(key) + const userId = this.props?.userId + if (!userId) throw new Error("Authenticated user ID is required") + const organizationId = this.props?.organizationId ?? "default" + return this.env.MCP_SERVER.getByName( + `workspace-state:${userId}:${organizationId}`, + ) } private getActiveContainerTag(): Promise { - return this.workspaceState().getActiveContainerTag() + return this.workspaceState().readActiveContainerTag() } private setActiveContainerTag(containerTag: string): Promise { - return this.workspaceState().setActiveContainerTag(containerTag) + return this.workspaceState().writeActiveContainerTag(containerTag) + } + + async readActiveContainerTag(): Promise { + return this.ctx.storage.get(ACTIVE_CONTAINER_TAG_KEY) + } + + async writeActiveContainerTag(containerTag: string): Promise { + await this.ctx.storage.put(ACTIVE_CONTAINER_TAG_KEY, containerTag) } private getSession() { diff --git a/apps/mcp/src/server/index.ts b/apps/mcp/src/server/index.ts index 84f56552..e0660fd6 100644 --- a/apps/mcp/src/server/index.ts +++ b/apps/mcp/src/server/index.ts @@ -4,11 +4,9 @@ import type { ContentfulStatusCode } from "hono/utils/http-status" import type { Props } from "../shared/types" import { SupermemoryMCP } from "./agent" import { validateOAuthToken } from "./auth" -import { WorkspaceState } from "./workspace-state" type Bindings = { - MCP_SERVER: DurableObjectNamespace - WORKSPACE_STATE: DurableObjectNamespace + MCP_SERVER: DurableObjectNamespace API_URL?: string MCP_RESOURCE?: string } @@ -177,6 +175,6 @@ app.all("/mcp/*", async (c) => { return handleMcpRequest(c) }) -export { SupermemoryMCP, WorkspaceState } +export { SupermemoryMCP } export default app diff --git a/apps/mcp/src/server/workspace-state.ts b/apps/mcp/src/server/workspace-state.ts deleted file mode 100644 index 8ad756a2..00000000 --- a/apps/mcp/src/server/workspace-state.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { DurableObject } from "cloudflare:workers" - -const ACTIVE_CONTAINER_TAG_KEY = "activeContainerTag" - -export class WorkspaceState extends DurableObject { - async getActiveContainerTag(): Promise { - return this.ctx.storage.get(ACTIVE_CONTAINER_TAG_KEY) - } - - async setActiveContainerTag(containerTag: string): Promise { - await this.ctx.storage.put(ACTIVE_CONTAINER_TAG_KEY, containerTag) - } -} diff --git a/apps/mcp/wrangler.jsonc b/apps/mcp/wrangler.jsonc index 8a85739f..a7429795 100644 --- a/apps/mcp/wrangler.jsonc +++ b/apps/mcp/wrangler.jsonc @@ -27,10 +27,6 @@ { "name": "MCP_SERVER", "class_name": "SupermemoryMCP" - }, - { - "name": "WORKSPACE_STATE", - "class_name": "WorkspaceState" } ] }, @@ -39,10 +35,6 @@ { "tag": "v1", "new_sqlite_classes": ["SupermemoryMCP"] - }, - { - "tag": "v2", - "new_sqlite_classes": ["WorkspaceState"] } ],