Skip to content

Repository files navigation

Memlink Logo

Memlink

Universal Memory for AI Agents
Self-hosted · HTTP streamable · No cloud

Release License npm


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/cli

Requires Node.js 18+ or Bun 1.0+.

From source:

git clone https://github.com/rblez/memlink.git
cd memlink && bun install && npm run build

Quick Start

memlink serve --daemon          # Start server in background
memlink serve --status          # Verify it's running

Configure 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 CodeMCP_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 write

Robustness

  • Atomic writes.tmp + renameSync(), no partial writes
  • Auto-backups — every mutation backed up to .backups/
  • File lock — concurrent writes serialized via .lock with 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       # Prettier

Project 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, vbscript

License

Apache License 2.0 — see LICENSE.

About

Memlink is a self-hosted MCP (Model Context Protocol) server that gives AI agents persistent, organized memory. One memory, one URL, any agent connects.

Topics

Resources

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages