Skip to main content
Glama

Knowledge Base MCP Server

by jeanibarz
The Unlicense
10
  • Linux
  • Apple

知识库 MCP 服务器

该 MCP 服务器提供列出和检索来自不同知识库的内容的工具。

设置说明

这些说明假设您的系统上安装了 Node.js 和 npm。

通过 Smithery 安装

要通过Smithery自动安装 Claude Desktop 的知识库服务器:

npx -y @smithery/cli install @jeanibarz/knowledge-base-mcp-server --client claude

手动安装

先决条件

  • Node.js (版本 16 或更高版本)
  • npm (Node 包管理器)
  1. 克隆存储库:
    git clone <repository_url> cd knowledge-base-mcp-server
  2. 安装依赖项:
    npm install
  3. 配置环境变量:
    • 服务器需要设置HUGGINGFACE_API_KEY环境变量。这是 Hugging Face Inference API 的 API 密钥,用于生成知识库内容的嵌入。您可以从 Hugging Face 网站 ( https://huggingface.co/ ) 获取免费的 API 密钥。
    • 服务器需要设置KNOWLEDGE_BASES_ROOT_DIR环境变量。此变量指定知识库子目录所在的目录。如果不设置此变量,则默认为$HOME/knowledge_bases ,其中$HOME是当前用户的主目录。
    • 服务器支持使用FAISS_INDEX_PATH环境变量来指定 FAISS 索引的路径。如果未设置,则默认为$HOME/knowledge_bases/.faiss
    • 服务器支持HUGGINGFACE_MODEL_NAME环境变量,用于指定用于生成嵌入的 Hugging Face 模型。如果未设置,则默认为sentence-transformers/all-MiniLM-L6-v2
    • 您可以在.bashrc.zshrc文件中设置这些环境变量,也可以直接在 MCP 设置中设置。
  4. 构建服务器:
    npm run build
  5. 将服务器添加到 MCP 设置:
    • 编辑位于/home/jean/.vscode-server/data/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json文件。
    • mcpServers对象添加以下配置:
    "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." },
    • /path/to/knowledge-base-mcp-server替换为服务器目录的实际路径。
    • /path/to/knowledge_bases替换为知识库目录的实际路径。
  6. 创建知识库目录:
    • KNOWLEDGE_BASES_ROOT_DIR中为每个知识库创建子目录(例如companyit_supportonboarding )。
    • 将包含知识库内容的文本文件(例如.txt.md )放在这些子目录中。
  • 服务器递归读取指定知识库子目录内的所有文本文件(例如.txt.md )。
  • 服务器跳过隐藏文件和目录(以.开头的文件和目录)。
  • 对于每个文件,服务器都会计算 SHA256 哈希值,并将其存储在隐藏的.index子目录中的同名文件中。此哈希值用于确定文件自上次索引以来是否被修改过。
  • 使用langchain/text_splitter中的MarkdownTextSplitter将文件内容分割成块。
  • 然后将每个块的内容添加到 FAISS 索引中,用于相似性搜索。
  • FAISS 索引在服务器启动时自动初始化。它会检查知识库文件中的变化并相应地更新索引。

用法

该服务器公开了两个工具:

  • list_knowledge_bases :列出可用的知识库。
  • retrieve_knowledge知识库 (retrieve_knowledge):根据查询从知识库中检索相似的块。(可选)如果指定了知识库,则仅搜索该知识库;否则,将考虑所有可用的知识库。默认情况下,最多返回 10 个得分低于阈值 2 的文档块。可以使用threshold参数设置其他阈值。

您可以通过 MCP 界面使用这些工具。

retrieve_knowledge工具使用 FAISS 索引执行语义搜索。当服务器启动或知识库中的文件被修改时,索引会自动更新。

retrieve_knowledge工具的输出是 markdown 格式的字符串,具有以下结构:

## Semantic Search Results **Result 1:** [Content of the most similar chunk] **Source:** ```json { "source": "[Path to the file containing the chunk]" } ``` --- **Result 2:** [Content of the second most similar chunk] **Source:** ```json { "source": "[Path to the file containing the chunk]" } ``` > **Disclaimer:** The provided results might not all be relevant. Please cross-check the relevance of the information.

每个结果包括最相似的块的内容、源文件和相似度分数。

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

提供使用语义搜索功能列出和检索来自不同知识库的内容的工具。

  1. 设置说明
    1. 通过 Smithery 安装
    2. 手动安装
  2. 用法

    Related MCP Servers

    • -
      security
      A
      license
      -
      quality
      Enables performing local web searches and extracting structured content from web pages using the Model Context Protocol, featuring customizable result limits and domain filtering.
      Last updated -
      5
      JavaScript
      MIT License
    • -
      security
      A
      license
      -
      quality
      Provides RAG capabilities for semantic document search using Qdrant vector database and Ollama/OpenAI embeddings, allowing users to add, search, list, and delete documentation with metadata support.
      Last updated -
      5
      4
      TypeScript
      Apache 2.0
    • -
      security
      A
      license
      -
      quality
      Allows AI models to interact with SourceSync.ai's knowledge management platform to organize, ingest, retrieve, and search content in knowledge bases.
      Last updated -
      14
      1
      TypeScript
      MIT License
      • Apple
      • Linux
    • -
      security
      A
      license
      -
      quality
      Enables semantic search across multiple Qdrant vector database collections, supporting multi-query capability and providing semantically relevant document retrieval with configurable result counts.
      Last updated -
      46
      TypeScript
      MIT License

    View all related MCP servers

    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/jeanibarz/knowledge-base-mcp-server'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server