explaingit

samsiva-dev/pg_mcp_server

Analysis updated 2026-05-18

0PythonAudience · developerComplexity · 4/5LicenseSetup · hard

TLDR

A local, offline MCP server that lets you ask plain language questions about PostgreSQL's C source code, answered by a local LLM.

Mindmap

mindmap
  root((repo))
    What it does
      Local PostgreSQL source assistant
      Semantic and symbol search
    Tech stack
      Python
      pgvector
      Ollama
    Use cases
      Explain internals
      Find callers of a function
      Study a subsystem
    Audience
      PostgreSQL developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Ask natural language questions about PostgreSQL internals from Zed or VSCode.

USE CASE 2

Look up exact function callers and definitions in the PostgreSQL source with search_symbol.

USE CASE 3

Run semantic search over PostgreSQL's C source without sending code to any API.

USE CASE 4

Study a specific PostgreSQL subsystem like the buffer manager or WAL using scoped queries.

What is it built with?

PythonPostgreSQLpgvectorOllamaFastMCP

How does it compare?

samsiva-dev/pg_mcp_server0xallam/my-recipe0xhassaan/nn-from-scratch
Stars00
LanguagePythonPythonPython
Last pushed2022-11-22
MaintenanceDormant
Setup difficultyhardmoderatemoderate
Complexity4/52/54/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard

Needs local Postgres 18 with pgvector, Ollama models, and a full PostgreSQL source checkout indexed with ctags and cscope.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice (MIT License).

In plain English

This project is a local, offline assistant for exploring PostgreSQL's internal C source code by asking plain language questions instead of digging through the codebase by hand. It runs entirely on your own machine, with no API costs and no internet connection needed once set up, and connects to code editors like Zed and VSCode through the Model Context Protocol, or MCP. Under the hood it combines a few pieces: ctags and cscope provide exact symbol lookups such as who calls a function or where something is defined, while a vector database extension called pgvector, running inside a local Postgres 18 database, holds semantic search embeddings for tens of thousands of chunks of the PostgreSQL source code. A local embedding model turns questions and code into those vectors, and a small local language model, run through Ollama, uses the matched source snippets to write an answer grounded in the real code rather than guessing. Three tools are exposed to your editor's AI agent panel: one that performs a full retrieval and answer cycle, one that just returns the raw matching source code chunks, and one that does exact symbol lookups using cscope. Setting it up involves installing Ollama and pulling two local models, installing the pgvector extension, creating a database and loading its schema, building the ctags and cscope index over a local copy of the PostgreSQL source, indexing everything into the database with a provided script, and finally pointing your editor's MCP configuration at the server script. The author notes the local seven billion parameter model is good for explaining how code works but not for deep architecture decisions, where a larger hosted model would do better, and that the indexer needs to be rerun after upgrading to a newer PostgreSQL source version. The project is released under the MIT license.

Copy-paste prompts

Prompt 1
Use the ask_pg tool to explain how PostgreSQL evicts dirty buffers.
Prompt 2
Walk me through setting up Ollama, pgvector, and the ctags index for this project.
Prompt 3
Use search_symbol to find every caller of StrategyGetBuffer in the PostgreSQL source.
Prompt 4
Explain what index_pg_source.py does and how long the indexing step takes.

Frequently asked questions

What is pg_mcp_server?

A local, offline MCP server that lets you ask plain language questions about PostgreSQL's C source code, answered by a local LLM.

What language is pg_mcp_server written in?

Mainly Python. The stack also includes Python, PostgreSQL, pgvector.

What license does pg_mcp_server use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice (MIT License).

How hard is pg_mcp_server to set up?

Setup difficulty is rated hard.

Who is pg_mcp_server for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.