PG-Git (Semantic Memory MCP)
A persistent, PostgreSQL-backed repository management system and semantic memory MCP server that stores the entire Git DAG natively in PostgreSQL with temporally-decayed semantic vector embeddings for AI IDEs.
README
PG-Git (Semantic Memory MCP)
<p align="center"> <img src="assets/banner.png" alt="PG-Git Banner" width="100%"> </p>
A persistent, PostgreSQL-backed repository management system and semantic memory MCP server. Instead of storing Git objects loosely on the file system, PG-Git stores the entire Directed Acyclic Graph (DAG) natively in PostgreSQL, complete with automatically generated, temporally-decayed semantic vector embeddings for AI IDEs.
🧠 Why PG-Git?
In the standard AI coding agent ecosystem, searching codebases relies on rigid grep searches or expensive AST parsing. PG-Git fundamentally changes this by bridging Git directly with Vector Databases:
- Semantic Code Search: Find code based on what it does, not just its syntax.
- Exponential Temporal Decay: PG-Git mathematically decays older vectors. Your agent will prioritize code you wrote yesterday over highly similar dead code written 6 months ago.
- Local-First Purity: No cloud APIs. It uses Ollama with
nomic-embed-textfor 100% private, on-device vectorization. - ACID Compliant: Native transactions ensure complete safety for multi-node accessibility and concurrent AI swarm agents.
⚡ Quick Start
You must have Ollama running with the nomic-embed-text model pulled:
ollama run nomic-embed-text
1. Install Dependencies & Migrate
You will need a running PostgreSQL instance with pgvector enabled.
npm install
cp .env.example .env
# Edit .env with your PostgreSQL credentials
node db/migrate.js
2. Import Your GitHub History
You can instantly import any local .git repository. PG-Git will natively parse the Git history, generate semantic embeddings for all blobs, and securely deduplicate them into PostgreSQL:
npm run import
3. Add to your Agent / IDE Configuration (e.g. mcp_config.json):
{
"mcpServers": {
"pg-git-mcp": {
"command": "node",
"args": ["/absolute/path/to/pg-git/server/mcp.js"],
"env": {
"OLLAMA_URL": "http://localhost:11434",
"EMBED_MODEL": "nomic-embed-text"
}
}
}
}
4. Start the Web UI (Optional) PG-Git includes a sleek, dual-pane IDE interface for browsing your semantic repositories.
npm run dev
🚀 Real-World Usage Examples
To effectively use PG-Git, simply speak to your IDE agent normally. It will use the MCP tools (pg_git_semantic_search, pg_git_list_repos, pg_git_read_tree, pg_git_read_blob) to interface with the database.
Example 1: Finding specific logic
You: "Where do we handle the temporal decay for the memory MCP?" Agent: [Calls
pg_git_semantic_search] "I found the logic inserver/index.jsinside thekrusch-memory-mcprepo. It uses theexp(-DECAY_RATE * age_in_days)formula."
Example 2: Reading a repository tree
You: "What is the folder structure for the pg-git project?" Agent: [Calls
pg_git_read_tree] "Here is the root directory structure..."
How Does Temporal Decay Work?
When calling pg_git_semantic_search, PG-Git returns the highest cosine-similarity matches. However, it applies Exponential Temporal Decay based on the blob's last_seen_at timestamp. If you have two very similar pieces of code, the newer one will have a significantly higher score, preventing your agent from hallucinating based on outdated implementations.
🤖 The Autonomous Agent Workflow (/close)
You can integrate PG-Git into your agentic workflow to ensure your semantic memory is always up to date.
Whenever you step away from a task, tell your agent to run the snapshot script. The agent will autonomously:
- Hash the current project folder into Git Blobs and Trees.
- Ping Ollama to embed any new or modified files.
- Commit the state directly into PostgreSQL.
Command to run:
npm run snapshot
🛠️ Configuration & Environment Variables
| Variable | Description | Default |
|---|---|---|
DB_HOST |
PostgreSQL Host address. | localhost |
DB_PORT |
PostgreSQL Port. | 5432 |
DB_NAME |
Database Name. | postgres |
DB_USER |
Database User. | postgres |
DB_PASSWORD |
Database Password. | postgres |
OLLAMA_URL |
The endpoint for your local Ollama instance. | http://localhost:11434 |
EMBED_MODEL |
The Ollama text-embedding model to use. | nomic-embed-text |
License
MIT License. Created by kruschdev.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。