MCP Hub
Back to servers

brain-mcp

An MCP server that provides persistent semantic memory backed by PostgreSQL and pgvector for storing and searching thoughts via vector embeddings. It enables dimensional organization, conflict detection, and historical tracking of facts, decisions, and observations.

glama
Updated
Mar 6, 2026

brain-mcp

An MCP (Model Context Protocol) server that provides persistent semantic memory backed by PostgreSQL + pgvector. Store "thoughts" with vector embeddings and organize them via a flexible dimensional model.

Features

  • Semantic search — find thoughts by meaning using cosine similarity over vector embeddings
  • Dimensional organization — tag thoughts with typed dimensions (person, project, topic, tag, etc.)
  • Thought temporality — thoughts have types (fact, decision, observation, question) and can be superseded while preserving history
  • Multi-brain support — isolated knowledge spaces via the BRAIN_NAME environment variable
  • Conflict detection — automatically surfaces similar existing thoughts when capturing new ones

Tools

ToolDescription
capture_thoughtStore a thought with type, dimensions, and embedding. Surfaces conflicts with similar active thoughts.
searchSemantic vector search with optional filters (dimension, thought type, etc.)
list_recentChronological listing with optional filters
explore_dimensionAll thoughts linked to a given dimension
list_dimensionsAll dimensions with thought counts
supersede_thoughtReplace an existing thought, preserving history and optionally copying dimensions

Setup

Prerequisites

  • Node.js
  • pnpm
  • Docker (for PostgreSQL + pgvector)
  • An OpenRouter API key (for generating embeddings)

Install and run

# Install dependencies
pnpm install

# Start PostgreSQL with pgvector (port 5488)
docker compose up -d

# Build
pnpm run build

# Run the server (stdio transport)
OPENROUTER_API_KEY=your-key-here node dist/index.js

Configure in Claude Code

Add to your Claude Code MCP settings:

{
  "mcpServers": {
    "brain": {
      "command": "node",
      "args": ["/path/to/brain-mcp/dist/index.js"],
      "env": {
        "OPENROUTER_API_KEY": "your-key-here",
        "BRAIN_NAME": "personal"
      }
    }
  }
}

Environment variables

VariableDescriptionDefault
DATABASE_URLPostgreSQL connection stringpostgresql://brain:brain@localhost:5488/brain
OPENROUTER_API_KEYRequired for embedding generation
EMBEDDING_MODELOverride the embedding modelopenai/text-embedding-3-small
BRAIN_NAMEWhich brain (knowledge space) to usepersonal

Database schema

Migrations are in migrations/ and are auto-applied by the Docker entrypoint.

  • brains — isolated knowledge spaces
  • thoughts — content + vector(1536) embedding + metadata + thought type + status
  • dimensions — typed categories, unique per (brain, name, type)
  • thought_dimensions — many-to-many links with optional context

Embeddings are indexed with HNSW for fast cosine similarity search.

Development

pnpm run dev    # watch mode (tsc --watch)

License

ISC

Reviews

No reviews yet

Sign in to write a review