A decentralized, encrypted, lifetime memory layer for AI agents. DMGN enables AI agents to store, retrieve, and synchronize memories across devices without relying on central servers.
User owns their identity and memory data that persists across devices and time, with no central server or third-party control.
- No central server: Fully peer-to-peer using libp2p
- User owns identity: Self-sovereign ed25519 keys
- Lifetime persistence: Data persists across devices and time
- End-to-end encryption: AES-GCM-256 for all memory data
- Resilient to failure: Automatic replication and recovery
- Offline-first: Works without connectivity, syncs when available
┌─────────────────────────────────────────────────────────────┐
│ DMGN Daemon │
├─────────────────────────────────────────────────────────────┤
│ CLI (start/stop) │ REST API │ MCP (TCP IPC → stdio) │
├────────────────────┴────────────┴────────────────────────────┤
│ Query Engine │ Encryption │ Memory Graph │
├───────────────┴────────────┴────────────────────────────────┤
│ Local Storage (BadgerDB) │ libp2p Network │
├───────────────────────────┴──────────────────────────────────┤
│ Identity (ed25519) │ Sync │ Shard Distribution │
│ Protobuf (wire) │ Protobuf (protocols) │
└─────────────────────────────────────────────────────────────┘
- Quick Start
- Installation
- CLI Commands
- Architecture
- Memory Model
- Security
- Configuration
- Development
- Roadmap
- Contributing
- License
| Phase | Status | Description |
|---|---|---|
| 1 | ✅ Complete | Local Foundation — Identity, storage, CLI, local memory |
| 2 | ✅ Complete | Encryption & API — Full E2E encryption, REST API |
| 3 | ✅ Complete | Networking Core — libp2p peer discovery, mDNS, DHT |
| 4 | ✅ Complete | Distributed Storage — Shamir sharding, replication |
| 5 | ✅ Complete | Query & Sync — Vector search, gossip sync, delta sync |
| 6 | ✅ Complete | MCP & Polish — MCP protocol, observability, backup, docs |
| 7 | ✅ Complete | Daemon Architecture — Background daemon, CLI restructure, MCP IPC |
| 8 | 🔄 In Progress | Networking Enhancements — QUIC transport, NAT traversal (Circuit Relay v2, hole punching, TURN) |
| 9 | ✅ Complete | Skill Loader — Conversational skill-trigger system |
| 10 | ✅ Complete | Graph Sync — Distributed edge sync via gossip |
- Go 1.21+
- BadgerDB (pulled via go modules)
git clone https://github.com/nnlgsakib/dmgn
cd dmgn
go build -o dmgn ./cmd/dmgn./dmgn init
# Enter a strong passphrase (min 8 characters)
# Confirm the passphraseThis creates:
- ed25519 keypair (public key = your ID)
- Encrypted private key stored in data directory
- Configuration file
./dmgn add "This is my first memory stored in DMGN"Output:
✓ Memory added: a3f7b2d8e1c9...
./dmgn query "first memory"Output:
Found 1 memories:
1. This is my first memory stored in DMGN
ID: a3f7b2d8e1c9... | Type: text | Links: 0
./dmgn start
# Enter passphrase — daemon launches in backgroundOutput:
Starting DMGN daemon (PID: 12345)...
DMGN daemon started successfully!
PID: 12345
MCP IPC port: 52431
Multiaddresses:
/ip4/192.168.1.10/tcp/4001/p2p/12D3KooW...
/ip4/127.0.0.1/tcp/4001/p2p/12D3KooW...
To stop: dmgn stop
AI tools: dmgn mcp
Share your multiaddress with other nodes as a bootstrap peer.
The daemon persists its own multiaddresses in config.json inside the data directory.
Copy a multiaddress from node A and add it as a bootstrap peer in node B's config:
{
"bootstrap_peers": [
"/ip4/192.168.1.10/tcp/4001/p2p/12D3KooW..."
]
}Or start node B and manually edit config.json in its data directory.
./dmgn status
./dmgn peers./dmgn stop| Command | Description |
|---|---|
dmgn init |
Create new identity and initialize node |
dmgn start |
Start daemon in background (prompts passphrase) |
dmgn start --foreground |
Start daemon in current terminal (debug mode) |
dmgn stop |
Gracefully stop the running daemon |
dmgn mcp |
stdio↔TCP proxy for AI agent MCP integration |
dmgn add <text> |
Add a memory to local storage |
dmgn query <text> |
Search memories by content |
dmgn query --recent |
List recent memories |
dmgn status |
Show node status and stats |
dmgn peers |
Show connected peers |
dmgn backup |
Export encrypted backup of node data |
dmgn restore |
Restore node from encrypted backup |
dmgn export |
Export encrypted identity for backup |
dmgn import |
Import identity from backup |
See docs/cli-reference.md for complete usage.
{
id: "sha256_hash_of_encrypted_payload",
timestamp: int64_nanoseconds,
type: "text|conversation|observation|document",
embedding: [float32_vector],
encrypted_payload: bytes,
links: ["memory_id_1", "memory_id_2"],
merkle_proof: "integrity_hash"
}text- General text contentconversation- Dialog or chat messagesobservation- Noted observations or factsdocument- Document chunks or summaries
Memories can link to other memories, forming a directed graph:
./dmgn add "User asked about Go channels" --link <previous-memory-id>- Key derivation: Argon2id (time=3, memory=64MB, threads=4)
- Identity encryption: XChaCha20-Poly1305
- Memory encryption: AES-GCM-256 with per-memory keys
- Master key: Derived from ed25519 seed + purpose
ed25519 Private Key (encrypted with passphrase)
↓
Master Key (HKDF-derived from seed)
↓
Per-Memory Keys (random, encrypted with master key)
↓
Encrypted Payload (AES-GCM-256)
# Export (encrypted - safe to store)
./dmgn export -o backup.key
# Import on new device
./dmgn import -i backup.keyData directory locations:
- Linux:
~/.config/dmgn/ - macOS:
~/Library/Application Support/dmgn/ - Windows:
%APPDATA%/dmgn/
Override with --data-dir flag.
After dmgn init and first dmgn start, the config file includes:
{
"data_dir": "/home/user/.config/dmgn",
"listen_addr": "/ip4/0.0.0.0/tcp/4001",
"api_port": 8080,
"bootstrap_peers": [],
"node_multiaddrs": [
"/ip4/192.168.1.10/tcp/4001/p2p/12D3KooW...",
"/ip4/127.0.0.1/tcp/4001/p2p/12D3KooW..."
],
"mcp_ipc_port": 0,
"gossip_topic": "dmgn/memories/1.0.0",
"sync_interval": "60s",
"query_timeout": "2s"
}Key fields:
bootstrap_peers— List of peer multiaddresses to connect to on startup. Copy anode_multiaddrsentry from another node here.node_multiaddrs— This node's own full multiaddresses (auto-populated on daemon start). Share these with other nodes.listen_addr— libp2p listen address. Default/ip4/0.0.0.0/tcp/4001.mcp_ipc_port— TCP port for MCP IPC.0= auto-assign.
cmd/dmgn/ # CLI entry point
pkg/identity/ # ed25519 key management
pkg/memory/ # Memory model and graph
pkg/storage/ # BadgerDB interface
pkg/vectorindex/ # Vector similarity search
pkg/query/ # Hybrid query engine + cross-peer protocol
pkg/sync/ # GossipSub + delta sync + version vectors
pkg/network/ # libp2p host, peer discovery, reputation
pkg/sharding/ # Shamir secret sharing
pkg/mcp/ # MCP server for AI agent integration
pkg/backup/ # Encrypted backup/restore
pkg/observability/ # OpenTelemetry, structured logging
internal/cli/ # Cobra commands (start, stop, mcp, etc.)
internal/crypto/ # AES-GCM encryption
internal/config/ # Configuration management
internal/api/ # REST API server
internal/daemon/ # Background daemon lifecycle + process mgmt
docs/ # Architecture, MCP, API, CLI, config docs
examples/ # Claude Desktop, Cline config examples
go test ./...- User can run
dmgn initand create a new identity with ed25519 keypair - User can run
dmgn add "text"and store memory locally with content-addressable ID - Memory graph can be traversed via link relationships
- Data persists across CLI restarts
- Time-based queries return memories in chronological order
DMGN runs an MCP server inside the daemon. AI tools connect through the dmgn mcp stdio proxy.
# 1. Build, init, and start
go build -o dmgn ./cmd/dmgn
./dmgn init
./dmgn start
# 2. Configure your AI tool to use:
# Command: dmgn mcp{
"mcpServers": {
"dmgn": {
"command": "dmgn",
"args": ["mcp"]
}
}
}The daemon must be running (dmgn start) before AI tools can connect.
7 MCP tools: add_memory, query_memory, get_context, link_memories, get_graph, delete_memory, get_status
See docs/mcp-integration.md for full setup guide.
| Document | Description |
|---|---|
| Architecture | System overview, component diagram, data flow |
| MCP Integration | Claude Desktop, Cline setup guides |
| API Reference | REST API with curl examples |
| CLI Reference | All commands with usage |
| Config Reference | All config fields with defaults |
| Troubleshooting | Common issues and fixes |
- Identity generation and storage
- Local memory storage with BadgerDB
- CLI commands (init, add, query, status)
- Memory graph with links
- Full AES-GCM-256 encryption for all data
- REST API with Bearer token authentication
- Memory backup and import/export
- Key hierarchy with per-memory keys
- libp2p host with TCP and QUIC transports
- DHT and mDNS peer discovery
- Connection management with watermarks
- Basic protocol handlers
- Shamir secret sharing for memory shards
- Encrypted shard distribution to peers
- Replication factor management
/memory/store/1.0.0and/memory/fetch/1.0.0protocols
- Brute-force cosine vector similarity search
- Hybrid scoring (vector + text)
- Cross-peer query aggregation via libp2p streams
- GossipSub memory propagation + delta sync with version vectors
- MCP stdio server with 7 tools (official Go SDK)
- OpenTelemetry traces/metrics + structured logging with rotation
- Encrypted backup/restore (tar.gz with manifest)
- Peer reputation scoring (weighted: uptime, latency, sync, availability)
- Comprehensive documentation suite
- Background daemon with self-re-exec pattern (cross-platform)
dmgn start/dmgn stop/dmgn mcpcommands- MCP served over TCP IPC with stdio proxy for AI tools
- Node multiaddresses persisted in config for bootnode sharing
- PID file + port file lifecycle management
- Derived keys passed securely via environment variable
- Protobuf v2.0.0 migration for wire protocols
- QUIC transport for improved latency and NAT traversal
- NAT traversal: Circuit Relay v2, direct hole punching, TURN fallback
- Conversational skill-trigger system for AI agents
dmgn_load_skillMCP tool integration- Dynamic skill loading at runtime
- Distributed knowledge graph edge propagation
- Gossip-based edge sync alongside memory sync
- Delta sync for efficient updates
See SECURITY.md for vulnerability reporting and security policies.
If you discover a security vulnerability, please report it responsibly:
- Do NOT open a public issue
- Email security reports privately
- Include reproduction steps and potential impact
- Wait for acknowledgment before public disclosure
Join the conversation:
- GitHub Discussions - Q&A and ideas
- Discord - Real-time chat
- Watch the repository for release notifications
- Check CHANGELOG.md for version history
This project is licensed under the MIT License - see LICENSE for details.
Contributions are welcome! Please read CONTRIBUTING.md for guidelines on:
- Setting up your development environment
- Submitting pull requests
- Code style and commit conventions
- Recognizing contributors
Thanks to all contributors who have helped build DMGN:
| Contributor | Contribution |
|---|---|
| @dmgn | Original author |
(This section is updated for each release. Thank you for your contributions!)
Special thanks to the following projects and communities: