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

@memstack/mcp

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@memstack/mcp

MCP server for MemStack — AI agent memory via Model Context Protocol

latest
Source
npmnpm
Version
0.7.3
Version published
Weekly downloads
158
251.11%
Maintainers
1
Weekly downloads
 
Created
Source

@memstack/mcp

MCP server for MemStack — persistent AI agent memory via the Model Context Protocol.

Installation

npm install -g @memstack/mcp

Install a database driver only when selecting that storage backend:

npm install @memstack/mcp better-sqlite3 # SQLite
npm install @memstack/mcp ioredis        # Redis
npm install @memstack/mcp postgres       # Postgres (or pg)

Memory, disk, and Markdown storage need only @memstack/mcp. SQLite requires a writable database path and package lifecycle scripts. The Glama deployment image is packages/mcp/Dockerfile; it runs the stdio MCP command directly, which Glama wraps as its hosted transport. It is not the REST server image.

Quick Start

Add to your MCP client config (~/.config/opencode/, ~/.claude/mcp.json, or .cursor/mcp.json):

{
  "mcpServers": {
    "memstack": {
      "command": "npx",
      "args": ["-y", "@memstack/mcp"],
      "env": {
        "MEMSTACK_STORAGE": "memory",
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

Configuration

All configuration is via environment variables. No config files needed.

Storage backends

VariableValuesDefault
MEMSTACK_STORAGEmemory, disk, markdown, postgres, sqlite, redismemory

In-memory (default — testing only, data lost on restart):

MEMSTACK_STORAGE=memory

Disk (JSON file per actor):

MEMSTACK_STORAGE=disk
MEMSTACK_DIR=/Users/me/.memstack

Markdown (zero infra, human-readable):

MEMSTACK_STORAGE=markdown
MEMSTACK_DIR=/Users/me/.memstack

Postgres (production):

MEMSTACK_STORAGE=postgres
DATABASE_URL=postgresql://user:pass@localhost/memstack

Redis:

MEMSTACK_STORAGE=redis
REDIS_URL=redis://localhost:6379

SQLite:

MEMSTACK_STORAGE=sqlite
SQLITE_PATH=./memory.db

LLM providers

VariablePurpose
OPENAI_API_KEYOpenAI LLM (default)
ANTHROPIC_API_KEYAnthropic (summarization)
MEMSTACK_OPENAI_BASE_URLCustom API endpoint (DeepSeek, etc.)
MEMSTACK_LLM_MODELModel override
MEMSTACK_EMBED_ON_STOREAuto-embed on store (default: true)
MEMSTACK_ACTORDefault actor ID

At least one of OPENAI_API_KEY or ANTHROPIC_API_KEY must be set. Anthropic preferred if both are set.

VariablePurpose
OPENAI_API_KEYOpenAI embeddings

Without embedding config, retrieval falls back to keyword + importance search.

Tools

The MCP server exposes these tools to the agent:

ToolDescription
memory_processStore with auto-enrichment (importance, tags)
memory_storeStore a memory
memory_store_batchStore multiple memories in one call (batched embeddings)
memory_getGet a single memory by ID
memory_retrieveRetrieve memories by query, strategy, time range
memory_compile_contextAssemble token-budgeted LLM-ready context
memory_summarizeCompress old interactions via LLM
memory_pruneRemove stale/low-importance memories
memory_purge_actorDelete all memories for an actor
memory_mergeMerge multiple memories into one
memory_statsMemory diagnostics (counts, types, importance)
memory_deleteDelete a single memory
memory_delete_manyDelete multiple memories by ID
memory_touchBump a memory's recency without changing its content
memory_exportExport a memory snapshot for backup/migration
memory_importImport memories from a snapshot produced by memory_export
memory_healthCheck storage/LLM/embedding connectivity
memory_dry_run_prunePreview what would be pruned

Resources

URIDescription
memory://{actorId}/contextCompiled LLM context as markdown
memory://{actorId}/statsActor memory stats as JSON

Input handling

Tool arguments are normalized and validated before storage:

  • memory_store / memory_process reject an empty or missing content with a tool error instead of creating a blank memory.
  • Non-string content is coerced to a string; importance is clamped to 0.0–1.0; empty tags are dropped; actorId is trimmed.
  • memory_import with an empty memories array returns { "imported": 0 } (flagged isError) instead of throwing.
  • memory_import preserves each memory's original createdAt, so it round-trips exactly with memory_export.
  • memory_prune / memory_dry_run_prune reject unknown strategy type values with a clear error.

Prompts

PromptDescription
memory_contextAuto-injected memory context for current actor

Transport

By default memstack-mcp speaks MCP over stdio — the client spawns it as a subprocess (the Quick Start config above). This is the right choice for one agent per process (opencode, Claude Code, Claude Desktop, Cursor, etc.).

For a shared memory server reachable by multiple agents/processes over the network, run it in Streamable HTTP mode instead:

memstack-mcp --http --port 3939
# MCP endpoint: http://localhost:3939/mcp

HTTP mode is stateless (sessionIdGenerator: undefined per the MCP spec) — each request gets a fresh protocol handshake, but all requests share one underlying MemStack instance, so storage connections aren't reopened per call. Point any Streamable-HTTP-capable MCP client at http://host:3939/mcp.

Actor persistence

By default, all memories belong to the "default" actor. Set MEMSTACK_ACTOR to identify the agent:

MEMSTACK_ACTOR=my-agent

This keeps memory isolated per agent. The agent can also override the actor with actorId in any tool call.

Publishing

cd packages/mcp
pnpm build && pnpm check && pnpm test
npm publish --access public

After publishing, users install with:

npm install -g @memstack/mcp

License

MIT

Keywords

mcp

FAQs

Package last updated on 20 Sep 2026

Related posts