Integrations

Frameworks and tools

Packages for agent frameworks and a connector for coding tools.

llms.txt

MenteDB has first-party integrations for popular agent frameworks, a one-command connector for existing AI coding tools, and a copy-paste loop for chat bots.

There are two ways to wire it in: call the hosted API with an mdb_ key (no infra), or embed the engine with the SDK (self-hosted, your disk). The framework packages below embed the engine; to run a framework against MenteDB Cloud, use the REST process_turn loop as its memory step. Either way the verb is the same, one call per turn.

Connect an existing AI tool

To add memory to Claude Code, Cursor, Copilot, or the Claude apps, you do not write the loop yourself. One command wires MenteDB in and the assistant calls process_turn every turn for you.

Terminal
npx mentedb-mcp@latest setup claude-code   # or: cursor, copilot, claude

This is for wiring MenteDB into an existing tool, not for building your own agent. If you are writing an agent loop, use the SDK or REST examples in The loop instead. Full connector details are in MCP server & tools.

LangChain / LangGraph

Install the integration package:

Terminal
pip install mentedb-langchain

MenteDBMemory

A LangChain-compatible memory backend. Uses hybrid search (vector similarity, tag filtering, temporal decay) to assemble the most relevant context each turn.

Python
from mentedb_langchain import MenteDBMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI

memory = MenteDBMemory(
    data_dir="./agent-memory",
    agent_id="my-agent",
    token_budget=4096,
)

chain = ConversationChain(
    llm=ChatOpenAI(),
    memory=memory,
)

chain.predict(input="What database should I use for time series data?")
chain.predict(input="Tell me more about that recommendation")
data_dir

Path to the MenteDB data directory.

Default: ./mentedb-data

agent_id

Optional agent identifier for memory isolation.

Default: None

token_budget

Maximum tokens for assembled context.

Default: 4096

return_messages

Return LangChain message objects instead of a string.

Default: False

MenteDBRetriever

A LangChain-compatible retriever using MenteDB hybrid search. Supports optional tag filtering and agent scoping.

Python
from mentedb_langchain import MenteDBRetriever
from langchain.chains import RetrievalQA
from langchain_openai import ChatOpenAI

retriever = MenteDBRetriever(
    data_dir="./agent-memory",
    k=10,
    tags=["backend", "architecture"],
)

chain = RetrievalQA.from_chain_type(
    llm=ChatOpenAI(),
    retriever=retriever,
)

chain.invoke("What were the key decisions about our database migration?")
data_dir

Path to the MenteDB data directory.

Default: ./mentedb-data

k

Number of results to return.

Default: 10

tags

Optional tag filter for narrowing retrieval.

Default: None

agent_id

Optional agent identifier for scoping.

Default: None

MenteDBChatHistory

Persistent chat history with cognitive tracking. Stores messages alongside reasoning trajectories, knowledge gaps, and contradiction signals.

Python
from mentedb_langchain import MenteDBChatHistory

history = MenteDBChatHistory(
    session_id="session-123",
    data_dir="./agent-memory",
)

history.add_user_message("What database should I use?")
history.add_ai_message("I recommend PostgreSQL for your use case.")

messages = history.messages
session_id

Unique identifier for this chat session.

Default: (required)

data_dir

Path to the MenteDB data directory.

Default: ./mentedb-data

agent_id

Optional agent identifier.

Default: None

CrewAI / AutoGen

Install the integration package:

Terminal
pip install mentedb-crewai

MenteDBCrewMemory

A drop-in memory backend for CrewAI agents. Supports multi-agent memory isolation via spaces, cross-session recall, and automatic knowledge-gap detection.

Python
from crewai import Agent, Crew, Task
from mentedb_crewai import MenteDBCrewMemory

memory = MenteDBCrewMemory(
    data_dir="./crew-memory",
    space="research-team",
)

researcher = Agent(
    role="Senior Researcher",
    goal="Find comprehensive information on the topic",
    memory=memory,
)

writer = Agent(
    role="Technical Writer",
    goal="Write clear documentation from research",
    memory=MenteDBCrewMemory(
        data_dir="./crew-memory",
        space="research-team",
        agent_name="writer",
    ),
)

task = Task(
    description="Research and document the latest trends in vector databases",
    agent=researcher,
)

crew = Crew(agents=[researcher, writer], tasks=[task])
crew.kickoff()
data_dir

Path to the MenteDB data directory.

Default: ./mentedb-data

space

Memory space name for agent isolation or sharing across a team.

Default: default

agent_name

Optional agent name for per-agent memory scoping within a space.

Default: None

MenteDBTool

A CrewAI tool that lets agents query MenteDB directly using MQL. Attach it to any agent so the agent can search the team knowledge base during task execution.

Python
from crewai import Agent
from mentedb_crewai import MenteDBTool

memory_tool = MenteDBTool(data_dir="./crew-memory")

agent = Agent(
    role="Analyst",
    goal="Analyze data using historical context",
    tools=[memory_tool],
)
data_dir

Path to the MenteDB data directory the tool queries against.

Default: ./mentedb-data

Chat bots: Discord, Slack, support

A memory-backed bot is just process_turn on your message handler: recall what you know about this user, answer with it in the prompt, store the exchange. The loop is identical hosted or self-hosted, only the transport differs. These use the hosted API; the one-line self-host swap is at the bottom.

Discord bot (hosted API)

Terminal
pip install discord.py requests
export MENTEDB_API_KEY=mdb_your_key_here
export DISCORD_TOKEN=...
Python
import os, requests, discord

API = "https://api.mentedb.com/v1/process_turn"
HEADERS = {"Authorization": f"Bearer {os.environ['MENTEDB_API_KEY']}"}

intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)

memory, turns = {}, {}   # per-channel context and turn counter

@client.event
async def on_message(msg):
    if msg.author.bot:
        return
    cid = str(msg.channel.id)
    context = "\n".join(m["content"] for m in memory.get(cid, []))

    reply = call_your_llm(
        system=f"You are a helpful assistant.\nWhat you remember:\n{context}",
        user=msg.content,
    )
    await msg.channel.send(reply)

    # Store the exchange; context comes back for the next message in this channel.
    turn = turns.get(cid, 0)
    result = requests.post(API, headers=HEADERS, json={
        "user_message": msg.content,
        "assistant_response": reply,
        "turn_id": turn,
        "project_context": f"discord:{cid}",   # advisory tag, not isolation (use user_id for that)
    }).json()
    memory[cid] = result["context"]
    turns[cid] = turn + 1

client.run(os.environ["DISCORD_TOKEN"])

The returned context is kept per channel and feeds the next message, so recall kicks in from the second turn onward. For Slack, swap discord.py for slack_bolt; the handler body is the same.

Support assistant (hosted API)

For a returning customer you want recall on the very first message, including past conversations. One call stores the question and hands back everything relevant to it, then you answer with that in the prompt.

Python
import os, requests

API = "https://api.mentedb.com/v1/process_turn"
HEADERS = {"Authorization": f"Bearer {os.environ['MENTEDB_API_KEY']}"}
SUPPORT_PROMPT = "You are a support agent. Be concise. Use what we know about the customer."

def answer(customer_id, question, turn_id):
    # One call: store the question + get back memory relevant to it, including past sessions.
    result = requests.post(API, headers=HEADERS, json={
        "user_message": question,
        "assistant_response": "",              # no reply yet
        "turn_id": turn_id,
        "project_context": f"customer:{customer_id}",
    }).json()
    known = "\n".join(m["content"] for m in result["context"])

    return call_your_llm(
        system=f"{SUPPORT_PROMPT}\n\nWhat we know:\n{known}",
        user=question,
    )

This stores each customer message and its extracted facts. To also persist the agent's exact wording for future recall, send a follow-up process_turn with the assistant_response once you have it.

Self-hosted: swap the transport

Same loop against the embedded engine, no network. Replace the REST POST with the SDK call; result.context carries the same memories (attribute access instead of dict keys).

Python
from mentedb import MenteDB

db = MenteDB("./bot-memory")   # data on local disk

def answer(customer_id, question, turn_id):
    result = db.process_turn(
        user_message=question,
        assistant_response="",
        turn_id=turn_id,
        project_context=f"customer:{customer_id}",
    )
    known = "\n".join(m.content for m in result.context)
    return call_your_llm(system=known, user=question)