Overview
The MemMachine Dify plugin allows you to seamlessly integrate persistent memory into your Dify applications. By adding MemMachine as a tool provider, your Dify agents can store chronological interactions (Episodic) and retrieve distilled knowledge (Semantic), enabling a deeper level of context awareness across user sessions.Configuration
When adding the MemMachine plugin to Dify, you will need to configure the following credentials:| Variable | Description | Default |
|---|---|---|
memmachine_api_key | Your MemMachine API Key for authentication | (Required) |
memmachine_base_url | The URL of your MemMachine backend service | https://api.memmachine.ai/v2 |
The
memmachine_base_url is optional. If left empty, the plugin will default to the MemMachine Cloud API. If you are self-hosting, ensure you provide your local server address (e.g., http://localhost:8080).Setup Guide
Build and Package
Navigate to the integration directory and run the build script to generate the
.plugin file:Install in Dify
A. Open your Dify dashboard.
B. Navigate to the Plugins tab.
C. Upload the generated
.plugin file.Usage
Once installed, you can add MemMachine tools to any Dify Chatflow or Agent.Memory Search
Use thesearch_memory tool to retrieve relevant context. In a Chatflow, you can map the query input using Jinja2 templates:
Code snippet
Memory Storage
Use theadd_memory tool within your nodes to persist important information from the conversation, ensuring the agent “remembers” it in future sessions.
Developer Guide (Contributors)
If you wish to modify the plugin behavior or develop new tools for the Dify provider:Requirements
- Python 3.12+
- Dify Plugin CLI (
dify) jinja2(for build-time template rendering)
Development Workflow
The source of truth for the plugin provider and tool definitions is located in thetemplates/ directory.
-
Modify Templates: Edit files in
templates/or add new tools totools/. -
Rebuild: Run
python build_plugin.pyto render theprovider/files. -
Manual Package:
Bash
Repo Hygiene
Note that generated provider files are ignored by git. Always modify the files intemplates/ and use the build script to ensure your changes are correctly propagated to the packaged plugin.
Requirements
- A Dify instance (Cloud or Self-hosted)
- MemMachine server running (default: http://localhost:8080) or Cloud account
- Python 3.12+ (for building/contributing)

