How to Build Durable AI Memory with Oracle Database and Claude
A technical guide to combining Claude's MCP protocol, Oracle AI Database, and LangChain for production AI workflows that remember across sessions.
Building AI workflows that remember
Most AI assistant demos break down after the first week of use. The assistant can answer questions and generate SQL, but it lacks durable context across sessions. When something goes wrong, teams struggle to answer basic operational questions: who executed what query, with which permissions, and what data informed the response.
Oracle has published a detailed technical guide addressing this gap. The approach combines Claude's Model Context Protocol (MCP), Oracle AI Database for persistent storage, Oracle AI Agent Memory for application-level context management, and LangChain for structured retrieval pipelines.
Why it matters
Production AI systems need two capabilities simultaneously: controlled execution boundaries and durable memory that survives beyond individual chat sessions. Without both, teams face audit gaps, permission sprawl, and context that evaporates when users close their laptops. This architecture separates real-time interaction from cross-session persistence, making each layer testable and debuggable independently.
Two execution loops, two memory layers
The architecture distinguishes between operational interaction and persistent memory through two separate loops.
Loop A handles real-time interaction. Claude communicates with Oracle AI Database through SQLcl running in MCP mode, which exposes database access as explicit tool contracts rather than raw credentials. The command sql -mcp launches SQLcl as an MCP server that Claude Desktop can invoke through declared tools.
Loop B manages durable memory. Oracle AI Database stores conversation threads, tool logs, and vector embeddings for semantic retrieval. Oracle AI Agent Memory provides a Python API that applications use to manage these records, assemble context, and retrieve relevant history across sessions and users.
Claude's built-in memory handles conversational continuity within the assistant experience. Oracle AI Agent Memory handles system-level memory that multiple users and agents can query, audit, and share.
Setting up the MCP boundary
The SQLcl MCP setup requires Oracle SQLcl 25.2.0 or higher, Oracle JRE 17 or 21, and at least one saved connection profile with persisted credentials. Developers create these profiles using SQLcl's connection store under ~/.dbtools with the -savepwd flag.
Claude Desktop configuration points to the SQLcl executable with the -mcp argument. A minimal configuration in Claude's config file specifies the command path and MCP argument. SQLcl then translates Claude's tool calls into database operations using the saved connection's permissions.
Oracle recommends starting with read-only access, using purpose-specific database users with minimal grants, and enabling restrict level 4 to disable sensitive commands like unrestricted file system access. Database-side activity appears in traces like DBTOOLS$MCP_LOG and session views like V$SESSION.
When to add Oracle AI Agent Memory
Teams should add Oracle AI Agent Memory when workflows need durable thread context, scoped recall across users, or reusable context cards that persist beyond individual sessions. The Python package sits on top of Oracle AI Database and provides APIs for conversation threads, memory records, and context assembly.
The package handles three memory categories: conversational memory for user and assistant turns, operational memory for tool inputs and outputs, and semantic memory with embeddings for meaning-based retrieval. Storing all three in Oracle AI Database enables SQL-based filtering, transactional integrity, and vector search in a single platform.
LangChain's role in retrieval
LangChain enters the architecture when applications need structured retrieval orchestration. The langchain-oracledb package wires vector retrieval in Oracle AI Database while keeping access control in database roles. LangChain runs in the application layer to format context before it reaches Claude's prompt—Claude Desktop does not call LangChain directly.
Good uses include declaring retrieval tools in consistent formats, running retrieval-first answer pipelines, and standardizing context assembly. Poor uses include treating LangChain as a security boundary or relying solely on prompts to limit assistant capabilities. Permissions belong in the database and infrastructure layer.
Production readiness checklist
Before expanding access, Oracle recommends validating that the MCP server starts without errors, Claude Desktop discovers SQLcl tools after restart, read-only queries succeed against approved schemas, database-side activity logs capture MCP interactions, and denied queries fail because of database roles rather than prompt engineering.
The architecture's value lies in making each layer independently testable. When an answer looks wrong, developers can inspect which tool call ran, which database user executed it, what SQL was used, which memory records were retrieved, and whether the application assembled correct context.
These details were first reported by Oracle in a technical guide published on their developer blog.
This is an original analysis by the Omega editorial team. Source reporting: AI Watch.
Want systems like this working for your business?
Book a Call