Skip to main content

End-to-End Memory Walkthrough

End-to-End Memory Walkthrough

This walkthrough covers the full memory lifecycle — create, search, update, and delete — using the four LanOnasis surfaces that genuinely exist today:

  1. TypeScript SDK@lanonasis/memory-client
  2. curl / REST API — the platform HTTP endpoints
  3. MCP — Model Context Protocol tools
  4. CLI@lanonasis/cli

All examples were run against a local mock/sandbox API so they are safe to copy and adapt. No real API keys, secrets, or production data are shown.

Prerequisites

SurfaceInstall / Setup
TypeScriptnpm install @lanonasis/memory-client
curlAny HTTP client; curl is used here.
MCPAn MCP client (Claude Desktop, Cursor, or the LanOnasis CLI mcp command).
CLInpm install -g @lanonasis/cli

Start a local sandbox before running the examples. If you are working from the LanOnasis monorepo, bun run dev starts the local API used below.

Use a local base URL and placeholder credentials in every example by default. Only switch to production explicitly when you are ready to point at a live environment:

LANONASIS_API_URL=http://localhost:3000/api/v1
LANONASIS_API_KEY=lns_test_xxxxxxxxxxxxxxxx

For production, replace LANONASIS_API_URL with https://api.lanonasis.com/api/v1 and use a real user-scoped token or API key from the appropriate environment.

1. TypeScript SDK

Use the browser-safe core client in frontends, and the Node entry point when you want CLI/MCP-aware behavior on the server.

import { createMemoryClient } from '@lanonasis/memory-client/core';

const accessToken = await getAccessTokenFromYourBackend();

const client = createMemoryClient({
apiUrl: 'http://localhost:3000',
authToken: accessToken,
});

// In browsers, inject runtime config or a short-lived user token from your
// backend/session layer. Do not embed long-lived server API keys in client code.
import { createNodeMemoryClient } from '@lanonasis/memory-client/node';

const client = await createNodeMemoryClient({
apiUrl: process.env.LANONASIS_API_URL || 'http://localhost:3000',
apiKey: process.env.LANONASIS_API_KEY,
});

// 1. Create
const created = await client.createMemory({
title: 'Q4 Planning Notes',
content: 'We decided to prioritise the SDK matrix and the MCP tooling before the end of the quarter.',
memory_type: 'project',
tags: ['planning', 'q4', 'sdk']
});
console.log('Created:', created.data?.id);

// 2. Search
const found = await client.searchMemories({
query: 'SDK matrix priorities',
limit: 5,
threshold: 0.7
});
console.log('Search hits:', found.data?.total_results);

// 3. Update (using the id from the create step)
const memoryId = created.data?.id;
if (memoryId) {
const updated = await client.updateMemory(memoryId, {
title: 'Q4 Planning Notes (updated)',
tags: ['planning', 'q4', 'sdk', 'walkthrough']
});
console.log('Updated:', updated.data?.id);

// 4. Delete
const deleted = await client.deleteMemory(memoryId);
console.log('Deleted:', deleted.data ?? deleted.message);
}

Expected output (local mock):

Created: mem_01j5m2xz3abcdef
Search hits: 1
Updated: mem_01j5m2xz3abcdef
Deleted: Memory deleted successfully

2. curl / REST API

The REST API is the canonical contract every SDK and tool uses. Replace lns_test_... with your own API key.

2.1 Create a memory

curl -X POST "${LANONASIS_API_URL}/memories" \
-H "Content-Type: application/json" \
-H "X-API-Key: ${LANONASIS_API_KEY}" \
-d '{
"title": "Q4 Planning Notes",
"content": "We decided to prioritise the SDK matrix and the MCP tooling before the end of the quarter.",
"memory_type": "project",
"tags": ["planning", "q4", "sdk"]
}'

Expected response (local mock):

{
"data": {
"id": "mem_01j5m2xz3abcdef",
"title": "Q4 Planning Notes",
"content": "We decided to prioritise the SDK matrix and the MCP tooling before the end of the quarter.",
"memory_type": "project",
"tags": ["planning", "q4", "sdk"],
"created_at": "2026-08-08T10:00:00.000Z"
}
}

2.2 Search memories

curl -X POST "${LANONASIS_API_URL}/memories/search" \
-H "Content-Type: application/json" \
-H "X-API-Key: ${LANONASIS_API_KEY}" \
-d '{
"query": "SDK matrix priorities",
"limit": 5,
"threshold": 0.7
}'

Expected response (local mock):

{
"data": {
"total_results": 1,
"results": [
{
"id": "mem_01j5m2xz3abcdef",
"title": "Q4 Planning Notes",
"similarity_score": 0.92
}
]
}
}

2.3 Update a memory

curl -X PATCH "${LANONASIS_API_URL}/memories/mem_01j5m2xz3abcdef" \
-H "Content-Type: application/json" \
-H "X-API-Key: ${LANONASIS_API_KEY}" \
-d '{
"title": "Q4 Planning Notes (updated)",
"tags": ["planning", "q4", "sdk", "walkthrough"]
}'

Expected response (local mock):

{
"data": {
"id": "mem_01j5m2xz3abcdef",
"title": "Q4 Planning Notes (updated)",
"tags": ["planning", "q4", "sdk", "walkthrough"],
"updated_at": "2026-08-08T10:01:00.000Z"
}
}

2.4 Delete a memory

curl -X DELETE "${LANONASIS_API_URL}/memories/mem_01j5m2xz3abcdef" \
-H "X-API-Key: ${LANONASIS_API_KEY}"

Expected response (local mock):

{
"data": null,
"message": "Memory deleted successfully"
}

3. MCP (Model Context Protocol)

The LanOnasis MCP server exposes memory operations as tools. Use the tool names with your MCP client, or run onasis mcp tools to see the current list. The examples below use the standard JSON-RPC tool call shape.

3.1 Create

{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "create_memory",
"arguments": {
"title": "Q4 Planning Notes",
"content": "We decided to prioritise the SDK matrix and the MCP tooling before the end of the quarter.",
"memory_type": "project",
"tags": ["planning", "q4", "sdk"]
}
}
}

Expected response (local mock):

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "Created memory mem_01j5m2xz3abcdef"
}
]
}
}
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "search_memories",
"arguments": {
"query": "SDK matrix priorities",
"limit": 5,
"threshold": 0.7
}
}
}

Expected response (local mock):

{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "Found 1 result(s): mem_01j5m2xz3abcdef — Q4 Planning Notes (score 0.92)"
}
]
}
}

3.3 Update

{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "update_memory",
"arguments": {
"id": "mem_01j5m2xz3abcdef",
"title": "Q4 Planning Notes (updated)",
"content": "We decided to prioritise the SDK matrix and the MCP tooling before the end of the quarter.",
"tags": ["planning", "q4", "sdk", "walkthrough"]
}
}
}

Expected response (local mock):

{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "Updated memory mem_01j5m2xz3abcdef"
}
]
}
}

3.4 Delete

{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "delete_memory",
"arguments": {
"id": "mem_01j5m2xz3abcdef"
}
}
}

Expected response (local mock):

{
"jsonrpc": "2.0",
"id": 4,
"result": {
"content": [
{
"type": "text",
"text": "Deleted memory mem_01j5m2xz3abcdef"
}
]
}
}

4. CLI

The @lanonasis/cli binary is available as onasis, lanonasis, memory, or maas. All examples use onasis.

4.1 Create

onasis memory create \
--title "Q4 Planning Notes" \
--content "We decided to prioritise the SDK matrix and the MCP tooling before the end of the quarter." \
--type project \
--tags "planning,q4,sdk"

Expected output (local mock):

✓ Created memory mem_01j5m2xz3abcdef
onasis memory search "SDK matrix priorities" --limit 5

Expected output (local mock):

┌─────────────────────────┬──────────────────────────┬──────────┐
│ ID │ Title │ Score │
├─────────────────────────┼──────────────────────────┼──────────┤
│ mem_01j5m2xz3abcdef │ Q4 Planning Notes │ 0.92 │
└─────────────────────────┴──────────────────────────┴──────────┘

4.3 Update

onasis memory update mem_01j5m2xz3abcdef \
--title "Q4 Planning Notes (updated)" \
--tags "planning,q4,sdk,walkthrough"

Expected output (local mock):

✓ Updated memory mem_01j5m2xz3abcdef

4.4 Delete

onasis memory delete mem_01j5m2xz3abcdef --force

Expected output (local mock):

✓ Deleted memory mem_01j5m2xz3abcdef

Validation summary

SurfaceCreateSearchUpdateDelete
TypeScript SDK
curl / REST
MCP
CLI

Next steps