The Knowledge Base MCP Server lets you manage and retrieve content through semantic search:
List Knowledge Bases: View all available knowledge bases by name
Semantic Search: Retrieve relevant content chunks across one or specific knowledge bases with customizable similarity thresholds
Automatic Index Management: Updates FAISS index when knowledge base files change
File Support: Reads text files (
.txt,.md) from specified directoriesContent Chunking: Splits files into manageable pieces using
MarkdownTextSplitterSource Tracking: Provides file paths for retrieved content
Environment Configuration: Supports setup via environment variables
Uses the Hugging Face Inference API to generate embeddings for the knowledge base content, with optional model selection through environment variables.
Uses LangChain's MarkdownTextSplitter to split file content into chunks for the knowledge base.
Knowledge Base MCP Server
This MCP server provides tools for listing and retrieving content from different knowledge bases.
Setup Instructions
These instructions assume you have Node.js and npm installed on your system.
Installing via Smithery
To install Knowledge Base Server for Claude Desktop automatically via Smithery:
Manual Installation
Prerequisites
Clone the repository:
git clone <repository_url> cd knowledge-base-mcp-serverInstall dependencies:
npm installConfigure environment variables:
The server requires the
HUGGINGFACE_API_KEYenvironment variable to be set. This is the API key for the Hugging Face Inference API, which is used to generate embeddings for the knowledge base content. You can obtain a free API key from the Hugging Face website (https://huggingface.co/).The server requires the
KNOWLEDGE_BASES_ROOT_DIRenvironment variable to be set. This variable specifies the directory where the knowledge base subdirectories are located. If you don't set this variable, it will default to$HOME/knowledge_bases, where$HOMEis the current user's home directory.The server supports the
FAISS_INDEX_PATHenvironment variable to specify the path to the FAISS index. If not set, it will default to$HOME/knowledge_bases/.faiss.The server supports the
HUGGINGFACE_MODEL_NAMEenvironment variable to specify the Hugging Face model to use for generating embeddings. If not set, it will default tosentence-transformers/all-MiniLM-L6-v2.You can set these environment variables in your
.bashrcor.zshrcfile, or directly in the MCP settings.
Build the server:
npm run buildAdd the server to the MCP settings:
Edit the
cline_mcp_settings.jsonfile located at/home/jean/.vscode-server/data/User/globalStorage/saoudrizwan.claude-dev/settings/.Add the following configuration to the
mcpServersobject:
"knowledge-base-mcp": { "command": "node", "args": [ "/path/to/knowledge-base-mcp-server/build/index.js" ], "disabled": false, "autoApprove": [], "env": { "KNOWLEDGE_BASES_ROOT_DIR": "/path/to/knowledge_bases", "HUGGINGFACE_API_KEY": "YOUR_HUGGINGFACE_API_KEY", }, "description": "Retrieves similar chunks from the knowledge base based on a query." },Replace
/path/to/knowledge-base-mcp-serverwith the actual path to the server directory.Replace
/path/to/knowledge_baseswith the actual path to the knowledge bases directory.
Create knowledge base directories:
Create subdirectories within the
KNOWLEDGE_BASES_ROOT_DIRfor each knowledge base (e.g.,company,it_support,onboarding).Place text files (e.g.,
.txt,.md) containing the knowledge base content within these subdirectories.
The server recursively reads all text files (e.g.,
.txt,.md) within the specified knowledge base subdirectories.The server skips hidden files and directories (those starting with a
.).For each file, the server calculates the SHA256 hash and stores it in a file with the same name in a hidden
.indexsubdirectory. This hash is used to determine if the file has been modified since the last indexing.The file content is splitted into chunks using the
MarkdownTextSplitterfromlangchain/text_splitter.The content of each chunk is then added to a FAISS index, which is used for similarity search.
The FAISS index is automatically initialized when the server starts. It checks for changes in the knowledge base files and updates the index accordingly.
Usage
The server exposes two tools:
list_knowledge_bases: Lists the available knowledge bases.retrieve_knowledge: Retrieves similar chunks from the knowledge base based on a query. Optionally, if a knowledge base is specified, only that one is searched; otherwise, all available knowledge bases are considered. By default, at most 10 document chunks are returned with a score below a threshold of 2. A different threshold can optionally be provided using thethresholdparameter.
You can use these tools through the MCP interface.
The retrieve_knowledge tool performs a semantic search using a FAISS index. The index is automatically updated when the server starts or when a file in a knowledge base is modified.
The output of the retrieve_knowledge tool is a markdown formatted string with the following structure:
Each result includes the content of the most similar chunk, the source file, and a similarity score.
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Provides tools for listing and retrieving content from different knowledge bases using semantic search capabilities.
Related Resources
Related MCP Servers
- -securityAlicense-qualityProvides tools for retrieving and processing documentation through vector search, enabling AI assistants to augment their responses with relevant documentation context.Last updated -22MIT License
- -securityFlicense-qualityIntelligent knowledge base management tool that enables searching, browsing, and analyzing documents across multiple datasets with smart document analysis capabilities.Last updated -16
- AsecurityAlicenseAqualityEnables AI assistants to search and retrieve content from WikiJS knowledge bases, allowing integration with your Wiki through simple search and retrieval tools.Last updated -4141MIT License
- -securityAlicense-qualityEnables LLMs to manage file-based knowledge bases with dual storage (Markdown + SQLite). Supports creating, searching, and organizing articles across multiple knowledge bases with full-text search capabilities.Last updated -42MIT License