Integrations

Claude memory tool

Back the client side memory tool with MenteDB, on the cloud or your own server.

llms.txt

Claude's memory tool (memory_20250818) is a client side tool. The model sends file style commands against a /memoriesdirectory, and your code runs them against a store you choose. MenteDB implements that contract, so the model's notes live in a real database you own, scoped per agent, and show up in search beside everything else the agent remembers.

The same endpoint runs on MenteDB Cloud and on a self hosted mentedb-server, with the same request and response, so a tool loop moves between them by changing only the base URL and the credential. Every edit is applied by the engine itself, with no extra model call on a write.

With the SDK

MemoryTool in the Python and TypeScript SDKs posts each call and builds the tool_result blocks for you. Point it at your server, or at https://api.mentedb.com with an mdb_ key.

import anthropic
from mentedb import MemoryTool

# Self hosted: MemoryTool("http://localhost:6677", token, agent_id="...")
memory = MemoryTool("https://api.mentedb.com", "mdb_your_key")
client = anthropic.Anthropic()

messages = [{"role": "user", "content": "Remember that I deploy on Fridays."}]
while True:
    response = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=16000,
        tools=[MemoryTool.TOOL],
        messages=messages,
    )
    messages.append({"role": "assistant", "content": response.content})
    if response.stop_reason != "tool_use":
        break
    messages.append({"role": "user", "content": memory.results(response.content)})

execute(input) runs one call and returns the reply, and handle(tool_use) returns one tool_result block. Pass database for a named database on your server. In Python, MenteDBClient(api_key=...).memory_tool() returns a MemoryTool for your cloud account. Auth and server failures raise MenteDBError in Python and throw MemoryToolError, with the HTTP status, in TypeScript.

The endpoint

POSThttps://api.mentedb.com/v1/memory_tool
Cloud, with Authorization: Bearer $MENTEDB_API_KEY, the same mdb_ key as process_turn.
POSThttp://localhost:6677/v1/memory_tool
Self hosted mentedb-server, with a server token, or /v1/db/{db}/memory_tool for a named database.

The body is the memory tool's tool_use input verbatim, a command and its fields. On the server it also takes optional agent_id and user_id (UUIDs) to pick whose files to use.

JSON
{ "command": "create",
  "path": "/memories/preferences.md",
  "file_text": "User prefers SQLite for side projects.\n" }

Commands

Every path lives under /memories. The six commands mirror the memory tool spec exactly.

viewList a directory or read a file. Optional view_range: [start, end] limits a file read to a line span.
createWrite a file from file_text. Creates it, or replaces the contents if the path already exists.
str_replaceReplace old_str with new_str in a file. old_str must match exactly once; omit new_str to delete the matched text.
insertInsert insert_text after line insert_line (0 inserts at the top of the file).
renameMove old_path to new_path. Works on a single file or a whole directory.
deleteRemove the file or directory at path.

Response

Every response is shaped to drop straight into a Claude tool_result block.

JSON
{ "content": "File created successfully at: /memories/preferences.md",
  "is_error": false }

Command-level failures (a missing file, a bad range, an old_str that matches twice) come back as HTTP 200 with is_error: true and the message the memory tool spec defines, so Claude reads it and self-corrects. Only auth and engine faults surface as HTTP errors.

Quickstart

Get an mdb_ key at app.mentedb.com, then create a file and read it back.

Terminal
export MENTEDB_API_KEY=mdb_your_key_here

# Create a memory file
curl -X POST https://api.mentedb.com/v1/memory_tool \
  -H "Authorization: Bearer $MENTEDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command":"create","path":"/memories/preferences.md","file_text":"User prefers SQLite.\n"}'

# View it back, line-numbered per the memory tool spec
curl -X POST https://api.mentedb.com/v1/memory_tool \
  -H "Authorization: Bearer $MENTEDB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command":"view","path":"/memories/preferences.md"}'

Without the SDK

Any language works. Declare the memory tool on the request. When the model asks to use it, forward the command to /v1/memory_tool and hand content back in the tool_result.

Terminal
export MENTEDB_API_KEY=mdb_your_key_here
pip install anthropic requests
Python
import os, requests, anthropic

claude = anthropic.Anthropic()
MEMORY_TOOL = "https://api.mentedb.com/v1/memory_tool"
HEADERS = {"Authorization": f"Bearer {os.environ['MENTEDB_API_KEY']}"}

def run_memory_command(command_input):
    # command_input is the memory tool_use input: command + its fields
    resp = requests.post(MEMORY_TOOL, headers=HEADERS, json=command_input)
    resp.raise_for_status()
    return resp.json()  # {"content": "...", "is_error": bool}

messages = [{"role": "user", "content": "Remember I moved from Postgres to SQLite."}]

while True:
    response = claude.messages.create(
        model="claude-opus-5-5",
        max_tokens=16000,
        tools=[{"type": "memory_20250818", "name": "memory"}],
        messages=messages,
    )
    messages.append({"role": "assistant", "content": response.content})
    if response.stop_reason != "tool_use":
        break

    results = []
    for block in response.content:
        if block.type == "tool_use" and block.name == "memory":
            out = run_memory_command(block.input)   # execute against MenteDB
            results.append({
                "type": "tool_result",
                "tool_use_id": block.id,
                "content": out["content"],
                "is_error": out["is_error"],
            })
    messages.append({"role": "user", "content": results})

Scoping on your server

Files belong to an agent and a user, and a command only sees its own scope, so one agent can never list, read, change or delete another agent's files, even at the same path. A token bound to an agent always acts as that agent, and an agent_id in the body must match it or the call gets 403. Otherwise the body's agent_id is used. Read only tokens may view and get 403 for everything else. Every path must be /memories or under it; traversal, encoded separators and control characters are refused before anything is read or written.

Each memory tool file maps to one MenteDB memory, tagged memtool:path:<path> and source:memory_tool, and is embedded again whenever it changes. It records provenance source filewith the path as its reference. A delete forgets the memory, a rename swaps its path. Because they are ordinary memories, they live beside the rest of the account's store and stay retrievable through process_turn and MQL.