### Connect to Supermemory MCP via SSE Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Establishes a persistent connection to the Supermemory MCP server using Server-Sent Events. Includes commands for direct connection and automated client installation for tools like Claude, Cursor, and Cline. ```bash # Connect to the MCP SSE endpoint with your user ID curl -N "https://mcp.supermemory.ai/{userId}/sse" # Or with a session ID for resuming connections curl -N "https://mcp.supermemory.ai/{userId}/sse?sessionId={sessionId}" # One-click installation for various MCP clients npx install-mcp i https://mcp.supermemory.ai/{userId}/sse --client claude npx install-mcp i https://mcp.supermemory.ai/{userId}/sse --client cursor npx install-mcp i https://mcp.supermemory.ai/{userId}/sse --client cline npx install-mcp i https://mcp.supermemory.ai/{userId}/sse --client windsurf ``` -------------------------------- ### GET /sse Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Establishes a Server-Sent Events (SSE) connection for real-time communication with the MCP server. ```APIDOC ## GET /{userId}/sse ### Description Establishes a persistent SSE connection for MCP communication, enabling real-time memory operations. ### Method GET ### Endpoint https://mcp.supermemory.ai/{userId}/sse ### Parameters #### Path Parameters - **userId** (string) - Required - Unique identifier for the user session. #### Query Parameters - **sessionId** (string) - Optional - Session ID for resuming existing connections. ### Response #### Success Response (200) - **Connection** (EventStream) - Persistent SSE stream for MCP protocol messages. #### Response Example { "status": "connected", "protocol": "mcp-sse" } ``` -------------------------------- ### Self-Hosting Environment Configuration Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Configuration template for setting up the project in a self-hosted environment using environment variables. ```bash SUPERMEMORY_API_KEY=your_supermemory_api_key_here AUTH_SECRET=your_session_secret_here ``` -------------------------------- ### Execute Development and Deployment Commands Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt A set of CLI commands used to manage the project lifecycle. These commands handle local development, production builds, deployment to Cloudflare, and type generation. ```bash bun run dev # Start development server bun run build # Build for production bun run deploy # Build and deploy to Cloudflare bun run cf-typegen # Generate Cloudflare types ``` -------------------------------- ### POST /add Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Stores user information, preferences, and behaviors into the memory system. ```APIDOC ## POST /add ### Description Stores user information, preferences, and behaviors. This tool is invoked when detecting significant user traits or patterns. ### Method POST ### Request Body - **thingToRemember** (string) - Required - The information to store in memory. ### Request Example { "thingToRemember": "User prefers TypeScript over JavaScript" } ### Response #### Success Response (200) - **type** (string) - Response type (text). - **text** (string) - Confirmation message. #### Response Example { "type": "text", "text": "Memory added successfully" } ``` -------------------------------- ### POST /?index (Fetch Memories) Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Retrieves the list of memories associated with a specific user ID. ```APIDOC ## POST /?index ### Description Lists all memories for a given user through the web interface action handler. ### Method POST ### Endpoint /?index ### Request Body - **userId** (string) - Required - The unique identifier for the user. - **action** (string) - Required - Must be set to "fetch". ### Request Example { "userId": "abc123xyz", "action": "fetch" } ### Response #### Success Response (200) - **success** (boolean) - Status of the request. - **memories** (array) - List of memory objects. #### Response Example { "success": true, "memories": [ { "id": "mem_abc123", "title": "User prefers TypeScript", "summary": "User prefers TypeScript over JavaScript", "containerTags": ["abc123xyz"] } ] } ``` -------------------------------- ### POST /search Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Performs semantic search across user memories using vector-based matching. ```APIDOC ## POST /search ### Description Performs semantic search across user memories and patterns to retrieve relevant context. ### Method POST ### Request Body - **informationToGet** (string) - Required - The query to search for in memories. ### Request Example { "informationToGet": "What programming languages does the user prefer?" } ### Response #### Success Response (200) - **type** (string) - Response type (text). - **text** (string) - The retrieved memory content. #### Response Example { "type": "text", "text": "User prefers TypeScript over JavaScript" } ``` -------------------------------- ### Configure Cloudflare Worker with wrangler.jsonc Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt This configuration file defines the Cloudflare Worker settings, including compatibility dates, entry points, and Durable Object bindings. It enables Node.js compatibility and sets up database migrations for persistent storage. ```jsonc { "name": "supermemory-mcp-app", "compatibility_date": "2025-04-04", "main": "./workers/app.ts", "compatibility_flags": ["nodejs_compat", "nodejs_compat_populate_process_env"], "durable_objects": { "bindings": [{ "name": "MY_DO", "class_name": "MyDurableObject" }] }, "migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyDurableObject"] }] } ``` -------------------------------- ### Configure Supermemory System Prompt Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Defines the system prompt schema used to instruct LLMs on how to proactively manage user memory. This ensures consistent storage and retrieval behavior during sessions. ```typescript { "name": "Supermemory Prompt", "description": "A prompt that gives information about supermemory.", "completion": ["supermemory", "memory", "supermemory api"] } // Response format when prompt is invoked: { "role": "user", "content": { "type": "text", "text": "IMPORTANT: You MUST use Supermemory tools proactively to be an effective assistant..." } } ``` -------------------------------- ### Implement addToSupermemory Tool Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Defines the schema and interaction pattern for the addToSupermemory tool. This tool enables LLMs to persist user preferences and traits into the memory store. ```typescript { "name": "addToSupermemory", "description": "Store user information, preferences, and behaviors. Run on explicit commands ('remember this') or implicitly when detecting significant user traits, preferences, or patterns.", "inputSchema": { "type": "object", "properties": { "thingToRemember": { "type": "string", "description": "The information to store in memory" } }, "required": ["thingToRemember"] } } // Example POST request { "thingToRemember": "User prefers TypeScript over JavaScript and uses Tailwind CSS for styling" } ``` -------------------------------- ### Implement searchSupermemory Tool Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Defines the schema and interaction pattern for the searchSupermemory tool. It utilizes semantic vector matching to retrieve relevant historical context based on user queries. ```typescript { "name": "searchSupermemory", "description": "Search user memories and patterns. Run when explicitly asked or when context about user's past choices would be helpful. Uses semantic matching to find relevant details across related experiences.", "inputSchema": { "type": "object", "properties": { "informationToGet": { "type": "string", "description": "The query to search for in memories" } }, "required": ["informationToGet"] } } // Example POST request { "informationToGet": "What programming languages does the user prefer?" } ``` -------------------------------- ### Restore Session and Parse MCP URL Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Restores a user session and demonstrates how to extract a user ID from an MCP SSE URL using regex. ```typescript const formData = new FormData(); formData.append("userId", "previousUserId123"); formData.append("action", "restore"); const response = await fetch("/?index", { method: "POST", body: formData }); const mcpUrl = "https://mcp.supermemory.ai/abc123xyz/sse"; const urlPattern = /\/([^\/]+)\/sse/; const match = mcpUrl.match(urlPattern); const extractedUserId = match[1]; ``` -------------------------------- ### POST /?index (Update Memory) Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Updates the content of an existing memory. ```APIDOC ## POST /?index ### Description Updates the content of an existing memory through the web interface. ### Method POST ### Endpoint /?index ### Request Body - **userId** (string) - Required - The user identifier. - **action** (string) - Required - Must be set to "update". - **memoryId** (string) - Required - The ID of the memory to update. - **content** (string) - Required - The new content for the memory. ### Request Example { "userId": "abc123xyz", "action": "update", "memoryId": "mem_abc123", "content": "Updated content text" } ### Response #### Success Response (200) - **success** (boolean) - Status of the request. - **message** (string) - Confirmation message. #### Response Example { "success": true, "message": "Memory updated successfully" } ``` -------------------------------- ### POST /?index (Delete Memory) Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Deletes a specific memory entry by its ID. ```APIDOC ## POST /?index ### Description Removes a specific memory by its ID through the web interface. ### Method POST ### Endpoint /?index ### Request Body - **userId** (string) - Required - The user identifier. - **action** (string) - Required - Must be set to "delete". - **memoryId** (string) - Required - The ID of the memory to delete. ### Request Example { "userId": "abc123xyz", "action": "delete", "memoryId": "mem_abc123" } ### Response #### Success Response (200) - **success** (boolean) - Status of the request. - **message** (string) - Confirmation message. #### Response Example { "success": true, "message": "Memory deleted successfully" } ``` -------------------------------- ### Fetch User Memories via Web API Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Retrieves a list of memories for a specific user. It sends a POST request with the user ID and action type to the web interface. ```typescript const formData = new FormData(); formData.append("userId", "abc123xyz"); formData.append("action", "fetch"); const response = await fetch("/?index", { method: "POST", body: formData }); ``` -------------------------------- ### Cloudflare Durable Object Session Management Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Implements persistent SSE connections and session routing using Cloudflare Durable Objects. This ensures state is maintained across multiple requests. ```typescript export class MyDurableObject extends DurableObject { transport?: SSEHonoTransport; async fetch(request: Request) { const url = new URL(request.url); const userId = url.pathname.split("/")[1]; if (!this.transport) { this.transport = new SSEHonoTransport(`/${userId}/messages`, this.ctx.id.toString()); } } } export default { async fetch(request: Request, env: Env, ctx: ExecutionContext) { const url = new URL(request.url); if (url.pathname.includes("sse") || url.pathname.endsWith("/messages")) { const sessionId = url.searchParams.get("sessionId"); const namespace = env.MY_DO; const stub = sessionId ? namespace.get(namespace.idFromString(sessionId)) : namespace.get(namespace.newUniqueId()); return stub.fetch(request); } return requestHandler(request, { cloudflare: { env, ctx } }); } }; ``` -------------------------------- ### Update Memory via Web API Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Updates the content of an existing memory. The request includes the user ID, memory ID, and the new content string. ```typescript const formData = new FormData(); formData.append("userId", "abc123xyz"); formData.append("action", "update"); formData.append("memoryId", "mem_abc123"); formData.append("content", "User strongly prefers TypeScript with strict mode enabled"); const response = await fetch("/?index", { method: "POST", body: formData }); ``` -------------------------------- ### Delete Memory via Web API Source: https://context7.com/supermemoryai/supermemory-mcp/llms.txt Removes a specific memory entry by its unique ID. Requires the user ID and the target memory ID to perform the deletion. ```typescript const formData = new FormData(); formData.append("userId", "abc123xyz"); formData.append("action", "delete"); formData.append("memoryId", "mem_abc123"); const response = await fetch("/?index", { method: "POST", body: formData }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.