Skip to main content
Glama
Sky-Memory MCP

Sky-Memory MCP

by ziditun
README.md
# Sky-Memory MCP

**Persistent, local-first memory for AI assistants.** Sky-Memory exposes a shared memory system through the Model Context Protocol (MCP), so supported assistants can use the same SQLite database across sessions and projects.

[![Node.js](https://img.shields.io/badge/Node.js-20.11%2B-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
[![MCP](https://img.shields.io/badge/Protocol-MCP-6f42c1)](https://modelcontextprotocol.io/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

> **Release status:** The repository is currently private and the npm package has not been published. Installation currently requires Git access to this repository.

## What it does

Sky-Memory gives MCP-compatible assistants a persistent memory layer without requiring a separate memory service.

- **Persistent memory:** Store facts, preferences, decisions and project knowledge in SQLite.
- **Relevant recall:** Search with SQLite FTS5, relevance ranking and graph relationships.
- **Optional semantic recall:** Add embeddings through an explicitly configured Ollama or OpenAI-compatible endpoint. FTS5 remains the fallback.
- **Memory evolution:** Review and resolve duplicates, contradictions, corrections and temporal changes.
- **Working and project context:** Keep temporary session notes and structured project state.
- **Procedural memory:** Capture workflows as skills and validate them before promotion.
- **History:** Inspect revisions, provenance, decisions and explicitly recorded session events.
- **Privacy controls:** Consent-gated memory creation and updates, opt-in session history, and configurable secret redaction (enabled by default).

## Architecture

```text
MCP clients
  Claude Desktop · Claude Code · Codex · OpenCode · Cursor
                         │
                         │ MCP over stdio
                         ▼
                Sky-Memory MCP server
                         │
        ┌────────────────┼─────────────────┐
        ▼                ▼                 ▼
   Memory & recall   Evolution       Working / skills
        │                │                 │
        └────────────────┼─────────────────┘
                         ▼
                 SQLite + FTS5
            revisions · events · edges
                  optional vectors
```

The database is local to the machine running Sky-Memory. If a remote embedding endpoint is configured, memory text and recall queries are sent to that provider for embedding generation. Local storage does not make remote model processing local.

## Requirements

- Node.js **20.11 or newer**
- npm
- Git
- Native build tools for `better-sqlite3` when a prebuilt binary is unavailable:
  - Linux: compiler toolchain and Python (for example, `build-essential`)
  - macOS: Xcode Command Line Tools
  - Windows: Visual Studio C++ Build Tools and Python

The automated CI workflow currently runs on Ubuntu Linux. Windows and macOS installer behavior has not been verified end-to-end in CI.

## Install

The repository is private at present, so the GitHub account used to clone it must have access.

```bash
git clone https://github.com/ziditun/sky-memory-mcp.git
cd sky-memory-mcp
node install.js
```

The installer:

1. Checks the platform, Node.js and npm versions.
2. Installs the locked dependencies and builds the native SQLite module.
3. Compiles the TypeScript MCP server.
4. Creates the data directory and initializes the database without replacing an existing database.
5. Installs the project prompts and hooks.
6. Detects supported harness configuration directories and registers the MCP server, backing up existing configuration files before editing them.
7. Runs database and MCP startup diagnostics.

Restart the relevant assistant after installation. The installer configures detected harnesses; it does not install the assistant applications themselves.

### Data location

Default data directory:

```text
~/.sky-memory/
├── config.json
├── data/default/mnemon.db
├── hooks/
└── prompt/
```

To use another directory:

```bash
# macOS / Linux
export MNEMON_DATA_DIR="$HOME/my-sky-memory"
node install.js

# Windows PowerShell
$env:MNEMON_DATA_DIR = "$HOME\my-sky-memory"
node install.js
```

The runtime also supports `SKY_MEMORY_DB_PATH` for an explicit database path.

### Verify or diagnose

Run the read-only installer diagnostics:

```bash
node install.js --diagnose-only
```

To run the MCP server manually after building:

```bash
npm run mcp
```

## MCP tools

The server exposes these tools to connected assistants:

| Tool | Purpose |
|---|---|
| `memory_context` | Build prompt-relevant context within a token budget |
| `memory_recall` | Search stored memories |
| `memory_remember` | Store a memory |
| `memory_evolve` | Resolve pending merges, contradictions and updates |
| `memory_session` | Record or inspect session history and decisions |
| `memory_manage` | List, inspect, update, delete, export and maintain memories |
| `memory_working` | Manage session scratchpad and project context |
| `memory_skills` | Manage procedural-memory skills |

Memory creation and updates, session-history recording, working/project-memory changes and skill lifecycle changes require explicit consent. Session input/output history is opt-in and is not recorded merely because context is retrieved. Deletion and maintenance are separate, explicitly invoked tool actions.

## Optional semantic retrieval

Semantic retrieval is disabled unless an embedding endpoint is configured. SQLite FTS5 works without an embedding provider.

Example using local Ollama:

```bash
export SKY_MEMORY_EMBEDDING_URL=http://localhost:11434/api/embed
export SKY_MEMORY_EMBEDDING_MODEL=nomic-embed-text

# Index existing memories; future writes are indexed automatically
sky-memory reindex-embeddings
```

For an OpenAI-compatible endpoint, set `SKY_MEMORY_EMBEDDING_URL` to the provider base URL or its `/embeddings` endpoint. Set `SKY_MEMORY_EMBEDDING_API_KEY` when required.

**Privacy:** A remote endpoint receives the text being embedded. Use a local endpoint when memory content must remain on-device. Provider errors fall back to lexical FTS5 recall.

## Existing database secret scan

New writes and imports are redacted before persistence. To inspect an older database, run the read-only scan first:

```bash
sky-memory scrub-legacy
```

To apply redaction:

```bash
sky-memory scrub-legacy --apply
```

The apply operation creates a timestamped database backup and verifies the migration. Stop other Sky-Memory processes before applying it. Keep the backup secure because it may contain the original sensitive values.

## Configuration

The runtime reads `~/.sky-memory/config.json` (or the configured data directory). Common settings:

| Setting | Default | Description |
|---|---:|---|
| `decayHalfLifeDays` | `30` | Memory importance decay half-life |
| `immunityImportanceThreshold` | `4` | Importance at or above this level is decay-immune |
| `defaultRecallLimit` | `10` | Default recall result limit |
| `workingMemoryDefaultTtl` | `3600` | Working-memory TTL in seconds |
| `skillPromotionThreshold` | `3` | Independent successful sessions required for skill validation |
| `maintenanceIntervalHours` | `24` | Background maintenance interval |
| `redactSecrets` | `true` | Enable secret redaction |

Environment variables can override runtime settings. See `src/mcp/index.ts` for the supported environment variables.

## Supported integrations

| Client | Integration |
|---|---|
| Claude Desktop | MCP over stdio |
| Claude Code | MCP over stdio |
| Codex | MCP over stdio |
| OpenCode | Local MCP server |
| Cursor | MCP over stdio |

The installer writes MCP configuration for detected clients and copies the prompt and hook scripts into the data directory. It does **not** register those scripts with each host's native hook system. CI tests the server protocol and configuration logic; it does not launch and verify each desktop application.

## Development

```bash
npm ci
npm run build
npm run lint
npm test
npm pack --dry-run
```

CI runs these checks on Ubuntu Linux.

## Current limitations

- No Sky-Memory-native web or graph UI is included.
- The npm package is not published.
- The repository is private.
- Windows and macOS installation have not had end-to-end CI verification.
- Cross-machine synchronization is not implemented.
- Session history is opt-in and requires explicit consent.

## Documentation

- [Architecture](specs/ARCHITECTURE.md)
- [Core specification](specs/CORE_SPEC.md)
- [Database schema](specs/DATABASE_SCHEMA.md)
- [MCP API](specs/MCP_API.md)
- [Parity reference](PARITY_TABLE.md)

## Credits and license

Sky-Memory maintains compatibility with the Mnemon database layout and acknowledges the [Mnemon project](https://github.com/mnemon-dev/mnemon).

Released under the [MIT License](LICENSE).