@cubememory/sdk
v0.1.4
Published
Official JavaScript/TypeScript SDK for Cube Memory — semantic search with 100% exact recall
Maintainers
Readme
@cubememory/sdk
Official JavaScript/TypeScript SDK for Cube Memory — semantic search with 100% exact recall, isolated multi-tenant islands, and native MCP support.
Install
npm install @cubememory/sdkQuick Start
import { createCubeClient } from '@cubememory/sdk';
const cube = createCubeClient('https://cubememory.com.br/gateway', 'cm_live_YOUR_KEY');
// Semantic search — 100% exact cosine recall (no ANN approximation)
const results = await cube.index('my-docs').search('wireless headphones', { limit: 10 });
// Index a document
await cube.index('my-docs').insert({
id: 'doc-001',
text: 'Noise cancelling Sony WH-1000XM5',
metadata: { price: 349, brand: 'Sony' },
});
// LLM Memory (agent remembers between sessions)
await cube.memory.store('User prefers dark mode and speaks Portuguese');
const ctx = await cube.memory.search('user preferences');
// PKM Notes
await cube.notes.upsert({ title: 'Meeting Q3', text: 'Discussed the roadmap...', tags: ['meeting'] });
const notes = await cube.notes.search('roadmap');CDN (no bundler)
<script src="https://cubememory.com.br/sdk.js"></script>
<script>
const cube = CubeMemory.createCubeClient('https://cubememory.com.br/gateway', 'cm_live_YOUR_KEY');
cube.index('docs').search('hello world').then(console.log);
</script>API Reference
createCubeClient(baseUrl, apiKey, options?)
Returns a CubeClient instance.
| Param | Type | Description |
|---|---|---|
| baseUrl | string | Gateway URL, e.g. https://cubememory.com.br/gateway |
| apiKey | string | Your API key (cm_live_xxx) |
| options.projectId | string | Project ID (proj_xxx) |
cube.index(name)
| Method | Description |
|---|---|
| .insert({ id, text, metadata? }) | Index a document |
| .insertMany(docs[]) | Batch index |
| .search(query, { limit?, threshold?, filter? }) | Semantic search |
| .get(id) | Fetch by ID |
| .delete(id) | Remove document |
| .stats() | Index statistics |
cube.memory
Agent memory — persists context between LLM sessions.
| Method | Description |
|---|---|
| .store(text, layer?) | Save a memory (long-term or short-term) |
| .search(query, limit?) | Semantic search over memories |
| .list(limit?) | List all memories |
| .delete(id) | Delete a memory |
cube.notes
PKM Notes — Obsidian-style knowledge base with AI auto-connections.
| Method | Description |
|---|---|
| .upsert({ title, text, tags?, id? }) | Create or update a note |
| .list() | List all notes |
| .get(id) | Get note with full content and related notes |
| .search(query, limit?) | Semantic search across notes |
| .delete(id) | Delete note and its chunks |
MCP Integration
Connect any LLM (Claude, GPT, Cursor, Windsurf) directly to your Cube Memory:
{
"mcpServers": {
"cube-memory": {
"type": "http",
"url": "https://cubememory.com.br/gateway/v1/mcp",
"headers": {
"Authorization": "Bearer cm_live_YOUR_KEY",
"X-Project-Id": "proj_YOUR_PROJECT"
}
}
}
}Available MCP tools: search_memory, store_memory, list_memories, search_notes, get_note.
Python SDK
pip install cubememoryfrom cubememory import CubeClient
cube = CubeClient('https://cubememory.com.br/gateway', 'cm_live_YOUR_KEY', 'proj_YOUR_PROJECT')
results = cube.index('my-docs').search('wireless headphones', limit=10)REST API (raw requests)
pip install requestsimport requests
H = {
'Authorization': 'Bearer cm_live_YOUR_KEY',
'X-Project-Id': 'proj_YOUR_PROJECT',
}
# save a memory
requests.post('https://cubememory.com.br/gateway/v1/memory',
headers=H, json={'text': 'user prefers short answers'})
# recall before LLM call (semantic search)
ctx = requests.post('https://cubememory.com.br/gateway/v1/memory/search',
headers=H, json={'query': user_input, 'limit': 5}).json()
memories = [r['text_preview'] for r in ctx['results']]Why Cube Memory?
| | Cube Memory | Bancos vetoriais baseados em ANN/HNSW | |---|:---:|:---:| | 100% exact recall | ✅ cosine float32 | ❌ ANN approximation | | Multi-tenant isolation | ✅ island per project | ⚠️ shared index with filters | | MCP native | ✅ built-in | ❌ | | Self-host footprint | ✅ minimal, single-host friendly | ❌ heavy multi-service clusters | | LGPD/GDPR | ✅ data never leaves your server | ❌ cloud by default |
Links
- Dashboard: cubememory.com.br
- PyPI: pypi.org/project/cubememory
- Issues: github.com/cubememory/sdk
