Corpus-KB
Corpus-KB is a local RAG (Retrieval-Augmented Generation) knowledge base server for ingesting, searching, and managing code and documents on your own machine. Key capabilities include:
Ingestion & Document Management
Ingest individual files, raw text, or entire directories (auto-detects code, markdown, text)
List and delete ingested documents
Search
Hybrid search (vector + full-text + RRF) across all chunks, with optional source type filter
Context-aware search with surrounding chunk expansion for richer LLM input
Similarity search by chunk ID
Retrieve results as citation-rich strings for LLM context building
Knowledge Graph
Add named entities (classes, functions, concepts, etc.) and directed, weighted relations between them
Search entities by name or type, perform BFS traversal, and retrieve all incoming/outgoing relations
SQL Access
Run SELECT queries (with JOINs, CTEs, window functions) over relational tables
Execute safe write operations (INSERT, UPDATE, DELETE) with guards against destructive commands
List available tables and schemas
Tagging & Metadata
Create tags, apply/remove them from documents, and retrieve document tags
Set and retrieve key-value metadata, globally or scoped to individual documents
Statistics & Sync
Sync vector store data into relational tables (idempotent)
Query aggregate corpus stats (total docs, chunks, types, date range) and general database/storage stats
Versioning & Time-Travel
List all historical versions, tag specific versions with human-readable labels
Check out, restore, or branch the database to any prior version
The server exposes these capabilities via MCP tools, HTTP endpoints, and a JSON-RPC socket, with multi-tenant support backed by PostgreSQL row-level security.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Corpus-KBsearch my codebase for examples of error handling"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Corpus-KB
Local RAG system for AI code editors. Ingest your codebase. Ask questions. Get answers. No cloud.
Corpus-KB is a private knowledge base for AI coding assistants. It reads your code, documentation, and notes, then answers questions grounded in your actual files. Everything runs on your machine: Postgres stores the data, Ollama generates embeddings, and a local server exposes the whole thing through MCP tools, HTTP endpoints, and a JSON-RPC socket.
What you get
Hybrid search that blends vector similarity, full-text search, and rank fusion
Knowledge graph with entities, relations, and BFS traversal
Event sourcing for audit trails and time-travel queries
Multi-tenant Postgres with row-level security on every table
MCP, HTTP, and socket APIs so any editor or script can talk to it
Related MCP server: ragi
Architecture
graph TB
Editor[AI Code Editor] -->|MCP stdio| MCP[FastMCP Server]
Editor -->|HTTP :8010| HTTP[Starlette API]
Editor -->|JSON-RPC socket| Socket[Unix socket / named pipe]
MCP --> Handlers[Command / Query Handlers]
HTTP --> Handlers
Socket --> Handlers
Handlers --> Domain[Domain Layer<br/>Aggregates + Events]
Domain --> ES[Event Store<br/>append-only]
ES --> Projections[Async Projections]
Projections --> PG[PostgreSQL 17]
PG --> VEC[pgvector<br/>vector search]
PG --> FTS[Postgres FTS<br/>to_tsvector]
PG --> AGE[Apache AGE<br/>Cypher graphs]
PG --> RLS[RLS on 12 tables]
Projections --> Ollama[Ollama<br/>embedding service]Ingest a file, directory, or raw text.
The pipeline partitions it into chunks, embeds each chunk through Ollama, extracts entities and relations, and stores the result.
Commands append events to the event store; async projections write the read models into Postgres.
Your editor queries the read models through search, SQL, or graph traversal.
Event sourcing flow
sequenceDiagram
participant C as Client
participant H as CommandHandler
participant A as Document Aggregate
participant ES as Event Store
participant P as Projection
participant DB as Postgres Tables
C->>H: ingest_file(file_path)
H->>A: create Document
A->>A: apply Ingested event
A->>A: apply ChunksAdded event
H->>ES: app.save(aggregate)
ES-->>H: event_id, version
H-->>C: {status: "success"}
ES->>P: subscribe(ChunksAdded)
P->>P: embed chunks via Ollama
P->>DB: INSERT chunks, chunks_vectors
P->>DB: UPDATE projection_checkpointsEvents are the source of truth. Projections are derived and can be rebuilt by replaying the event log. Vectors live in the chunks_vectors table and are treated as derived data, not event payload.
Quick start
From zero to a working system in about ten minutes:
# 1. Install Postgres 17 with pgvector and Apache AGE, then create a database
# See docs/INSTALL.md for platform-specific steps.
# 2. Clone the repo
git clone https://github.com/moliver28/corpus-kb.git
cd corpus-kb
# 3. Install the package
pip install -e ".[dev]"
# 4. Load the schema
psql -d postgresql://corpus_user:corpus_pass@localhost:5432/corpus_kb \
-f corpus-kb/src/storage/schema.sql
# 5. Pull the embedding model
ollama pull nomic-embed-text
# 6. Start the server
export CORPUS_KB_DATABASE_URL=postgresql://corpus_user:corpus_pass@localhost:5432/corpus_kb
python -m corpus-kb.src.server_wiring --transport http --port 8010In another terminal:
# Ingest a file
curl -X POST http://localhost:8010/api/ingest/file \
-H "Content-Type: application/json" \
-d '{"file_path": "corpus-kb/src/server_wiring.py"}'
# Search
curl -X POST http://localhost:8010/api/search \
-H "Content-Type: application/json" \
-d '{"query": "how does startup work"}'See docs/INSTALL.md for the full setup guide.
Documentation
Page | What it covers |
Full setup from scratch: Postgres, Python, Ollama, schema, first query | |
Ingest, search, graph, tags, metadata, versioning, embedding models | |
Configuration, schema, multi-tenancy, backups, monitoring, CI/CD | |
HTTP routes, request bodies, curl examples, MCP tool reference | |
Architecture deep dive, testing, PR workflow, conventions | |
MCP config validation, fail-fast pipeline behavior | |
Common questions |
Editor integration
Corpus-KB speaks MCP over stdio, so any MCP-compatible editor can connect:
OpenCode
Claude Code
Cursor
VS Code with Cline
Any other MCP client
Config files live in mcp-configs/. The setup scripts rewrite them to point at your virtual environment.
License
MIT License. See pyproject.toml for the full text.
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
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/moliver28/corpus-kb'
If you have feedback or need assistance with the MCP directory API, please join our Discord server