Skip to main content
Enable Claude’s native memory tool functionality with Supermemory as the persistent storage backend. Claude can automatically store and retrieve information across conversations using familiar filesystem operations.

Supermemory tools on npm

Check out the NPM page for more details

Installation

Quick Start

How It Works

Claude’s memory tool uses a filesystem metaphor to manage persistent information:
  • Files: Individual memory items stored as Supermemory documents
  • Directories: Organized using path structure (e.g., /memories/user-preferences)
  • Operations: View, create, edit, delete, and rename files
  • Path Normalization: Paths like /memories/preferences are stored as --memories--preferences

Configuration

Basic Configuration

Using Container Tags

Memory Operations

Claude automatically performs these operations when managing memory:

View Files

List directory contents or read file contents:

Create Files

Store new information:

Edit Files

Update existing memories using string replacement:

Delete Files

Remove information:

Rename Files

Reorganize memory structure:

Complete Chat Example

Here’s a full example with conversation handling:

Advanced Usage

Custom Path Management

Control where Claude stores information:

Error Handling

Handle operations gracefully:

Monitoring Operations

Track memory operations:

Memory Organization

Best Practices

  1. Use Descriptive Paths: /memories/user-preferences/theme.txt is better than /mem1.txt
  2. Organize by Category: Group related information under directories
  3. Keep Files Focused: Store specific information in separate files
  4. Use Clear Naming: Make file names self-explanatory

Path Structure Examples

API Reference

createClaudeMemoryTool(apiKey, config)

Creates a memory tool instance for Claude. Parameters:
  • apiKey (string): Your Supermemory API key
  • config (optional):
    • projectId (string): Project identifier
    • containerTags (string[]): Alternative to projectId
    • baseUrl (string): Custom API endpoint
Returns: ClaudeMemoryTool instance

handleCommandForToolResult(command, toolUseId)

Processes a memory command and returns formatted result. Parameters:
  • command (MemoryCommand): The memory operation from Claude
  • toolUseId (string): Tool use ID from Claude’s response
Returns: Promise<MemoryToolResult> with:
  • type: “tool_result”
  • tool_use_id: The tool use ID
  • content: Operation result or error message
  • is_error: Boolean indicating success/failure

Memory Commands

Claude uses these command types internally:

Environment Variables

When to Use

The Claude Memory Tool is ideal for:
  • Conversational AI: Claude automatically remembers user preferences and context
  • Personal Assistants: Store and retrieve user-specific information
  • Documentation Bots: Maintain knowledge across conversations
  • Project Management: Track tasks and project state
  • Note-Taking Apps: Persistent memory for meeting notes and ideas

Comparison with Other Approaches

Limitations

  • Requires Anthropic SDK with beta features enabled
  • Path separators (/) are normalized to -- for storage
  • Maximum 100 files per directory listing
  • File operations are asynchronous

Next Steps

OpenAI SDK Tools

Use memory tools with OpenAI function calling

AI SDK Integration

Integrate with Vercel AI SDK

Memory API

Direct API access for advanced control

Cookbook

See real-world examples