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

chathub-mcp-server

v1.0.2

Published

AI对话即时处理和剪藏工具 - MCP服务器

Readme

ChatHub MCP Server

告别复制粘贴,一键剪藏让AI对话秒转知识资产

AI对话即时处理和剪藏工具的MCP服务器实现,支持将AI对话内容快速转换为结构化格式并保存到Notion等知识管理工具。

🚀 功能特性

核心功能

  • 对话内容解析: 智能解析AI对话,提取参与者、主题、时间戳等结构化信息
  • 多格式转换: 支持Markdown、HTML、Q&A、教程等多种输出格式
  • 一键剪藏: 快速保存到Notion数据库,支持自动创建数据库
  • MCP集成: 完整的Model Context Protocol支持,可集成到Claude Desktop、Cursor、Windsurf等工具

支持的集成

  • Notion: 通过API直接创建页面到指定数据库,支持标签、分类、搜索等功能
  • 更多集成: 计划支持Obsidian、Logseq、RemNote等

📦 快速开始

步骤1: 配置Notion集成

1.1 创建Notion集成应用

  1. 访问 Notion Integrations
  2. 点击 "New integration" 创建新集成
  3. 填写集成信息:
    • Name: 输入应用名称,如 "ChatHub AI对话剪藏"
    • Associated workspace: 选择你的工作区
  4. 点击 "Submit" 完成创建
  5. 复制生成的 "Internal Integration Token"(格式:secret_xxxxxxxxx...

1.2 创建并配置Notion数据库

  1. 创建数据库页面

    • 在Notion中创建新页面,标题如 "AI对话剪藏库"
    • 在页面中输入 /table/database 创建数据库
  2. 设置数据库属性

    • Title: 保持默认标题属性(必需)
    • Tags: 添加"多选"属性,用于内容分类
      • 点击 "+" → 选择 "Multi-select" → 命名为 "Tags"
  3. 获取数据库ID

    • 点击数据库右上角 "..." → "Copy link"

    • 从URL中提取数据库ID:

      https://www.notion.so/your-workspace/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                         这部分就是数据库ID

1.3 连接集成到数据库

  1. 在数据库页面,点击右上角 "..." → "Add connections"
  2. 找到并选择刚创建的集成应用
  3. 点击 "Confirm" 授权集成访问数据库

💡 提示: 如果不提供 NOTION_DATABASE_ID,系统会自动创建专用数据库

步骤2: 配置MCP客户端

根据您使用的AI客户端进行配置:

Claude Desktop配置

配置文件位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "chathub-mcp-server": {
      "command": "npx",
      "args": ["chathub-mcp-server@latest"],
      "env": {
        "NOTION_TOKEN": "your_notion_token_here",
        "NOTION_DATABASE_ID": "your_database_id_here"
      }
    }
  }
}

Cursor配置

配置文件位置: ~/.cursor/mcp.json

{
  "mcpServers": {
    "chathub-mcp-server": {
      "command": "npx",
      "args": ["chathub-mcp-server@latest"],
      "env": {
        "NOTION_TOKEN": "your_notion_token_here",
        "NOTION_DATABASE_ID": "your_database_id_here"
      }
    }
  }
}

注意: NOTION_DATABASE_ID 是可选的。如果不提供,系统会自动创建一个新的数据库。

步骤3: 重启AI客户端

配置完成后,重启Claude Desktop或Cursor,即可开始使用工具。

🔧 使用工具

配置完成后,您可以在AI对话中直接使用以下功能:

直接对话使用(推荐)

直接在AI对话中说出您的需求,AI会自动调用相应的工具:

📝 保存和管理内容:

  • "帮我把这段对话保存到Notion"
  • "保存这次讨论,标题叫'AI项目实战'"
  • "在之前的'React教程'文章后面添加这段代码"
  • "初始化一个新的Notion数据库"

🔍 查找和阅读:

  • "搜索我之前保存的关于React的文章"
  • "显示我最近收藏的5篇文章"
  • "读取'TypeScript进阶'这篇文章的完整内容"
  • "找找本周保存的所有内容"

🔄 格式转换:

  • "将这个对话转换为Markdown格式"
  • "把这段内容转成HTML格式分享"
  • "解析这段对话的结构和参与者"

可用工具详情

📝 内容保存工具

  • saveToNotion - 保存内容到Notion

    • 自动创建数据库(如果不存在)
    • 支持标签分类和搜索
    • 包含时间戳和元数据
  • appendToNotion - 追加内容到现有页面

    • 通过页面ID精确追加
    • 可选择添加时间戳
    • 适合续写长对话
  • smartAppendToNotion - 智能追加内容

    • 通过页面标题模糊匹配
    • 支持智能缓存和快速访问
    • 无需记住页面ID

🔍 内容查询工具

  • queryNotionPages - 查询已保存的内容

    • 按时间排序显示
    • 支持内容预览和元数据
    • 智能缓存页面信息
  • searchNotionContent - 智能搜索

    • 关键词搜索
    • 时间范围过滤(今天/本周/本月/全部)
    • 标签分类筛选
  • readNotionPage - 读取完整页面内容

    • 通过页面ID精确读取
    • 返回完整格式化内容
    • 包含页面属性和时间信息
  • readNotionPageByTitle - 通过标题读取页面

    • 模糊标题匹配
    • 自动继续之前对话的上下文
    • 支持多数据库查询

🔄 格式转换工具

  • convertToMarkdown - 转换为Markdown格式

    • 支持Q&A、教程等格式
    • 自动提取对话结构
    • 生成结构化文档
  • convertToHtml - 转换为HTML格式

    • 美观的网页格式输出
    • 包含样式和排版
    • 适合分享和展示
  • parseConversation - 对话解析

    • 提取参与者和主题
    • 统计消息数量
    • 识别对话模式

⚙️ 数据库管理工具

  • initNotionDatabase - 初始化数据库
    • 自动创建ChatHub专用数据库
    • 预设标签和属性字段
    • 支持强制重新创建

使用示例

配置完成后,您可以在AI对话中这样使用:

💾 保存对话:

用户: "帮我把这次关于React Hooks的讨论保存到Notion,标题叫'React Hooks最佳实践'"
AI: ✅ 已成功保存到Notion!页面标题:React Hooks最佳实践

🔍 搜索历史内容:

用户: "搜索我之前保存的关于TypeScript的文章"
AI: 🎯 找到3篇相关文章:
- TypeScript高级类型使用技巧
- TypeScript与React最佳实践
- TypeScript项目配置指南

📋 查看收藏列表:

用户: "显示我最近收藏的5篇文章"
AI: 您最近收藏的文章:
1. React Hooks最佳实践 (2小时前)
2. Vue3 Composition API详解 (1天前)
3. Next.js 14新特性解析 (3天前)
...

📖 继续之前的对话:

用户: "读取我之前保存的'React Hooks最佳实践'这篇文章"
AI: 这是您在 2024-01-15 剪藏的内容"React Hooks最佳实践"。
现在我们可以基于这个内容继续之前的对话...

➕ 续写内容:

用户: "在'React Hooks最佳实践'这篇文章后面添加今天讨论的useCallback优化技巧"
AI: ✅ 内容已成功追加到Notion页面!新增了3个代码块。

🔄 格式转换:

用户: "把这段对话转换成Q&A格式的Markdown"
AI: 已转换为Markdown格式,包含5个问答对,结构清晰易读。

🛠️ 开发者指南 (未来可能开源)

本地开发设置

  1. 克隆项目

    git clone https://github.com/Crushdada/chathub-mcp-server.git
    cd chathub-mcp-server
  2. 安装依赖

    npm install
  3. 配置环境变量

    cp env.example .env
    # 编辑 .env 文件,添加您的 NOTION_TOKEN
  4. 开发模式启动

    npm run start:dev

构建和发布

  1. 构建项目

    npm run build
  2. 本地测试

    npm run start:prod
  3. 发布新版本

    npm version patch  # 或 minor/major
    npm publish

🏗️ 项目结构

src/
├── mcp/                    # MCP服务器相关
│   ├── server.ts          # MCP服务器主文件
│   ├── tools/             # MCP工具实现
│   │   └── mcp-tools.service.ts
│   └── types.ts           # 类型定义
├── parsers/               # 内容解析器
│   ├── conversation.ts    # 对话解析器
│   └── parsers.module.ts
├── integrations/          # 第三方集成
│   ├── notion.ts          # Notion集成
│   └── integrations.module.ts
├── config/                # 配置管理
│   └── secure-config.ts   # 安全配置管理
├── utils/                 # 工具函数
│   ├── page-cache.ts      # 页面缓存
│   └── utils.module.ts
├── app.module.ts          # 应用根模块
└── main.ts               # 应用入口

🧪 测试

运行单元测试:

npm run test

运行测试覆盖率:

npm run test:cov

运行端到端测试:

npm run test:e2e

📝 开发规范

  • 使用TypeScript严格模式
  • 遵循ESLint和Prettier配置
  • 函数命名使用驼峰命名法
  • 接口和类型定义使用PascalCase
  • 常量使用UPPER_SNAKE_CASE

🤝 贡献指南

  1. Fork 项目
  2. 创建功能分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开 Pull Request

📄 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。

🔗 相关链接

🙏 致谢

感谢以下项目和技术的支持: