diff --git a/README.md b/README.md index 70ca4ca..b486cfb 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,16 @@ If you only need to authenticate an existing install, run: bunx cursor-supermemory@latest login ``` +To connect Cursor to a different Supermemory organization, run: + +```bash +bunx cursor-supermemory@latest switch-org +``` + +Choose the organization in your browser, then restart Cursor or run +**Developer: Reload Window**. A failed or cancelled switch keeps the previously +saved browser credential. + ## What it does - **Session hooks** — injects relevant memories at session start; saves conversation highlights at session end @@ -53,7 +63,7 @@ explicit project knowledge when an agent requests one scope. | Variable | Description | |---|---| -| `SUPERMEMORY_API_KEY` | API key (overrides all other sources) | +| `SUPERMEMORY_API_KEY` | API key (overrides browser-selected organizations and all other sources) | | `SUPERMEMORY_API_URL` | Override the Supermemory API base URL | | `SUPERMEMORY_REPO_TAG` | Override the unified repository container tag | | `SUPERMEMORY_USER_TAG` | Legacy Cursor personal container to continue reading | diff --git a/commands/supermemory-setup.md b/commands/supermemory-setup.md index 37b22d6..deaa3ed 100644 --- a/commands/supermemory-setup.md +++ b/commands/supermemory-setup.md @@ -11,4 +11,8 @@ bunx cursor-supermemory@latest login This opens your browser to connect your Supermemory account to Cursor. Once connected, the AI will have persistent memory across all your coding sessions. -If the browser doesn't open automatically, visit: https://console.supermemory.ai/auth/connect?client=cursor +To choose a different organization later, run: + +```bash +bunx cursor-supermemory@latest switch-org +``` diff --git a/commands/supermemory-switch-org.md b/commands/supermemory-switch-org.md new file mode 100644 index 0000000..d68bda1 --- /dev/null +++ b/commands/supermemory-switch-org.md @@ -0,0 +1,16 @@ +--- +name: supermemory-switch-org +description: Choose which Supermemory organization Cursor should use +--- + +Run the following command in the terminal: + +```bash +bunx cursor-supermemory@latest switch-org +``` + +This opens Supermemory in your browser, where you can choose an organization. +Your existing saved credential is kept if authentication is cancelled or fails. + +After a successful switch, restart Cursor or run **Developer: Reload Window** +so the MCP server uses the new organization. diff --git a/src/auth.ts b/src/auth.ts index e854081..22fd156 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,11 +1,13 @@ import path from "node:path"; import os from "node:os"; import fs from "node:fs"; +import { randomBytes } from "node:crypto"; const CREDENTIALS_DIR = path.join(os.homedir(), ".supermemory-cursor"); const CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, "credentials.json"); -const AUTH_PORT = 19878; -const AUTH_URL = "https://console.supermemory.ai/auth/connect"; +const AUTH_URL = "https://app.supermemory.ai/auth/connect"; +export const DEFAULT_API_URL = "https://api.supermemory.ai"; +const SESSION_TIMEOUT_MS = 10_000; const SUCCESS_HTML = `