@memlink/cli
v2.0.1
Published
Memlink — MCP server for persistent AI agent memory. Self-hosted, one URL, no cloud.
Maintainers
Readme
Memlink is a self-hosted MCP server that gives AI agents persistent, organized memory. One install, one URL, any agent connects — Devin Desktop, Cursor, Windsurf, Claude Code, or any MCP-compatible HTTP client.
Installation
npm install -g @memlink/cliRequires Node.js 18+ or Bun 1.0+.
From source:
git clone https://github.com/rblez/memlink.git
cd memlink && bun install && npm run buildQuick Start
memlink serve --daemon # Start server in background
memlink serve --status # Verify it's runningConfigure your agent with http://localhost:4444/mcp (see below).
Connecting an Agent
Add this JSON to your agent's MCP configuration:
{
"mcpServers": {
"memlink": {
"type": "http",
"url": "http://localhost:4444/mcp"
}
}
}Devin Desktop → Settings → MCP Servers
Cursor → Settings → MCP
Windsurf → ~/.codeium/windsurf/mcp_config.json
Claude Code → MCP_SERVERS_CONFIG env var or .mcp.json
Codex CLI → ~/.codexclirc or project .codexclirc
After connecting, agents discover the memory_read, memory_edit, memory_search, and memory_sync tools automatically. Start every new session by calling memory_read to load stored context.
Commands
| Command | Description |
|---------|-------------|
| memlink | Show server URL, memory stats, and daemon status |
| memlink serve | Start the MCP server |
| memlink serve --daemon | Run in background |
| memlink serve --stop | Stop the daemon |
| memlink serve --status | Show server status + stats |
No CRUD commands — all memory operations happen through the MCP tools.
MCP Tools
| Tool | Description |
|------|-------------|
| memory_read | Read index or a specific entry (id?, title?, full?) |
| memory_edit | Create or update an entry (title, content, tags?) |
| memory_search | Search entries by query |
| memory_sync | Memory stats (count, size, last updated) |
Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| MEMLINK_DIR | ~/.memlink | Data directory |
| MEMLINK_PORT / PORT | 4444 | Server port |
| MEMLINK_HOST / HOST | localhost | Server host |
| MEMLINK_NO_COLOR | — | Disable colored output |
Data Layout
~/.memlink/
├── settings.json # Global config
├── .serve.pid # Daemon PID
└── default/ # Memory (auto-created)
├── meta.json # Memory metadata
├── index.json # Entry index (titles, tags, timestamps)
├── 1.md, 2.md, ... # Entries with YAML frontmatter
└── .backups/ # Timestamped backups on every writeRobustness
- Atomic writes —
.tmp+renameSync(), no partial writes - Auto-backups — every mutation backed up to
.backups/ - File lock — concurrent writes serialized via
.lockwith TTL + retry - Health ticker — 30s heartbeat written to
.health - Rate limiting — 1000 req/min per IP
Development
bun install # Install dependencies
npm run build # Build CLI + server
npm run dev:server # Server with hot reload
npm run dev:cli # CLI dev mode
npm run test # Run tests
npm run lint # ESLint
npm run format # PrettierProject Structure
src/
├── cli/index.ts # CLI entrypoint (commander)
├── cli/output.ts # Colors, badges, branding
├── cli/daemon.ts # Detached spawn (Windows VBScript)
├── server/index.ts # MCP server (Express + MCP SDK)
└── core/
├── storage.ts # Entry CRUD, atomic writes, backups
├── meta.ts # Per-memory meta.json
├── routing.ts # Default memory route
├── health.ts # Daemon heartbeat
├── lock.ts # File lock with TTL
├── memory.ts # Config + CLI helpers
└── types.ts # Types, constants, MEMLINK_VERSION
tests/ # memory, server, unit, vbscriptLicense
Apache License 2.0 — see LICENSE.
