SharedBrain
SharedBrain
Local-first, multi-user shared memory for AI agents.
SharedBrain is an MCP server that gives AI agents persistent memory with semantic search. It works offline, syncs across devices and teams, and never phones home. Embeddings are computed locally via ONNX — no API keys required.
You: "Remember that we decided to use PostgreSQL for the relay server"
Agent: *stores memory with type=decision, computes embedding locally*
Later...
You: "What database are we using for sync?"
Agent: *semantic search finds the decision with 94% similarity*Quick Start
# 1. Clone and install
git clone https://github.com/anthropics/shared-brain.git
cd shared-brain
pnpm install
# 2. Initialize
pnpm --filter @shared-brain/cli dev -- init
# 3. Start the MCP server
pnpm --filter @shared-brain/server devThe server starts at http://127.0.0.1:3100/mcp. Your auth token is printed during init.
Related MCP server: Turbo Quant Memory MCP Server
MCP Client Configuration
Claude Code
Add to .claude/settings.json:
{
"mcpServers": {
"shared-brain": {
"type": "streamable-http",
"url": "http://127.0.0.1:3100/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN_HERE"
}
}
}
}Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"shared-brain": {
"url": "http://127.0.0.1:3100/mcp",
"transport": "streamable-http",
"headers": {
"Authorization": "Bearer YOUR_TOKEN_HERE"
}
}
}
}VS Code (Copilot)
Add to .vscode/mcp.json:
{
"servers": {
"shared-brain": {
"type": "http",
"url": "http://127.0.0.1:3100/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN_HERE"
}
}
}
}Architecture
┌─────────────────────────────────────────────────────────────────────┐
│ MCP Clients │
│ (Claude Code, Cursor, VS Code, custom agents) │
└──────────────────────────────┬──────────────────────────────────────┘
│ Streamable HTTP
▼
┌─────────────────────────────────────────────────────────────────────┐
│ @shared-brain/server │
│ MCP Tools: memory_store, memory_search, memory_get, memory_update │
│ MCP Resources: stats, recent, tags │
│ Auth: Bearer token / OAuth2 │
└──────────────┬──────────────────────────────────┬───────────────────┘
│ │
▼ ▼
┌──────────────────────────┐ ┌─────────────────────────────────┐
│ @shared-brain/core │ │ @shared-brain/sync │
│ │ │ │
│ - SQLite store │ │ - WebSocket client │
│ - ONNX embeddings │ │ - Offline queue │
│ - CRDT (HLC/LWW/OR-Set)│ │ - Merkle tree diff │
│ - Vector index │ │ - Relay server (PostgreSQL) │
└──────────────────────────┘ └─────────────────────────────────┘
│ │
▼ ▼
┌──────────┐ ┌──────────────────┐
│ SQLite │ │ Relay (WebSocket) │
│ (local) │ │ + PostgreSQL │
└──────────┘ └──────────────────┘Key Design Choices
Feature | Implementation | Why |
Local-first | SQLite + in-process | Works offline, zero config, fast |
Embeddings | ONNX (all-MiniLM-L6-v2) | No API keys, 384 dims, ~10ms/embed |
Conflict resolution | Per-field LWW + OR-Set | No data loss on concurrent edits |
Sync | Merkle tree + op log | O(log n) diff, minimal bandwidth |
Transport | Streamable HTTP | Multi-client, standard MCP |
Scope | Personal / Team / Org | Granular visibility control |
CLI Usage
# Initialize a new instance
shared-brain init
# Store a memory
shared-brain store --content "PostgreSQL 16 with pgvector for vector search" \
--type decision --tags "database,infrastructure" --title "DB choice"
# Semantic search
shared-brain search "what database do we use"
# Search with filters
shared-brain search "deployment" --type procedure --limit 5 --threshold 0.5
# Check sync status
shared-brain sync status
# Force push/pull
shared-brain sync push
shared-brain sync pullDocker Compose (Team Sync)
Start the relay server + PostgreSQL for team synchronization:
cd docker
docker compose up -dThis starts:
PostgreSQL (port 5432) with pgvector extension
Relay server (port 3200) for WebSocket sync
To also start the Adminer DB inspector:
docker compose --profile debug up -d
# Adminer at http://localhost:8080Then configure your .env:
SYNC_RELAY_URL=ws://localhost:3200
SYNC_AUTH_TOKEN=dev-sync-tokenMCP Tools Reference
Tool | Description |
| Store a new memory with content, type, scope, tags |
| Semantic search by meaning (not keywords) |
| Retrieve a specific memory by ID |
| Update fields of an existing memory |
| Soft-delete a memory |
| List memories with filters and pagination |
| Find semantically related memories |
| Bulk import from JSON |
| Export memories as JSON or Markdown |
| Check sync connection and pending ops |
Development
# Build all packages
pnpm build
# Run tests
pnpm test
# Dev mode (watch + rebuild)
pnpm dev
# Lint
pnpm lintProject Structure
shared-brain/
├── packages/
│ ├── core/ # Data models, CRDT, embeddings, SQLite store
│ ├── server/ # MCP server (Streamable HTTP transport)
│ ├── sync/ # Sync engine (WebSocket client + relay)
│ └── cli/ # Command-line interface
├── docker/ # Docker Compose + Dockerfile for relay
├── models/ # ONNX model cache (auto-downloaded)
└── ARCHITECTURE.md # Detailed technical designContributing
Fork the repository
Create a feature branch:
git checkout -b feat/your-featureMake your changes with tests
Ensure all checks pass:
pnpm build && pnpm test && pnpm lintSubmit a pull request
Please follow:
Conventional commits:
feat:,fix:,docs:,refactor:,test:TypeScript strict mode: no
any, no implicit returnsESM only: use
.jsextensions in importsTests: add tests for new functionality
License
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/awictor/shared-brain'
If you have feedback or need assistance with the MCP directory API, please join our Discord server