MemoFSMemoFS
Core Runtime

Configuration

Configuration options, precedence resolution, filesystem options, and environment variables for MemoFS instances.

MemoFS resolves configuration through a strict 4-level precedence chain:

Runtime Modes

MemoFS supports two primary runtime modes:

ModeTargetDescription
localLocal / Zero CloudAll reads, writes, and recall operations occur 100% locally on disk (or in-memory). Zero cloud dependencies or network calls required.
hybridLocal + Cloud SyncReads and writes remain 100% local. Cloud connectivity is used exclusively for explicit file replication via memofs.sync.push and memofs.sync.pull.
import { createNodeMemoFs } from "@memofs/core/node-fs";

const memofs = createNodeMemoFs({
  rootDir: ".",
  mode: "local", // or "hybrid"
});

Client Options

The MemoFsConfig object is passed to new MemoFS(config) or createNodeMemoFs(config):

PropertyTypeDefaultDescription
storeMemoryStore(Auto in Node)Storage adapter (NodeFsMemoryStore, RemoteBlobMemoryStore, or InMemoryMemoryStore). Required when using new MemoFS() directly.
mode"local" | "hybrid""local"Runtime mode.
rootDirstring"."Workspace root directory containing .memofs/. Used for anchor drift path resolution.
projectIdstringAuto-derivedUnique project identifier. Extracted from .memofs/manifest.json if omitted.
tenantIdstringundefinedOptional multi-tenant identifier.
workspaceIdstringundefinedOptional sub-workspace identifier.
cloudMemoFsCloudClientOptionsundefinedCloud connection settings (baseUrl, apiKey, defaultProjectId) for hybrid mode.
cloudClientMemoFsCloudClientundefinedInjected custom cloud replication client instance.
embedderMemoryEmbedderundefinedVector embedding provider (e.g. from @memofs/adapter-openai, @memofs/adapter-voyage, or local ONNX).
rerankerRerankerFallbackCustom reranker for retrieval results. Defaults to DeterministicFallbackReranker.
extractorExtractorRule-basedEntity/edge graph extractor. Defaults to built-in rule-based extractor (createRuleBasedExtractor).
llmClientLlmClientundefinedProvider-neutral LLM client for LLM-enhanced extraction, rewriting, and consolidation.
recallStoreRecallStoreAuto-createdVector/lexical storage backend (FsRecallStore or InMemoryRecallStore).
recallRecallEngineConfig{ engine: "auto" }Recall engine settings (engine: "lexical" | "vector" | "hybrid" | "auto").
fileConfigMemoFsConfigFileAuto-readPre-parsed .memofs/config.json content (bypasses filesystem read).
autoBootstrapbooleantrueAutomatically creates canonical .memofs/ files on initial read/write if missing.
loggerMemoFsLoggerundefinedCustom logger interface for debug/info events.
userAgentstringundefinedCustom User-Agent header sent to cloud replica.

Node Filesystem Options

When constructing a filesystem store via createNodeFsMemoryStore(options), the following options are available:

OptionTypeDefaultDescription
rootDirstring | URL(Required)Directory where the .memofs/ folder lives.
createRootbooleantrueAutomatically creates parent directories before writing.
missingFileBehavior"throw" | "empty""throw"What store.read() returns if a file is missing.
disallowSymlinksbooleantruePrevents symlink path traversal attacks.
directoryModenumber0o700POSIX directory permissions.
fileModenumber0o600POSIX file permissions.
lockbooleantrueEnables cross-process advisory locking (.memofs/.lock) to prevent concurrent writers from corrupting files.
lockMaxAgeMsnumber3600000 (1h)Max duration before a stale lock is reclaimed (guards against process crashes).

Workspace Config

You can commit a .memofs/config.json file in your repository root:

.memofs/config.json
{
  "$schema": "https://docs.memofs.dev/schema/config.json",
  "runtime": "local",
  "projectId": "proj_abc123",
  "recall": {
    "engine": "hybrid",
    "embeddingModel": "openai/text-embedding-3-small",
    "localEmbeddings": false
  },
  "cloud": {
    "baseUrl": "https://memofs.dev/api/v1"
  }
}

Reading Config Synchronously (Node.js)

@memofs/core/node-fs provides readMemoFsConfigFileSync(rootDir) to safely parse .memofs/config.json without throwing if the file is missing:

import { readMemoFsConfigFileSync } from "@memofs/core/node-fs";

const fileConfig = readMemoFsConfigFileSync(".");
console.log(fileConfig.projectId);

Environment Variables

VariableTypeDefaultDescription
MEMOFS_RUNTIMEstring"local"Overrides the runtime mode ("local" or "hybrid").
MEMOFS_PROJECT_IDstringundefinedUnique project workspace ID.
MEMOFS_CLOUD_URLstringhttps://memofs.dev/api/v1Base URL of the MemoFS Cloud sync API.
MEMOFS_API_KEYstringundefinedAPI key (mfs_...) used to authenticate with MemoFS Cloud.
MEMOFS_RECALL_ENGINEstring"auto"Recall engine strategy: "lexical", "vector", "hybrid", or "auto".
MEMOFS_LOCAL_EMBEDDINGSstring"false"Set to "1" or "true" to enable local ONNX embeddings in CLI/core. In @memofs/mcp-server, local embeddings are enabled by default and disabled with "0" or "false".
MEMOFS_EMBEDDING_MODELstringundefinedModel identifier for local or remote embeddings.

On this page