npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

knowledge-base-mcp-server

v1.0.0

Published

知识库 MCP 服务器,通过 Cloudflare Worker 连接 Supabase。为 Claude 提供强大的知识库管理功能。

Downloads

9

Readme

知识库 MCP 服务器

一个通过 Cloudflare Worker 连接 Supabase 的知识库管理系统,为 Claude 提供强大的知识库功能。

功能特性

  • 📚 知识库文档管理(增删改查)
  • 🔍 全文搜索和语义检索
  • 🏷️ 分类和标签管理
  • 📊 统计信息和分析
  • 🌐 通过 Cloudflare Worker 提供 API
  • 🗄️ 使用 Supabase 作为数据存储
  • 🔌 完整的 MCP 协议支持

架构组成

Claude ↔ MCP 服务器 ↔ Cloudflare Worker ↔ Supabase
  1. MCP 服务器 (mcp-server.js) - 为 Claude 提供工具接口
  2. Cloudflare Worker (knowledge-base-worker.js) - 提供 RESTful API
  3. Supabase 数据库 - 存储知识库数据

安装

从 npm 安装

npm install -g @zhongce-xie/knowledge-base-mcp

从源码安装

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

快速开始

1. 设置 Supabase

  1. Supabase 创建新项目
  2. 在 SQL 编辑器中执行 supabase-schema.sql 创建表结构
  3. 获取项目 URL 和 API 密钥

2. 部署 Cloudflare Worker

  1. Cloudflare 创建新的 Worker
  2. knowledge-base-worker.js 的内容复制到 Worker 编辑器
  3. 设置环境变量:
    • SUPABASE_URL: 你的 Supabase 项目 URL
    • SUPABASE_KEY: 你的 Supabase API 密钥
    • API_SECRET_KEY: (可选) API 访问密钥
  4. 部署 Worker 并记录 URL

3. 配置 MCP 服务器

  1. 安装依赖:

    npm install
  2. 设置环境变量:

    export KNOWLEDGE_WORKER_URL="https://your-worker.your-subdomain.workers.dev"
    export KNOWLEDGE_API_KEY="your-api-secret-key"  # 如果设置了的话

4. 配置 Claude Code

在 Claude Code 配置中添加 MCP 服务器:

{
  "mcpServers": {
    "knowledge-base": {
      "command": "node",
      "args": ["/path/to/knowledge-base-mcp/mcp-server.js"],
      "env": {
        "KNOWLEDGE_WORKER_URL": "https://your-worker.your-subdomain.workers.dev",
        "KNOWLEDGE_API_KEY": "your-api-secret-key"
      }
    }
  }
}

API 接口

Worker API 端点

  • GET /api/knowledge - 获取文档列表
  • GET /api/knowledge/{id} - 获取指定文档
  • POST /api/knowledge - 创建新文档
  • PUT /api/knowledge/{id} - 更新文档
  • DELETE /api/knowledge/{id} - 删除文档
  • POST /api/knowledge/search - 搜索文档
  • GET /api/knowledge/stats - 获取统计信息

MCP 工具

  • search_knowledge - 搜索知识库文档
  • get_document - 获取文档详情
  • add_document - 添加新文档
  • update_document - 更新文档
  • delete_document - 删除文档
  • list_documents - 列出文档
  • get_knowledge_stats - 获取统计信息

使用示例

配置完成后,你可以在 Claude Code 中使用以下功能:

搜索关于 MCP 的文档
添加一篇关于 Python 的教程
获取知识库统计信息
更新文档标题和内容

数据结构

知识库文档

{
  "id": "uuid",
  "title": "文档标题",
  "content": "文档内容",
  "summary": "自动生成的摘要",
  "category": "分类",
  "tags": ["标签1", "标签2"],
  "keywords": ["关键词1", "关键词2"],
  "author": "作者",
  "status": "active|draft|archived",
  "created_at": "创建时间",
  "updated_at": "更新时间"
}

开发和调试

启动开发服务器

npm run dev

测试 Worker API

# 健康检查
curl https://your-worker.your-subdomain.workers.dev/health

# 获取文档列表
curl https://your-worker.your-subdomain.workers.dev/api/knowledge

# 搜索文档
curl -X POST https://your-worker.your-subdomain.workers.dev/api/knowledge/search \
  -H "Content-Type: application/json" \
  -d '{"query": "MCP"}'

安全考虑

  1. 在生产环境中启用 Supabase 行级安全性 (RLS)
  2. 设置强 API 密钥保护 Worker 接口
  3. 考虑添加请求频率限制
  4. 定期备份 Supabase 数据

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!