mcp-knowledge-base
Click on "Deploy 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., "@mcp-knowledge-base search the knowledge base for retrieval augmented generation"
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.
mcp-knowledge-base
A local, self-contained MCP (Model Context Protocol) server that lets AI assistants search, retrieve, and manage a local document collection using BM25 retrieval with stemming and stopword filtering. No external APIs required.
Built with the official MCP TypeScript SDK. Works with Claude Desktop, Cursor, Windsurf, and any MCP-compatible client.
Features
BM25 search with Porter stemming and stopword filtering for high-quality retrieval
Document chunking (~500 tokens with overlap) preserving original Markdown formatting
6 MCP tools: search, list, get, ingest, update, delete
Stdio transport (standard for local MCP servers)
File locking with stale lock detection for safe concurrent access
Corrupt store recovery with automatic backup
Zero external dependencies for search (no OpenAI/Anthropic API calls needed)
9 unit tests with Vitest
Example document auto-ingested on first run
Related MCP server: KB-MCP Server
Requirements
Node.js 20+
npm
Quick Start
git clone https://github.com/shelldon0x/mcp-knowledge-base.git
cd mcp-knowledge-base
npm install
npm run buildMCP Tools
Tool | Description |
| BM25 search across indexed document chunks with relevance scoring |
| List all indexed documents with metadata and timestamps |
| Retrieve full content of a specific document by ID |
| Add a new document (Markdown or plain text) to the knowledge base |
| Update title, content, or metadata of an existing document (re-indexes on content change) |
| Remove a document and all its chunks from the knowledge base |
MCP Client Configuration
Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"knowledge-base": {
"command": "node",
"args": ["/absolute/path/to/mcp-knowledge-base/dist/index.js"]
}
}
}Cursor / Windsurf
Add the same mcpServers block to your editor's MCP settings.
Usage Examples
Search the knowledge base
{
"query": "retrieval augmented generation",
"top_k": 5
}Returns ranked chunks with scores, source attribution, and original formatting preserved.
Ingest a new document
{
"title": "Team onboarding notes",
"content": "# Welcome\nThese are the team onboarding notes...",
"metadata": {
"source": "docs/onboarding.md",
"tags": ["onboarding", "internal"]
}
}Update a document
{
"document_id": "abc-123",
"title": "Updated title",
"content": "New content here..."
}Content changes automatically trigger re-chunking and re-indexing.
Delete a document
{
"document_id": "abc-123"
}How It Works
Search Pipeline
Tokenization: Text is lowercased and split into alphanumeric tokens
Stopword removal: 90+ common English words filtered out
Stemming: Basic Porter stemmer handles
-ing,-ed,-s,-ly,-tion,-nesssuffixes with double-consonant reductionBM25 scoring: Okapi BM25 with k1=1.5, b=0.75 ranks chunks by relevance
Source attribution: Results include document title, chunk snippet (with original formatting), and metadata
Document Storage
Documents are split into ~500 token chunks with 50-token overlap
Chunks preserve the original text (including Markdown formatting) while using stemmed tokens for indexing
All data stored in
data/knowledge-base.json(created automatically)File locking prevents concurrent write corruption (stale locks auto-expire after 30s)
Corrupt JSON files are backed up to
.corruptand the store reinitializes gracefully
Development
npm run dev # Run with tsx (hot reload)
npm run build # Compile TypeScript
npm test # Run Vitest test suiteArchitecture
src/
├── index.ts # Entry point, stdio transport setup
├── server.ts # MCP server with 6 registered tools
├── knowledge-base.ts # Document store, BM25 search, chunking, stemming
├── types.ts # TypeScript interfaces
└── __tests__/
└── knowledge-base.test.ts # 9 unit testsTech Stack
TypeScript (strict, no
any)@modelcontextprotocol/sdk for MCP server
Zod for input validation
Vitest for testing
ESM modules with NodeNext resolution
License
MIT
Available Tools
6 toolsdelete_documentB
Delete a document and its chunks from the knowledge base.
Inputs: document_id (required).
get_documentB
Retrieve full content of a specific document.
Inputs: document_id (required).
ingest_documentB
Add a new document (markdown or plain text) to the knowledge base.
Inputs: title (required), content (required), metadata.
list_documentsB
List all indexed documents with metadata.
Inputs: no named parameters.
search_knowledge_baseC
Semantic search across indexed documents.
Inputs: query (required), top_k.
update_documentC
Update an existing document and reindex if content changes.
Inputs: document_id (required), title, content, metadata.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct resource+action: search across docs, list metadata, get content, and create/update/delete lifecycle operations. The boundaries between search, list, and get are clear from the descriptions, and CRUD operations are unambiguous.
All six tools follow a consistent snake_case verb_noun pattern (search_knowledge_base, list_documents, get_document, ingest_document, delete_document, update_document). The convention is predictable throughout with no deviations.
Six tools is well-scoped for a knowledge base server, covering search, listing, retrieval, ingestion, update, and deletion without redundancy. Each tool earns its place.
The surface covers full document lifecycle: create (ingest), read (get/list/search), update (with reindex), and delete. No obvious gaps for a knowledge base domain.
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
The Needle MCP server enables semantic search on documents stored in files like PDFs, DOCX, and XLSX by connecting AI applications to external data sources. It provides capabilities to create and manage document collections, perform natural language searches on stored content, and retrieve relevant information without requiring exact keyword matches.
Serve a folder of Markdown notes as an MCP server: hybrid search, reading, and sourced answers.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceRAG-powered document search server that enables semantic search across large collections of legal and business documents (PDF, Word, Excel, PowerPoint) using local embeddings with no API costs.5MIT
- FlicenseAqualityNot gradedmaintenanceA local-first knowledge base server that enables AI clients to store, retrieve, and manage documents using semantic search. Provides privacy-focused, offline-capable memory for AI assistants with tools for ingesting, querying, updating, and deleting knowledge.721 npm-
- FlicenseNot gradedqualityBmaintenanceEnables any MCP-compatible AI assistant to search, filter, and retrieve information from a local document collection using a hybrid search pipeline with vector, BM25, reranking, and LLM enrichment.4-
- AlicenseAqualityDmaintenanceLocal-first RAG indexing and semantic search MCP server. Enables document retrieval and context-aware queries using local embedding models.36 npmMIT