Skip to documentation
Docs navigation
Docs/Install MemoGrafter and prepare the database
Setup

Install MemoGrafter and prepare the database.

MemoGrafter runs server-side on Node.js and uses PostgreSQL with pgvector for the built-in storage backend.

Requirements

Node.js 18 or newer.
TypeScript or modern JavaScript using ES modules.
PostgreSQL with the pgvector extension for the built-in PostgresGraphStore.
An LLM adapter and an embedding adapter.
Redis only when enabling queue mode or the optional recall cache.

Install the package

Install MemoGrafter from npm in the server-side package where your chatbot or memory workflow runs.

terminal
# Add the MemoGrafter runtime to your server-side app.
npm install memo-grafter

Initialize project files

Create the generated MemoGrafter config and schema files. These files live under src/memo-grafter/ so they are easy to review, keep separate from your application code, and commit with the rest of your project.

terminal
# Generate MemoGrafter config and schema files.
npx memo-grafter init

Generated files overview

Review both generated files after initialization. Keep secrets in environment variables rather than committing credentials in mg.config.ts.

src/memo-grafter/mg.config.ts contains project-level MemoGrafter settings, including the database connection and optional feature configuration.
src/memo-grafter/mg.schema.ts defines the MemoGrafter-managed database schema used by migration and other CLI tooling.

Create the database schema

Run the migration command after setting DATABASE_URL. MemoGrafter owns only its mg_* tables and required PostgreSQL extensions.

terminal
# Create or update only MemoGrafter-owned database tables.
npx memo-grafter migrate

Verify the installation

Run Doctor after migration to verify the installed package, configuration, PostgreSQL connection, pgvector extension, migration state, and required MemoGrafter tables. Doctor performs read-only diagnostics and does not change your configuration or database.

terminal
npx memo-grafter doctor

Migration boundary

memo-grafter migrate manages only MemoGrafter-owned mg_* tables and PostgreSQL extensions. Application tables remain in your existing Prisma, Drizzle, SQL, or custom migration workflow.