Provides containerized deployment capabilities with Docker and Docker Compose support for running the memory server in isolated environments with configurable embedding providers
Enables knowledge graph operations for GitHub repositories, including repository initialization, task management, and synchronization of GitHub-specific observations and canonical URLs
Integrates with Google Gemini's text-embedding-004 model to generate 768-dimensional embeddings for vector search and hybrid search capabilities in the knowledge graph
Connects to local Ollama instances to generate embeddings using models like nomic-embed-text, enabling self-hosted embedding generation for vector search without external API dependencies
Integrates with OpenAI's embedding models (text-embedding-3-small, text-embedding-3-large) to generate high-quality vector embeddings for semantic search and knowledge graph operations
Exposes detailed metrics and monitoring capabilities including database connection pool statistics, tool execution latencies, and prepared statement cache performance for operational visibility
Uses SQLite-compatible libSQL for persistent storage of knowledge graphs with vector search capabilities, supporting both local file databases and remote libSQL servers
Provides remote database connectivity to Turso's libSQL cloud platform, enabling distributed knowledge graph storage with vector search capabilities across multiple projects
mcp-memory-libsql-go
A Go implementation of the MCP Memory Server using libSQL for persistent storage with vector search capabilities.
Overview
This project started as a 1:1 feature port of the TypeScript mcp-memory-libsql project to Go. However, this project has since evolved to included much-needed improvements upon the original codebase.
mcp-memory-libsql-go provides a high-performance, persistent memory server for the Model Context Protocol (MCP) using libSQL (a fork of SQLite by Turso) for robust data storage, including vector search capabilities.
The go implemenation has a few advantages:
2x performance
40% less memory footprint
single binary with no runtime dependencies
tursodb/go-libsql driver
multi-project support
And more!
Features
Persistent Storage: Uses libSQL for reliable data persistence
Vector Search: Built-in cosine similarity search using libSQL's vector capabilities
Hybrid Search: Leverages Semantic & Vector search using a postgres-inspired algorithm
MCP Integration: Fully compatible with the Model Context Protocol, stdio & sse transports
Knowledge Graph: Store entities, observations, and relations
Multiple Database Support: Works with local files and remote libSQL servers
Multi-Project Support: Optionally, run in a mode that manages separate databases for multiple projects.
Metrics (optional): No-op by default; enable Prometheus exporter with
METRICS_PROMETHEUS=true
Installation
To install the mcp-memory-libsql-go binary to a standard location on your system, use the following command:
This will compile the binary and install it in a standard directory (e.g., ~/.local/bin on Linux or /usr/local/bin on macOS), which should be in your system's PATH.
Quick Start
Local (stdio) – single database
Remote libSQL (stdio)
SSE transport (HTTP)
Docker & Docker Compose (0→1 guide)
This section shows exactly how to get the server running in Docker, with or without docker-compose, and how to enable embeddings and hybrid search.
Prerequisites
Docker (v20+) and Docker Compose (v2)
Open ports: 8080 (SSE) and 9090 (metrics/health)
Disk space for a mounted data volume
1) Build the image
This builds mcp-memory-libsql-go:local and injects version metadata.
2) Create a data directory
3) Choose an embeddings provider (optional but recommended)
Set EMBEDDINGS_PROVIDER and provider-specific variables. For new databases, set EMBEDDING_DIMS to the desired embedding dimensionality. For existing databases, the server automatically detects the current DB dimensionality and adapts provider output vectors to match it (see “Embedding Dimensions” below). Common mappings are listed later in this README.
You can create a .env file for Compose or export env vars directly. Example .env for OpenAI:
Pre-built GHCR image (quick-start)
We publish pre-built images to the GitHub Container Registry (GHCR) so you can get started without building locally.
Authenticate (if pulling a private image or using rate-limited endpoints - most of you can skip this step):
Pull the latest pre-built image:
Run the container (example SSE mode):
Use with Docker Compose
Edit the docker-compose.yml to use the GHCR image (replace the build: section or set image:):
Then start:
Where to find tags
Visit the project Releases or the GitHub Packages /ghcr page for this repository to find available tags and changelogs.
Each database fixes its embedding size at creation (F32_BLOB(N)). The server now (1) detects the DB’s current size at startup and (2) automatically adapts provider outputs via padding/truncation so you can change provider/model without migrating the DB. To change the actual stored size, create a new DB (or run a manual migration) with a different EMBEDDING_DIMS.
4) Run with docker-compose (recommended)
The repo includes a docker-compose.yml with profiles:
single(default): single database at/data/libsql.dbmulti: multi-project mode at/data/projects/<name>/libsql.dbollama: optional Ollama sidecarlocalai: optional LocalAI sidecar (OpenAI-compatible)
Start single DB SSE server:
MODE
The Compose setup exposes a single memory service that switches behavior via the MODE environment variable. Set MODE to one of:
single— single-database mode (default)multi— multi-project mode (usesPROJECTS_DIR)voyageai— multi-project mode with VoyageAI provider-specific envs
Example one-liners:
For Coolify or other deploy systems, callmake docker-build to build the image and make docker-run (or set MODE/PORT/METRICS_PORT in the deploy env) to start the container. This decouples build and runtime for CI/CD.
OpenAI quick start (using .env above):
Ollama quick start (sidecar):
LocalAI quick start (sidecar):
Multi-project mode:
When Multi-Project Mode is enabled:
All tool calls MUST include
projectArgs.projectName.Per-project auth: include
projectArgs.authToken. On first use, the token is persisted at<ProjectsDir>/<projectName>/.auth_token(0600). Subsequent calls must present the same token.Calls without
projectNameor with invalid tokens are rejected. You can relax this by settingMULTI_PROJECT_AUTH_REQUIRED=false(see below). You can also enable automatic token initialization withMULTI_PROJECT_AUTO_INIT_TOKEN=trueand optionally provideMULTI_PROJECT_DEFAULT_TOKEN.
Health and metrics:
Stop and clean up:
5) Alternative: plain docker run
Remote libSQL (optional)
Point to a remote libSQL instance:
If you later change EMBEDDING_DIMS, it will not alter an existing DB’s schema. The server will continue to adopt the DB’s actual size. To change sizes, create a new DB or migrate*.
* Automated migrations will be coming in the future
Example (Go) SSE client
Multi-project mode
Configure embedding dimensions
ChangingEMBEDDING_DIMS for an existing DB requires a manual migration or new DB file.
Usage
Prompts
This server registers MCP prompts to guide knowledge graph operations:
quick_start: Quick guidance for using tools (search, read, edit)search_nodes_guidance(query, limit?, offset?): Compose effective searches with paginationkg_init_new_repo(repoSlug, areas?, includeIssues?): Initialize an optimal KG for a new repositorykg_update_graph(targetNames, replaceObservations?, mergeObservations?, newRelations?, removeRelations?): Update entities/relations idempotentlykg_sync_github(tasks, canonicalUrls?): Ensure exactly one canonicalGitHub:observation perTask:*kg_read_best_practices(query, limit?, offset?, expand?, direction?): Best-practices layered graph reading
Notes:
Prompts return structured descriptions of recommended tool sequences.
Follow the recommended order to maintain idempotency and avoid duplicates.
Text search gracefully falls back to LIKE when FTS5 is unavailable; vector search falls back when vector_top_k is missing.
Query language highlights for
search_nodes(text):FTS first, LIKE fallback; tokenizer includes
:-_@./.Prefix: append
*to a token (e.g.,Task:*). Recommended token length ≥ 2.Field qualifiers (FTS only):
entity_name:andcontent:(e.g.,entity_name:"Repo:"* OR content:"P0").Phrases:
"exact phrase". Boolean OR supported (space implies AND).Special:
Task:*is treated as a prefix on the literalTask:token across both entity name and content.On FTS parse errors (e.g., exotic syntax), the server auto-downgrades to LIKE and normalizes
*→%.Ranking: when FTS is active, results are ranked by BM25 if the function is available; otherwise ordered by
e.name. BM25 can be disabled or tuned via environment (see below).
Examples:
Using Prompts with MCP Clients
What prompts are
Prompts are named, parameterized templates you can fetch from the server. They return guidance (and example JSON plans) describing which tools to call and with what arguments.
Prompts do not execute actions themselves. Your client still calls tools like
create_entities,search_nodes, etc., using the plan returned by the prompt.
Workflow
List prompts:
ListPromptsRetrieve a prompt:
GetPrompt(name, arguments)Parse the returned description for the JSON tool plan and follow it to execute tool calls (via
CallTool).
Minimal Go example
Tip: Render the prompt description as Markdown to view Mermaid diagrams and copy the embedded JSON plan.
Command-line Flags
-libsql-url: Database URL (default:file:./libsql.db). Overrides theLIBSQL_URLenvironment variable.-auth-token: Authentication token for remote databases. Overrides theLIBSQL_AUTH_TOKENenvironment variable.-projects-dir: Base directory for projects. Enables multi-project mode. If this is set,-libsql-urlis ignored.-transport: Transport to use:stdio(default) orsse.-addr: Address to listen on when using SSE transport (default:8080).-sse-endpoint: SSE endpoint path when using SSE transport (default/sse).
Environment Variables
LIBSQL_URL: Database URL (default:file:./libsql.db)Local file:
file:./path/to/db.sqliteRemote libSQL:
libsql://your-db.turso.io
LIBSQL_AUTH_TOKEN: Authentication token for remote databasesEMBEDDING_DIMS: Embedding dimension for new databases (default:4). Existing DBs are auto-detected and take precedence at runtime.EMBEDDINGS_ADAPT_MODE: How to adapt provider vectors to the DB size:pad_or_truncate(default) |pad|truncate.PROJECTS_DIR: Base directory for multi-project mode (can also be set via flag-projects-dir).MULTI_PROJECT_AUTH_REQUIRED: Set tofalse/0to disable per-project auth enforcement (default: required).MULTI_PROJECT_AUTO_INIT_TOKEN: Set totrue/1to auto-create a token file on first access when none exists; the first call will fail with an instruction to retry with the token.MULTI_PROJECT_DEFAULT_TOKEN: Optional token value used when auto-initializing; if omitted, a random token is generated.DB_MAX_OPEN_CONNS: Max open DB connections (optional)DB_MAX_IDLE_CONNS: Max idle DB connections (optional)DB_CONN_MAX_IDLE_SEC: Connection max idle time in seconds (optional)DB_CONN_MAX_LIFETIME_SEC: Connection max lifetime in seconds (optional)METRICS_PROMETHEUS: If set (e.g.,true), expose Prometheus metricsMETRICS_PORT: Metrics HTTP port (default9090) exposing/metricsand/healthzEMBEDDINGS_PROVIDER: Optional embeddings source. Supported values and aliases:openaiollamagemini|google|google-gemini|google_genaivertexai|vertex|google-vertexlocalai|llamacpp|llama.cppvoyageai|voyage|voyage-aiThe server still accepts client-supplied embeddings if unset.
Hybrid Search (optional):
HYBRID_SEARCH(true/1 to enable)HYBRID_TEXT_WEIGHT(default 0.4)HYBRID_VECTOR_WEIGHT(default 0.6)HYBRID_RRF_K(default 60)Text ranking (BM25 for FTS):
BM25_ENABLE(default true). Set tofalseor0to disable BM25 ordering.BM25_K1(optional) — saturation parameter. Example1.2.BM25_B(optional) — length normalization parameter. Example0.75.If
BM25_K1andBM25_Bare both set, the server usesbm25(table,k1,b); otherwise it usesbm25(table).
OpenAI:
OPENAI_API_KEY,OPENAI_EMBEDDINGS_MODEL(defaulttext-embedding-3-small).Ollama:
OLLAMA_HOST,OLLAMA_EMBEDDINGS_MODEL(defaultnomic-embed-text, dims 768). ExampleOLLAMA_HOST=http://localhost:11434.Google Gemini (Generative Language API):
GOOGLE_API_KEY,GEMINI_EMBEDDINGS_MODEL(defaulttext-embedding-004, dims 768).Google Vertex AI:
VERTEX_EMBEDDINGS_ENDPOINT,VERTEX_ACCESS_TOKEN(Bearer token). Endpoint format:https://{location}-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/publishers/google/models/{model}:predict.LocalAI / llama.cpp (OpenAI-compatible):
LOCALAI_BASE_URL(defaulthttp://localhost:8080/v1),LOCALAI_EMBEDDINGS_MODEL(defaulttext-embedding-ada-002, dims 1536), optionalLOCALAI_API_KEY.VoyageAI:
VOYAGEAI_API_KEY(orVOYAGE_API_KEY),VOYAGEAI_EMBEDDINGS_MODEL(defaultvoyage-3-lite). OptionalVOYAGEAI_EMBEDDINGS_DIMSto explicitly set expected output length if you need to override.
Provider outputs are automatically adapted to the DB’s fixed embedding size (padding/truncation). This allows switching providers/models without recreating the DB. Your client-supplied vector queries must still be exactly the DB size. Use thehealth_check tool to see the current EmbeddingDims.
Hybrid Search
Hybrid Search fuses text results (FTS5 when available, otherwise LIKE) with vector similarity using an RRF-style scoring function:
Score =
HYBRID_TEXT_WEIGHT * (1/(k + text_rank)) + HYBRID_VECTOR_WEIGHT * (1/(k + vector_rank))Defaults: text=0.4, vector=0.6, k=60
Requires an embeddings provider to generate a vector for the text query. If unavailable or dims mismatch, hybrid degrades to text-only.
If FTS5 is not available, the server falls back to
LIKEtransparently.When FTS is active, the text-side rank uses BM25 (if available) for higher-quality ordering; otherwise it uses name ordering.
Enable and tune:
Common model → EMBEDDING_DIMS mapping
Provider | Model | Dimensions | Set
|
OpenAI |
| 1536 | 1536 |
OpenAI |
| 3072 | 3072 |
Ollama |
| 768 | 768 |
Gemini |
| 768 | 768 |
VertexAI |
| 768 | 768 |
LocalAI |
| 1536 | 1536 |
VoyageAI |
| varies | Set once at DB create |
![IMPORTANT] Verify your exact model’s dimensionality with a quick API call (examples below) and set
EMBEDDING_DIMSaccordingly before creating a new DB.
Provider quick verification (curl / Go)
These calls help you confirm the embedding vector length (dimension) for your chosen model.
OpenAI
Ollama (v0.2.6+ embeds endpoint)
Notes:
The entrypoint no longer calls
ollama runfor the embedding model; Ollama will lazily load on first/api/embedcall.You can tune the client timeout via
OLLAMA_HTTP_TIMEOUT(e.g.30s,60s, or integer seconds like90).
Gemini (Generative Language API)
Vertex AI (using gcloud for access token)
LocalAI (OpenAI-compatible) VoyageAI (Go SDK)
Running the Server
Single Database Mode
Multi-Project Mode
When running in multi-project mode, the server will create a subdirectory for each project within the specified projects directory. Each subdirectory will contain a libsql.db file.
Tools Provided
The server provides the following MCP tools:
create_entities: Create new entities with observations and optional embeddingssearch_nodes: Search for entities and their relations using text or vector similarityread_graph: Get recent entities and their relationscreate_relations: Create relations between entitiesdelete_entity: Delete an entity and all its associated datadelete_relation: Delete a specific relation between entitiesadd_observations: Append observations to an existing entityopen_nodes: Retrieve entities by names with optional relationsdelete_entities: Delete multiple entities by name (bulk)delete_observations: Delete observations by id/content or all for an entitydelete_relations: Delete multiple relations (bulk)update_entities: Update entity metadata/embedding and manage observations (merge/replace)update_relations: Update relation tupleshealth_check: Return server info and configurationneighbors: 1-hop neighbors for given entities (direction out|in|both)walk: bounded-depth graph walk from seeds (direction/limit)shortest_path: shortest path between two entities
Tool Summary
Tool | Purpose | Required args | Optional args | Notes |
create_entities | Create/update entities and observations |
|
| Replaces observations for provided entities |
search_nodes | Text or vector search |
|
,
,
| Query is string or numeric array |
read_graph | Recent entities + relations | – |
,
| Default limit 10 |
create_relations | Create relations |
|
| Inserts source→target with type |
delete_entity | Delete entity + all data |
|
| Cascades to observations/relations |
delete_relation | Delete a relation |
,
,
|
| Removes one tuple |
add_observations | Append observations |
,
|
| Does not replace existing |
open_nodes | Get entities by names |
|
,
| Fetch relations for returned set |
delete_entities | Bulk delete entities |
|
| Transactional bulk delete |
delete_observations | Delete observations |
|
,
,
| If neither provided, deletes all for entity |
delete_relations | Bulk delete relations |
|
| Transactional bulk delete |
update_entities | Partial entity update |
|
| Update type/embedding/observations |
update_relations | Update relation tuples |
|
| Delete old + insert new tuple |
health_check | Server health/info | – | – | Version, revision, build date, dims |
neighbors | 1-hop neighbors |
|
,
,
| direction: out/in/both (default both) |
walk | Graph expansion (BFS) |
|
,
,
,
| Bounded-depth walk |
shortest_path | Shortest path |
,
|
,
| Returns path entities and edges |
Metrics
Set
METRICS_PROMETHEUS=trueto expose/metricsand/healthzonMETRICS_PORT(default9090).DB hot paths and tool handlers are instrumented with counters and latency histograms.
Additional gauges and counters:
db_pool_gauges{state="in_use|idle"}observed periodically and onhealth_checkstmt_cache_events_total{op="prepare",result="hit|miss"}from the prepared statement cache
Recommended Prometheus histogram buckets (example):
If metrics are disabled, a no-op implementation is used.
We keep this table and examples up to date as the project evolves. If anything is missing or incorrect, please open an issue or PR.
Planned/Upcoming tools:
– (none for now) –
Using Tools in Multi-Project Mode
When in multi-project mode, all tools accept an optional project context under projectArgs.projectName. If not provided, the server uses the "default" project.
Example
Example
Example
Pagination parameters:
limit(optional): maximum number of results (default 5 forsearch_nodes, 10 forread_graph)offset(optional): number of results to skip (for paging)
Example
Example
Example
Example
Example
Example
Example
Example
Vector search input: The server accepts vector queries as JSON arrays (e.g., [0.1, 0.2, 0.3, 0.4]). Numeric strings like "0.1" are also accepted. The default embedding dimension is 4 (configurable via EMBEDDING_DIMS).
Embedding Dimensions
The embedding column is F32_BLOB(N), fixed per database. On startup, the server detects the DB’s N and sets runtime behavior accordingly, adapting provider outputs via padding/truncation. Changing EMBEDDING_DIMS does not modify an existing DB; to change N, create a new DB (or migrate). Use the health_check tool to view the active EmbeddingDims.
Transports: stdio and SSE
This server supports both stdio transport (default) and SSE transport. Use -transport sse -addr :8080 -sse-endpoint /sse to run an SSE endpoint. Clients must use an SSE-capable MCP client (e.g., go-sdk SSEClientTransport) to connect.
Development
Prerequisites
Go 1.24 or later
libSQL CGO dependencies (automatically handled by go-libsql)
Building
Testing
Client Integration
This server supports both stdio and SSE transports and can run as:
a raw binary (local stdio or SSE)
a single Docker container (stdio or SSE)
a Docker Compose stack (SSE, with multi-project mode and optional embeddings)
Below are reference integrations for Cursor/Cline and other MCP-ready clients.
Cursor / Cline (MCP) via stdio (single DB)
Cursor / Cline (MCP) via stdio (multi-project)
Replace
/path/to/some/dir/.memory/memory-bankwith your desired base directory. The server will create/path/to/.../<projectName>/libsql.dbper project.
Cursor / Cline (MCP) via SSE (Docker Compose, recommended for embeddings)
Run the Compose stack in multi-project mode with Ollama embeddings (hybrid search, pooling, metrics):
Cursor/Cline SSE config:
Other usage patterns
Raw binary (stdio):
./mcp-memory-libsql-go -libsql-url file:./libsql.dbRaw binary (SSE):
./mcp-memory-libsql-go -transport sse -addr :8080 -sse-endpoint /sse # SSE URL: http://localhost:8080/sseDocker run (SSE):
docker run --rm -p 8080:8080 -p 9090:9090 \ -e METRICS_PROMETHEUS=true -e METRICS_PORT=":9090" \ -e EMBEDDING_DIMS=768 \ -v $(pwd)/data:/data \ mcp-memory-libsql-go:local -transport sse -addr :8080 -sse-endpoint /sseDocker Compose (single DB):
docker compose --profile single up --build -d # SSE URL: http://localhost:8080/sse, Metrics: http://localhost:9090/healthzDocker Compose (multi-project, Ollama, hybrid):
make prod # SSE URL: http://localhost:8081/sse, Metrics: http://localhost:9091/healthz
Architecture
The project follows a clean, modular architecture:
main.go: Application entry pointinternal/apptype/: Core data structures and MCP type definitionsinternal/database/: Database client and logic using libSQLinternal/server/: MCP server implementationinternal/embeddings/: Embeddings Providers implementations
License
MIT
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
🧠 High-performance persistent memory system for Model Context Protocol (MCP) powered by libSQL. Features vector search, semantic knowledge storage, and efficient relationship management - perfect for AI agents and knowledge graph applications.
Related MCP Servers
- Asecurity-licenseAqualityA high-performance MCP server utilizing libSQL for persistent memory and vector search capabilities, enabling efficient entity management and semantic knowledge storage.Last updated -625372MIT License
- Asecurity-licenseAqualityA high-performance, persistent memory system for the Model Context Protocol (MCP) providing vector search capabilities and efficient knowledge storage using libSQL as the backing store.Last updated -625318MIT License
- -security-license-qualityModel Context Protocol (MCP) server implementation for semantic search and memory management using TxtAI. This server provides a robust API for storing, retrieving, and managing text-based memories with semantic search capabilities. You can use Claude and Cline AI AlsoLast updated -11
- -security-license-qualityA Model Context Protocol (MCP) server that provides persistent memory and context management for AI systems through a structured 5-phase optimization workflow.Last updated -1MIT License
Appeared in Searches
- Semantic search, RAG, and memory systems
- A tool for storing chat conversations and generating knowledge graphs
- Claude Desktop with persistent memory and artifact library system
- A search for memes or internet memes
- A server for managing systematic Drupal module development with advanced memory and project features