MCP Knowledge Base Server

MCP Knowledge Base Server

A local knowledge base server that connects to AI assistants, turning markdown files into a semantically searchable memory layer via OpenAI embeddings and SQLite.

Category
访问服务器

README

MCP Knowledge Base Server

Give your AI assistant a long-term memory. Drop markdown files into a folder — Claude instantly knows your notes, docs, and code snippets.

npm version license node

What is this?

MCP Knowledge Base Server is a personal knowledge base that connects directly to AI assistants like Claude Desktop and Cursor. It turns a local folder of markdown files into a queryable, semantically searchable memory layer — without any cloud infrastructure or external databases.

It works over the Model Context Protocol (MCP), a standard that lets AI assistants call tools and retrieve data from local servers. When you ask Claude "what do my notes say about deployment?", it uses this server to run a semantic similarity search over your embedded documents and return the most relevant chunks — all locally, in milliseconds.

Under the hood, it uses OpenAI's text-embedding-3-small model to generate vector embeddings for your markdown content, stores them in a local SQLite database, and performs cosine similarity search to find the most relevant material. The server auto-indexes on startup (only re-embedding changed files), so your knowledge base stays fresh with zero manual work.

Features

  • 🔍 Semantic search across your knowledge base using OpenAI embeddings
  • 📄 Full document retrieval by title or file path
  • 🏷️ Topic browser — list all tags and categories with document counts
  • ✍️ AI-driven note creation — let Claude write notes back to your KB
  • ⚡ Incremental indexing — only re-embeds changed files on startup
  • 🗄️ Zero-dependency storage — SQLite, no external DB required
  • 🔧 Simple CLI — mcp-kb index, mcp-kb stats, mcp-kb serve

Prerequisites

  • Node.js >= 18
  • An OpenAI API key (for embeddings — uses text-embedding-3-small, ~$0.02/1M tokens)

Quick Start

1. Clone and install

git clone https://github.com/YOUR_USERNAME/mcp-knowledge-base.git
cd mcp-knowledge-base
npm install

2. Set your OpenAI API key

cp .env.example .env
# Edit .env and add your key:
# OPENAI_API_KEY=sk-...

3. Add your markdown files

Drop .md files into the knowledge/ directory. They can have YAML frontmatter:

---
title: "My Note"
tags: [typescript, backend]
category: "guides"
---

# Content here

4. Index your knowledge base

npm run build
npx mcp-kb index

5. Configure Claude Desktop

Add to your claude_desktop_config.json (location below):

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "knowledge-base": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-knowledge-base/dist/server.cjs"],
      "env": {
        "OPENAI_API_KEY": "sk-your-key-here"
      }
    }
  }
}

Then restart Claude Desktop.

CLI Reference

Command Description
npx mcp-kb index Index all markdown files in the knowledge directory
npx mcp-kb index --force Force re-index all files (ignores change detection)
npx mcp-kb index --dry-run Preview what would be indexed without API calls
npx mcp-kb stats Show KB statistics (docs, chunks, tags, DB size)
npx mcp-kb serve Start the MCP server manually

MCP Tools

Once connected, Claude has access to these tools:

Tool Description
search_knowledge Semantic search — ask in natural language
get_document Retrieve a full document by title or path
list_topics Browse all tags and categories
add_note Let Claude write a new note to your KB

Example Prompts

Once configured in Claude Desktop, try:

  • "What do my notes say about authentication middleware?"
  • "Show me everything tagged 'typescript'"
  • "What topics are covered in my knowledge base?"
  • "Write a summary of today's meeting and save it as a note"
  • "Get the full content of my deployment guide"

Configuration

Edit config.json to customize behavior:

{
  "knowledgeDir": "./knowledge",
  "embeddingModel": "text-embedding-3-small",
  "chunkSize": 500,
  "chunkOverlap": 50,
  "topN": 5,
  "openaiApiKey": "$OPENAI_API_KEY"
}
Field Default Description
knowledgeDir ./knowledge Directory to scan for .md files
embeddingModel text-embedding-3-small OpenAI model for embeddings
chunkSize 500 Max tokens per chunk
chunkOverlap 50 Overlap tokens between chunks
topN 5 Default number of search results

Architecture

The server follows a clean three-layer architecture: Ingestion scans markdown files, parses YAML frontmatter, splits content into overlapping chunks, and generates OpenAI embeddings — only for files that have changed since the last run (via SHA-256 hashing). Storage persists documents, chunks, and embeddings in a local SQLite database using WAL mode for write performance and an in-memory cache for fast similarity lookups. MCP Server exposes four tools to the AI assistant via stdio transport, handling all search, retrieval, and write operations.

Tech Stack

  • Runtime: Node.js + TypeScript
  • MCP SDK: @modelcontextprotocol/sdk
  • Embeddings: OpenAI text-embedding-3-small
  • Storage: better-sqlite3 (WAL mode)
  • Markdown: gray-matter + markdown-it
  • CLI: commander
  • Build: tsup
  • Tests: vitest

Development

npm run build     # compile TypeScript
npm test          # run tests
npm run dev       # watch mode build

Limitations & Roadmap

Current limitations (v1):

  • Markdown files only (.md)
  • In-process similarity search — works well up to ~10k chunks
  • Single knowledge base (no namespacing)

Planned for future versions:

  • pgvector support for large knowledge bases
  • Multi-format ingestion (PDF, HTML, plain text)
  • Namespace support (work/personal/project-x)
  • Local embedding models (offline operation)
  • Obsidian vault compatibility with [[wikilinks]]

License

MIT — see LICENSE

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选