MCP Knowledge Base Server
Used for HTML parsing and manipulation when processing HTML documents in the knowledge base system.
Referenced for repository management in the project configuration.
Used as the repository hosting service for the project as specified in the configuration.
Used as the package manager for installing dependencies and running scripts.
Used as the implementation language for the MCP server, providing type safety and modern JavaScript features.
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 Server query the knowledge base for information about document processing"
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 知识库服务器
这是一个基于 Model Context Protocol (MCP) 的知识库服务器,可以处理本地文档并根据文档内容回答问题。
功能特性
支持多种文档格式:PDF、DOCX、TXT、HTML
自动文档索引和搜索
基于相似度的文档检索
完整的 MCP 协议支持
中文文档处理支持
Related MCP server: Unstructured Document Processor MCP
ModelScope MCP 服务配置
{
"name": "mcp-knowledge-base",
"version": "1.0.0",
"description": "基于本地文档的知识库问答MCP服务器",
"author": "yjy",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ikungsjl/mcp-knowledge-base.git"
},
"keywords": ["mcp", "knowledge-base", "document-processing", "qa"],
"main": "dist/index.js",
"type": "module",
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "tsx src/index.ts"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^0.4.0",
"pdf-parse": "^1.1.1",
"mammoth": "^1.6.0",
"cheerio": "^1.0.0-rc.12",
"natural": "^6.10.4",
"fs-extra": "^11.2.0",
"glob": "^10.3.10"
},
"devDependencies": {
"@types/node": "^20.10.0",
"@types/fs-extra": "^11.0.4",
"@types/natural": "^5.1.5",
"@types/pdf-parse": "^1.1.4",
"typescript": "^5.3.0",
"tsx": "^4.6.0"
},
"mcp": {
"server": {
"command": "node",
"args": ["dist/index.js"],
"env": {}
},
"tools": [
{
"name": "add_document",
"description": "添加单个文档到知识库",
"inputSchema": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "文档文件路径"
}
},
"required": ["file_path"]
}
},
{
"name": "add_directory",
"description": "添加目录中的所有文档到知识库",
"inputSchema": {
"type": "object",
"properties": {
"directory_path": {
"type": "string",
"description": "目录路径"
}
},
"required": ["directory_path"]
}
},
{
"name": "query_knowledge_base",
"description": "查询知识库",
"inputSchema": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": "查询问题"
},
"max_results": {
"type": "number",
"description": "最大返回结果数",
"default": 5
},
"threshold": {
"type": "number",
"description": "相似度阈值",
"default": 0.1
}
},
"required": ["question"]
}
},
{
"name": "list_documents",
"description": "列出知识库中的所有文档",
"inputSchema": {
"type": "object",
"properties": {}
}
},
{
"name": "get_document",
"description": "获取特定文档信息",
"inputSchema": {
"type": "object",
"properties": {
"document_id": {
"type": "string",
"description": "文档ID"
}
},
"required": ["document_id"]
}
},
{
"name": "remove_document",
"description": "从知识库中移除文档",
"inputSchema": {
"type": "object",
"properties": {
"document_id": {
"type": "string",
"description": "文档ID"
}
},
"required": ["document_id"]
}
},
{
"name": "clear_knowledge_base",
"description": "清空知识库",
"inputSchema": {
"type": "object",
"properties": {}
}
},
{
"name": "get_stats",
"description": "获取知识库统计信息",
"inputSchema": {
"type": "object",
"properties": {}
}
}
]
}
}安装
克隆项目并安装依赖:
npm install构建项目:
npm run build使用方法
1. 启动服务器
npm start2. 在 MCP 客户端中配置
在你的 MCP 客户端配置文件中添加:
{
"mcpServers": {
"knowledge-base": {
"command": "node",
"args": ["dist/index.js"],
"env": {}
}
}
}3. 可用的工具
添加文档
add_document: 添加单个文档到知识库add_directory: 添加目录中的所有文档到知识库
查询知识库
query_knowledge_base: 查询知识库并获取答案
管理文档
list_documents: 列出所有文档get_document: 获取特定文档信息remove_document: 移除文档clear_knowledge_base: 清空知识库get_stats: 获取统计信息
配置
服务器会自动创建以下目录:
documents/: 存储文档文件index/: 存储索引数据
开发
# 开发模式
npm run dev
# 测试
npm test项目结构
src/
├── types.ts # 类型定义
├── document-processor.ts # 文档处理器
├── knowledge-base.ts # 知识库核心
├── mcp-server.ts # MCP 服务器
└── index.ts # 入口文件许可证
MIT
Available Tools
8 toolsadd_directoryC
添加目录中的所有文档到知识库
Inputs: directory_path (required).
add_documentC
添加单个文档到知识库
Inputs: file_path (required).
clear_knowledge_baseD
清空知识库
Inputs: no named parameters.
get_documentC
获取特定文档信息
Inputs: document_id (required).
get_statsC
获取知识库统计信息
Inputs: no named parameters.
list_documentsB
列出知识库中的所有文档
Inputs: no named parameters.
query_knowledge_baseD
查询知识库
Inputs: question (required), max_results, threshold.
remove_documentC
从知识库中移除文档
Inputs: document_id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Every tool has a clearly distinct purpose with no ambiguity. Each tool targets a specific action on the knowledge base (add, clear, get, list, query, remove) with clear boundaries between operations like adding documents versus querying versus management functions.
All tools follow a consistent verb_noun pattern with snake_case throughout (e.g., add_document, list_documents, query_knowledge_base). The naming is predictable and readable without any deviations in style or convention.
With 8 tools, this server is well-scoped for a knowledge base management system. Each tool earns its place by covering essential CRUD operations, querying, and administrative functions without being overly sparse or bloated.
The tool set provides complete CRUD/lifecycle coverage for the knowledge base domain. It includes creation (add_document, add_directory), retrieval (get_document, list_documents, query_knowledge_base), deletion (remove_document, clear_knowledge_base), and monitoring (get_stats), with no obvious gaps or dead ends.
Maintenance
Related MCP Connectors
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
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.
Document conversion MCP server: PDF to Markdown, image OCR, spreadsheet parsing.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceA server that provides document processing capabilities using the Model Context Protocol, allowing conversion of documents to markdown, extraction of tables, and processing of document images.19MIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables LLMs to extract and use content from unstructured documents across a wide variety of file formats.111-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server for ingesting, chunking and semantically searching documentation files, with support for markdown, Python, OpenAPI, HTML files and URLs.-
- AlicenseNot gradedqualityDmaintenanceA local RAG server that enables document indexing and sentence window retrieval across multiple file formats like PDF, MD, and DOCX. It supports both local Hugging Face models and OpenAI embeddings for efficient context-aware querying through the Model Context Protocol.GPL 3.0