Setup
Installation
Install the store package (langgraph-store-mongodb):
Credentials
Set your Atlas connection string:Usage
Create aMongoDBStore and pass it to create_agent. The from_conn_string context manager creates the required indexes when it opens. You do not call a separate setup() method.
Memory storage
LangGraph stores memories as JSON documents organized bynamespace and key. Namespaces typically include a user or org ID to keep memories scoped.
The following example configures vector indexing so store.search can run semantic queries. Use create_vector_index_config and pass it as index_config:
Read long-term memory in tools
Tools can read from the store using theruntime parameter, which LangGraph injects automatically:
Write long-term memory from tools
Tools can also write to the store usingruntime.store.put, persisting data that survives across threads:
See also
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

