MCP Knowledge Base Server
MCP ナレッジベースサーバー
AIアシスタント(Claude Desktop、Cursor、または任意のMCPクライアント)に、社内の ナレッジベース のMarkdownドキュメントへの検索可能で構造化されたアクセスを提供する MCP(Model Context Protocol) サーバーです。
アシスタントに 「本番环境にデプロイするにはどうすればいい?」 や 「有給休暇は何日ある?」 と尋ねると、ナレッジベースを検索し、関連記事を読み、引用付きで回答します。社内プロセスを幻覚(ハルシネーション)することはありません。
特徴
6つのツール — スニペット付きキーワード検索、ドキュメント全体の取得、フィルタ付き一覧表示、タグブラウジング、ホットリロード、統計
2種類のリソース — インデックス全体または任意のドキュメントを直接参照(
kb://index、kb://documents/{doc_id})1つのプロンプトテンプレート —
answer_from_knowledge_baseは検索結果に基づいて回答を根拠付け、引用を強制しますインフラ不要 — ナレッジベースはオプションのfrontmatter付きの
.mdファイルのフォルダだけで、Gitリポジトリとの併用に最適です2つのトランスポート — ローカルクライアント用のstdio、共有/リモート環境用のHTTP
依存関係が軽量 — FastMCP + 組み込みの小型TF-IDF型インデックス。データベースやembeddingsサービスは不要です
Related MCP server: search-docs
アーキテクチャ
┌─────────────────┐ stdio / HTTP (JSON-RPC) ┌──────────────────────────┐
│ MCP client │ ───────────────────────────▶ │ FastMCP server │
│ (Claude, …) │ ◀─────────────────────────── │ ├─ tools (search, get…) │
└─────────────────┘ │ ├─ resources (kb://…) │
│ └─ prompts (answer…) │
│ │ │
│ KnowledgeBaseIndex │
│ (tokenize → TF-IDF) │
└──────────┬─────────────┘
│ scans
┌──────────▼─────────────┐
│ knowledge_base/ │
│ engineering/*.md │
│ hr/*.md product/*.md │
└────────────────────────┘クイックスタート
git clone <your-repo-url> mcp-knowledge-base-server
cd mcp-knowledge-base-server
pip install .サーバーを自分のドキュメントに向ける(または同梱のサンプルコーパスを使用する):
export KB_DIR=/path/to/your/markdown/docsデモを実行する
pip install fastmcp # only dependency the demo needs
python examples/demo_client.pyデモはstdio経由でサーバーを起動し、すべての機能(検索、ドキュメント取得、一覧表示、リソース、根拠付き回答プロンプト)を実行し、実際のクライアントが目にする正確なJSON-RPCペイロードを表示します。
Claude Desktopに接続する
claude_desktop_config.json に追加:
{
"mcpServers": {
"knowledge-base": {
"command": "python",
"args": ["-m", "mcp_knowledge_base.server"],
"env": {
"PYTHONPATH": "/absolute/path/to/mcp-knowledge-base-server/src",
"KB_DIR": "/absolute/path/to/mcp-knowledge-base-server/knowledge_base"
}
}
}
}Claude Desktopを再起動して、次のように尋ねます: 「ナレッジベースを検索して — デプロイが失敗した場合のロールバック手順は?」
HTTPで実行する(共有/リモート環境)
KB_DIR=/path/to/docs mcp-knowledge-base --transport http --port 8000
# → streamable HTTP endpoint at http://127.0.0.1:8000/mcpドキュメント形式
任意の .md ファイルのフォルダで動作します。オプションのfrontmatterで結果を拡充できます:
---
title: Deploying to Production
tags: [deploy, production, runbook]
department: engineering
updated: 2025-11-02
---
# Deploying to Production
…ドキュメントの doc_id は、KB_DIR からの相対パスから拡張子を除いたものです(例: engineering/deploy-guide)。タイトルは最初の # 見出し、次にファイル名にフォールバックします。
APIリファレンス
ツール
ツール | 説明 |
| ランク付きキーワード検索。doc_id、タイトル、タグ、スニペット、スコアを返します |
| 1記事の完全なMarkdownコンテンツ + メタデータ |
| すべての記事を一覧表示。オプションでフィルタ可能 |
| ドキュメント数付きの全タグ |
|
|
| ドキュメント数、タグ数、インデックス経過時間 |
リソース
URI | 説明 |
| 全ドキュメントの人間可読なインデックス |
| 1つのドキュメントの完全なコンテンツ |
プロンプト
プロンプト | 説明 |
| KBを検索し、モデルに抜粋のみから回答しdoc_idを引用するよう指示します |
環境変数
変数 | デフォルト | 説明 |
|
| Markdownドキュメントのルートフォルダ |
|
| MCPクライアントに表示されるサーバー名 |
プロジェクト構造
├── knowledge_base/ # sample corpus (replace with your own)
│ ├── engineering/*.md
│ ├── hr/*.md
│ └── product/*.md
├── src/mcp_knowledge_base/
│ ├── server.py # FastMCP server: tools, resources, prompts
│ └── index.py # document loading + TF-IDF-style search
├── examples/
│ └── demo_client.py # end-to-end demo over stdio
└── pyproject.toml拡張方法
検索の改善:
KnowledgeBaseIndexをembeddings + ベクターデータベースに置き換える(ツールのインターフェースはそのままです)。他のソース: Confluence/Notionのエクスポートをインデックス化 — Markdownになるものであればそのまま動作します。
鮮度:
reload_knowledge_baseをスケジュール実行するか、ファイルシステムウォッチャーでKB_DIRを監視します。
ライセンス
MIT — LICENSE を参照してください。
Available Tools
6 toolsget_documentA
Fetch the full Markdown content of one knowledge-base article.
Inputs: doc_id (required). Returns: object
list_documentsA
List every article in the knowledge base, optionally filtered.
Inputs: tag, department. Returns: result
list_tagsA
List all tags used across the knowledge base, with document counts.
Inputs: no named parameters. Returns: object
reload_knowledge_baseA
Re-scan the knowledge-base directory to pick up new or edited articles.
Returns: Number of documents now indexed.
Inputs: no named parameters. Returns: object
search_knowledge_baseA
Search the company knowledge base with natural language or keywords.
Use this FIRST whenever a question might be answered by internal documentation (processes, runbooks, policies, architecture, onboarding…).
Inputs: query (required), tag, limit. Returns: result
statsB
Basic knowledge-base statistics (document count, tags, index age).
Inputs: no named parameters. Returns: object
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 has a clearly distinct purpose: searching, fetching full documents, listing documents, listing tags, reloading the index, and showing stats. There is no overlap that would cause an agent to select the wrong tool.
All tool names follow a consistent verb_noun pattern (search_, get_, list_, reload_, etc.). The pattern is predictable and easy to infer for additional tools.
Six tools is well within the ideal range for a knowledge base server. Each tool serves a distinct function, and the count feels neither too sparse nor bloated.
The tool set covers all core operations: search, read, list, and maintenance. Minor gaps exist (e.g., no tool to add or delete documents via the API, but that may be intentionally managed filesystem-side). Reload and stats provide necessary lifecycle support.
Related MCP Connectors
Search and reason over your Obsidian-style Markdown vault, right from ChatGPT.
Convert PDFs, Office docs, websites and audio into AI-ready Markdown, then search and ask your docs.
Shared markdown docs for people and AI agents, kept as plain files in your team's GitHub repo.
- Very Simple NotesDeprecatedcom.verysimplenotes
Markdown notes in folders, with files, that your AI assistant can read, write and organise.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI models to seamlessly access and query local markdown technical documentation files, providing automatic documentation context without explicit prompting.5ISC
- AlicenseAqualityBmaintenanceEnables AI agents to search local Markdown documents using natural language, with automatic indexing and section-level retrieval.101MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with direct access to local Markdown documentation libraries, enabling them to list, read, and search through docs on demand.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to search, read, and navigate a folder of Markdown notes as a knowledge base, with full-text search, backlinks, tags, metadata, and note resources for conversation attachment.1MIT