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/preferencesare 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
- Use Descriptive Paths:
/memories/user-preferences/theme.txtis better than/mem1.txt - Organize by Category: Group related information under directories
- Keep Files Focused: Store specific information in separate files
- 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 keyconfig(optional):projectId(string): Project identifiercontainerTags(string[]): Alternative to projectIdbaseUrl(string): Custom API endpoint
ClaudeMemoryTool instance
handleCommandForToolResult(command, toolUseId)
Processes a memory command and returns formatted result.
Parameters:
command(MemoryCommand): The memory operation from ClaudetoolUseId(string): Tool use ID from Claude’s response
Promise<MemoryToolResult> with:
type: “tool_result”tool_use_id: The tool use IDcontent: Operation result or error messageis_error: Boolean indicating success/failure
Memory Commands
Claude uses these command types internally:| Command | Description | Example |
|---|---|---|
view | List directory or read file | /memories/ or /memories/file.txt |
create | Create new file | Create /memories/new.txt with content |
str_replace | Edit file contents | Replace “old text” with “new text” |
insert | Add content at line | Insert at line 5 |
delete | Remove file | Delete /memories/old.txt |
rename | Rename/move file | Rename old.txt to new.txt |
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
| Feature | Claude Memory Tool | OpenAI SDK Tools | AI SDK Tools |
|---|---|---|---|
| Automatic Memory | ✅ Claude decides | ❌ Manual control | ❌ Manual control |
| Filesystem Metaphor | ✅ Files/directories | ❌ Flat storage | ❌ Flat storage |
| Path Organization | ✅ Hierarchical | ❌ Tags only | ❌ Tags only |
| Integration | Anthropic SDK only | OpenAI SDK only | Vercel AI SDK |
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