A TypeScript RAG Stack That Turns Project Decisions Into a Queryable Asset
Most RAG tutorials stop at a demo that stuffs PDFs into a vector store and calls it done. CorpRAG models the harder, higher-value problem: maintaining a living index of project rationale that an AI agent can query through a standard protocol, with every answer pointing back to a specific source file.
Project context — why JWT was chosen over sessions, why a table was split, what constraint a business rule addressed — decays faster than code. CorpRAG captures these decisions as structured Markdown documents and runs them through a full RAG pipeline: chunking, embedding with nomic-embed-text via Ollama, and similarity search in LanceDB. The system separates knowledge by business domain and tags each chunk with metadata for filtering and source traceability.
Instead of bolting a chatbot directly onto the retrieval layer, the project exposes query tools through the Model Context Protocol. An MCP-capable AI client can call domain-specific tools like ext_query or fr_query on demand, keeping context windows small and answers grounded in specific source documents. The architecture decouples retrieval from generation, so the knowledge base can be re-indexed without touching client prompts.
The column that accompanies the code treats RAG as a data pipeline to debug, not a magic API. It walks through each link — document loading, splitting, embedding, vector storage, and MCP tool wrapping — and stresses that answer quality is the product of every stage multiplied together.
Treating RAG as a composable pipeline rather than a monolithic API call forces developers to isolate failures: a bad answer could be a chunking problem, a retrieval problem, or a prompt problem, and each has a different fix.
Exposing retrieval through MCP tools instead of a direct chat loop is an underappreciated architectural choice. It lets the knowledge base evolve independently of whichever LLM client eventually consumes it, and it avoids the context-window bloat that comes from dumping entire document sets into a system prompt.
The default chunk size of 500 with 50 overlap is presented as a starting point to validate against real queries, not a tuned recommendation. Most RAG projects skip this empirical tuning step and then blame the model for poor retrieval.