New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@memstack/server

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@memstack/server

REST API server for MemStack — self-hostable agent memory

latest
Source
npmnpm
Version
0.7.3
Version published
Maintainers
1
Created
Source

@memstack/server

REST API server for MemStack — self-hostable agent memory. Runs on Node.js 22+ or Bun.

Installation

npm install @memstack/server
# or via Docker:
docker pull ghcr.io/isiomac/memstack-server:0.7.2

Quick Start

# Node.js
npx @memstack/server
# or, if installed as a dependency:
node node_modules/@memstack/server/dist/serve.js

# Bun
bun run node_modules/@memstack/server/dist/index.js

# Docker
docker run -p 3000:3000 -e MEMSTACK_STORAGE=memory -e OPENAI_API_KEY=sk-... ghcr.io/isiomac/memstack-server:0.7.0

Under Node, dist/serve.js starts the server explicitly via @hono/node-server. Under Bun, dist/index.js's default export ({ port, fetch }) is auto-started by the Bun runtime — no extra wiring needed. Both entry points serve the same Hono app, so behavior is identical either way.

Configuration

All via environment variables.

VariablePurposeDefault
MEMSTACK_STORAGEStorage backend (memory, disk, markdown, postgres, sqlite, redis)memory
MEMSTACK_DIRDirectory for markdown/disk./memories
DATABASE_URLPostgres connection—
SQLITE_PATHSQLite database path./memstack.db
REDIS_URLRedis connectionredis://localhost:6379
OPENAI_API_KEYOpenAI LLM + embeddings—
ANTHROPIC_API_KEYAnthropic LLM (summarization)—
MEMSTACK_OPENAI_BASE_URLCustom API endpoint (DeepSeek, etc)https://api.openai.com/v1
MEMSTACK_LLM_MODELModel overridegpt-4o-mini
MEMSTACK_EMBED_ON_STOREAuto-embed on storetrue
MEMSTACK_API_KEYBearer token auth (optional)—
MEMSTACK_RATE_LIMITRequests/minute limit0 (disabled)
PORTHTTP port3000

API Endpoints

The server exposes 20 operational routes plus the generated OpenAPI document endpoint.

MethodPathDescription
POST/v1/memoriesStore a memory
POST/v1/memories/batchStore multiple memories
POST/v1/memories/retrieveRetrieve memories
POST/v1/memories/contextCompile LLM-ready context
POST/v1/memories/processStore with auto-enrichment
POST/v1/memories/mergeMerge multiple memories
POST/v1/memories/purgeDelete all for an actor
POST/v1/memories/delete-manyDelete multiple by ID
POST/v1/memories/importImport JSON snapshot
GET/v1/memories/:idGet by ID
DELETE/v1/memories/:idDelete by ID
POST/v1/memories/:id/touchBump recency
GET/v1/memories/countCount with filters
GET/v1/memories/exportExport snapshot
POST/v1/summarizeCompress old memories
GET/v1/summarize/streamStream summary via SSE
POST/v1/pruneRemove stale memories
POST/v1/prune/dry-runPreview prune
GET/v1/stats/:actorIdMemory diagnostics
GET/healthHealth check
GET/openapi.jsonOpenAPI 3.1 spec, generated from the request-validation schemas below

Request validation

Every POST body is validated against a zod schema before it reaches MemStack. Invalid requests get a 400 with details instead of a generic 500:

curl -X POST http://localhost:3000/v1/memories \
  -H "Content-Type: application/json" \
  -d '{"actorId":"agent-1","importance":5}'
# 400 { "error": "Validation failed", "issues": [
#   { "path": ["content"], "message": "Required" },
#   { "path": ["importance"], "message": "Number must be less than or equal to 1" }
# ]}

GET /openapi.json serves the generated OpenAPI 3.1 document — paste it into Swagger UI, Redoc, or Postman, or run it through an OpenAPI code generator to get a typed client in any language. The request-body schemas in the spec come from the same zod schemas that validate incoming requests, so they can't drift apart.

Note: POST /v1/prune and /v1/prune/dry-run support every PruneStrategy type except "custom" — a custom prune strategy is a JavaScript predicate function, which can't be expressed in JSON. Use the @memstack/core library directly for custom prune logic.

Usage Examples

# Health check
curl http://localhost:3000/health

# Store a memory
curl -X POST http://localhost:3000/v1/memories \
  -H "Content-Type: application/json" \
  -d '{"actorId":"agent-1","content":"User reported login bug","importance":0.8}'

# Retrieve
curl -X POST http://localhost:3000/v1/memories/retrieve \
  -H "Content-Type: application/json" \
  -d '{"actorId":"agent-1"}'

# Compile context
curl -X POST http://localhost:3000/v1/memories/context \
  -H "Content-Type: application/json" \
  -d '{"actorId":"agent-1","maxTokens":500}'

# Stream summarization (SSE)
curl -N "http://localhost:3000/v1/summarize/stream?actorId=agent-1&olderThan=2026-01-01T00:00:00Z"

Docker

docker run -p 3000:3000 \
  -e MEMSTACK_STORAGE=postgres \
  -e DATABASE_URL=postgresql://... \
  -e OPENAI_API_KEY=sk-... \
  ghcr.io/isiomac/memstack-server:0.7.2

License

MIT

Keywords

api

FAQs

Package last updated on 20 Sep 2026

Related posts