postgres-pgvector-memory-mcp
v1.0.0
Published
MCP server for semantic memory storage using local Postgres with pgvector
Maintainers
Readme
Postgres Memory MCP Server
[!IMPORTANT] Prerequisites for Use
To ensure efficient operation and connectivity with Postgres, please verify the following:
- Rule Configuration: You must add the defined operational rules to your editor or extension's system prompt (e.g.,
.clinerules). See System Prompts.- MCP Configuration: The
mcp.jsonfile must be strictly configured as detailed in the MCP Client Configuration section.- Tool Authorization: For users of Cline, Roo Code, Kilo Code, or similar extensions: You must enable all tool permissions (check all boxes) upon initialization. Failure to approve these tools will prevent the server from authenticating and connecting to the Postgres instance.
An MCP server that provides semantic memory storage using a local PostgreSQL database with the pgvector extension. This enables your AI assistant to store, retrieve, and search memories using vector embeddings.
Features
- Semantic Search: Uses OpenAI-compatible embeddings (Xenova/all-MiniLM-L6-v2) to find relevant memories.
- Local Postgres: Runs entirely on your local machine using Docker or a local Postgres instance.
- Memory Management: Store, list, delete, and inspect memories.
- Project Isolation: Memories are scoped by
project_id.
Prerequisites
- Docker Desktop: Ensure Docker is installed and running.
- Node.js: Version 18 or higher.
Installation
1. Start Postgres with pgvector
This server is designed to work with the Docker container provided in the following repository, which includes Postgres configured with the pgvector extension:
https://github.com/cbuntingde/post-pgvector-docker
You can use the docker-compose.yml from that repository (or create one like below):
services:
db:
image: pgvector/pgvector:pg16
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:Run it:
docker-compose up -d2. Configure the MCP Server
npx postgres-pgvector-memory-mcp setupThis interactive setup will:
- Ask for your Postgres Connection String (default:
postgresql://postgres:password@localhost:5432/postgres). - Connect to the database.
- Automatically apply the database schema (create
memoriestable andvectorextension).
3. Add to your MCP Client
Add the following to your mcp.json or MCP settings:
{
"mcpServers": {
"postgres-memory": {
"command": "node",
"args": [
"c:/mcpservers/post-pgvector-mcp/dist/index.js"
],
"env": {
"POSTGRES_URL": "postgresql://postgres:password@localhost:5432/postgres"
}
}
}
}Tools
store_memory: Save a snippet of information with a category.search_memories: Find memories semantically related to a query.list_memories: recent memories for a project.delete_memory: Remove a memory by ID.get_project_stats: Count memories for a project.
Development
Install dependencies:
npm installBuild:
npm run buildRun locally:
npm run dev
License
MIT
