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 🙏

© 2026 – Pkg Stats / Ryan Hefner

knowledge-base-mcp

v1.0.3

Published

知识库MCP服务,基于Dify MCP协议的两步式知识库检索系统

Downloads

17

Readme

知识库MCP服务

基于MCP(Model Context Protocol)协议的知识库检索系统,提供与Dify知识库集成的能力。

项目介绍

知识库MCP服务是一个轻量级服务,可以通过MCP协议将您的Dify知识库连接到支持MCP的AI助手(如Claude AI)。该服务支持多种传输方式,包括STDIO、HTTP和SSE,适用于不同的应用场景。

主要特点

  • 支持MCP协议,与Claude等AI助手无缝集成
  • 支持解析知识库ID和获取知识库文档的工具
  • 支持多种传输方式:STDIO、HTTP和SSE
  • 缓存机制提高查询效率
  • 支持多知识库同时查询
  • 简单易用的API接口

技术架构

Architecture Diagram

系统由以下主要组件构成:

  1. MCP服务器:处理与AI助手的通信
  2. Dify服务:与Dify API交互,检索知识库内容
  3. 工具服务:提供MCP工具实现,包括解析知识库ID和获取知识库文档

安装与设置

环境要求

  • Node.js 18+
  • TypeScript
  • 有效的Dify API密钥

安装步骤

  1. 克隆仓库
git clone https://github.com/yourusername/knowledge-base-mcp.git
cd knowledge-base-mcp
  1. 安装依赖
pnpm install
# 或者使用pnpm
pnpm install
  1. 配置环境变量

.env.example复制为.env,并填写必要的配置信息:

cp .env.example .env

编辑.env文件,设置Dify API密钥和其他配置。

  1. 配置Docker
cp Dockerfile.example Dockerfile

编辑Dockerfile文件,设置Dify API密钥和其他配置。

配置说明

.env文件中可以配置以下参数:

| 变量名 | 描述 | 默认值 | |--------|------|--------| | DIFY_BASE_URL | Dify API基础URL | https://api.dify.ai/v1 | | DIFY_API_KEY | Dify API密钥 | - | | TRANSPORT_TYPE | 传输类型(stdio/http/sse) | stdio | | PORT | HTTP/SSE服务端口 | 3000 | | CACHE_TTL | 缓存生存时间(毫秒) | 3600000(1小时) | | CACHE_CLEANUP | 缓存清理间隔(毫秒) | 300000(5分钟) | | ALLOWED_ORIGINS | 允许的CORS来源(逗号分隔) | * |

构建与运行

构建项目

pnpm run build

运行服务

可以通过以下方式运行服务:

STDIO模式(默认)

pnpm start
# 或
pnpm run dev

HTTP模式

pnpm run dev:http
# 或
node dist/index.js --transport http --port 8008

SSE模式

pnpm run dev:sse
# 或
node dist/index.js --transport sse --port 8006

命令行参数

服务支持以下命令行参数:

  • --transport <stdio|http|sse>: 指定传输类型
  • --port <number>: 指定HTTP/SSE服务端口
  • --dify-api-key <string>: 指定Dify API密钥(覆盖环境变量设置)

许可证

MIT License