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

linker-feishu-mcp

v0.2.0

Published

MCP server for Linker Feishu group messages - daily digest and semantic search

Downloads

225

Readme

linker-feishu-mcp

飞书群聊消息 MCP 服务,提供长短期记忆结合的群聊查询能力,专为化工品现货信息场景设计。


系统架构

┌─────────────────────────────────────────────────────────────────┐
│                        飞书群聊消息源                             │
│   烯烃-丙烯群 / 液化气群 / 甲醇群 / 丁二烯群 / 链客研究汇报群     │
└──────────────────────────┬──────────────────────────────────────┘
                           │ 飞书 Webhook / 消息同步
                           ▼
┌─────────────────────────────────────────────────────────────────┐
│  表A: linker_feishu_group_messages (上游同事维护)               │
│  id / group_name / sender_name / msg_type / content / send_time │
│  digest_processed(0=待处理, 1=已处理)                             │
├─────────────────────────────────────────────────────────────────┤
│  表C: linker_feishu_group_files (上游同事维护,独立采集链路)     │
│  id / group_chat_id / message_id / file_name / file_type        │
│  cos_url / download_status / process_status                     │
└──────────────────────────┬──────────────────────────────────────┘
                           │
              ┌────────────┘  每5分钟 cron
              ▼
┌─────────────────────────────────────────────────────────────────┐
│              feishu_message_processor.py                         │
│                                                                  │
│  链路1 - 文字消息(驱动源: messages 表 digest_processed=0)       │
│  text/post ──────────────────────► digest_text(聊天列)          │
│                                                                  │
│  链路2 - 文件/图片(驱动源: files 表, 标记在 file_extract 表)    │
│                                                                  │
│  jpg/png ──► 千问 qwen-vl-plus(主)/ 豆包(备)──► file_digest_text │
│              直接传 cos_url,免下载                               │
│                                                                  │
│  pdf ──► pypdf 提取文本 ──────────────────────► file_digest_text  │
│  docx ──► docx2txt 提取 ─────────────────────► file_digest_text  │
│  pptx/其他 ──► 标记 skipped                                      │
│                                                                  │
│  每个文件内容上限 FILE_MAX=3000 字符                              │
│  防重复: INSERT IGNORE → 抢占标记后才写 digest                    │
└──────────────────────────┬──────────────────────────────────────┘
                           │
                           ▼
┌─────────────────────────────────────────────────────────────────┐
│           表B: linker_feishu_daily_digest                         │
│   date / group_name / group_chat_id                              │
│   digest_text (聊天文字)  ← 纯聊天,无文件/图片                   │
│   file_digest_text (文件/图片)  ← 提取内容,分列存储              │
│   UNIQUE KEY (date, group_chat_id)  — 每群每天一行                │
├─────────────────────────────────────────────────────────────────┤
│   表D: linker_feishu_file_extract (我方表,提取状态跟踪)        │
│   file_id(PK) / group_chat_id / group_name / file_type          │
│   extract_date / status(success/failed/skipped) / error_msg     │
└──────┬────────────────────────────────────┬───────────────────────┘
       │                                │
       │ 短期记忆                        │ 每天 23:55 cron
       │ 直查(实时,延迟≤5分钟)         ▼
       │                   ┌────────────────────────────────────┐
       │                   │    feishu_ragflow_sync.py           │
       │                   │    聊天: {group}_{date}.txt         │
       │                   │    文件: {group}_{date}_files.txt   │
       │                   │    meta_fields: group_name, date,   │
       │                   │                 doc_type            │
       │                   └──────────────┬─────────────────────┘
       │                                  │
       │                                  ▼
       │                   ┌────────────────────────────────────┐
       │                   │    RAGFlow 知识库                   │
       │                   │    向量化存储,支持语义检索            │
       │                   │    metadata 过滤:group_name / date │
       │                   └──────────────┬─────────────────────┘
       │                                  │ 长期记忆
       │                                  │ 语义检索(跨群跨日期)
       ▼                                  ▼
┌─────────────────────────────────────────────────────────────────┐
│                      MCP 工具层                                   │
│                                                                  │
│  query_feishu            ← 主入口,并发拉取长短期,返回结合结果    │
│  get_feishu_group_digest ← 某群完整原文,分层返回 {chat, files}   │
│  list_feishu_groups      ← 群名发现                              │
└──────────────────────────┬──────────────────────────────────────┘
                           │
                           ▼
                      Agent / LLM

设计理念

长短期记忆强制结合query_feishu 并发调用两个数据源,agent 单次调用即可获得:

  • 短期记忆(MySQL):完整聊天时间线,实时(延迟≤5分钟)
  • 长期记忆(RAGFlow):语义相关历史片段(含聊天和文件),跨时间跨群

聊天与文件分列存储

  • digest_text:纯聊天文字,优先召回,体积可控
  • file_digest_text:文件摘要+图片描述,按需召回,不冲占聊天空间
  • get_feishu_group_digest 返回 { chat, files } 分层结构

Agent 决策树

群名不确定                    → list_feishu_groups → 再调其他工具
需要某群逐日完整原文(≤7天)   → get_feishu_group_digest
其他所有问题                  → query_feishu

MCP 工具参数

query_feishu(主入口)

| 参数 | 类型 | 说明 | |------|------|------| | question | string | 查询问题,同时用于语义检索 | | group_name | string(可选) | 群名关键词,模糊匹配,不传查所有群 | | date | string(可选) | 指定日期 YYYY-MM-DD,不传则短期记忆查今天 | | top_k | number(可选) | 长期记忆返回片段数,默认 5 |

get_feishu_group_digest

| 参数 | 类型 | 说明 | |------|------|------| | group_name | string | 群名关键词,模糊匹配 | | days | number(可选) | 最近几天,默认 3,最大 7 |

返回 { chat: [...], files: [...] },先聊天后文件。

list_feishu_groups

无参数。返回所有群名、最近活跃日期、活跃天数。


ETL 脚本(etl_scripts/

部署在 192.168.20.118:/home/linker-feishu-etl/,通过 crontab 调度。

文件说明

| 文件 | 说明 | |------|------| | feishu_message_processor.py | 增量清洗:文字→digest_text,文件→file_digest_text | | feishu_ragflow_sync.py | RAGFlow 同步:聊天+文件分两个文档 upsert 到知识库 | | ragflow_meta_cleaner.py | RAGFlow 元数据清洗(每2小时) | | run_processor.py | 加载 .env 后调用 processor(cron 入口) | | run_ragflow_sync.py | 加载 .env 后调用 ragflow sync(cron 入口) | | .env | 环境变量(不入 git,参考 .env.example) | | requirements.txt | Python 依赖 | | schema.sql | 建表/加列 DDL |

Crontab

*/5 * * * * cd /home/linker-feishu-etl && /root/miniconda3/bin/python3 run_processor.py >> processor.log 2>&1
55 23 * * * cd /home/linker-feishu-etl && /root/miniconda3/bin/python3 run_ragflow_sync.py >> ragflow_sync.log 2>&1
0 */2 * * * cd /home/linker-feishu-etl && /root/miniconda3/bin/python3 ragflow_meta_cleaner.py >> meta_cleaner.log 2>&1

环境变量

参见 .env.example,关键配置:

  • DASHSCOPE_API_KEY:千问 API(图片解析主模型)
  • DOUBAO_API_KEY:豆包 API(图片解析备用)
  • FILE_BATCH:每次 cron 最多处理文件数(默认 30)
  • FILE_TYPES:限制处理的文件类型(逗号分隔,留空=全部)
  • FILE_MAX:每个文件提取内容上限字符数(默认 3000)

文件处理策略

| 类型 | 处理方式 | 状态 | |------|---------|------| | jpg/png/webp | 千问 qwen-vl-plus(直接传 URL),失败回退豆包 | ✅ | | pdf | pypdf 提取文本 | ✅ | | docx | docx2txt 提取 | ✅ | | xlsx/xlsm | openpyxl 逐行读取 | ✅ | | txt/md/csv | 直接读文本 | ✅ | | pptx | 跳过 | ⏭️ |


安装

npx linker-feishu-mcp@latest

MCP 配置

{
  "mcpServers": {
    "linker-feishu-mcp": {
      "command": "npx",
      "args": ["-y", "linker-feishu-mcp@latest"],
      "env": {
        "FEISHU_DB_HOST": "1.13.171.218",
        "FEISHU_DB_PORT": "13316",
        "FEISHU_DB_USER": "linker_ro",
        "FEISHU_DB_PASS": "linkerRO2026!",
        "FEISHU_DB_NAME": "linker_dmp",
        "RAGFLOW_API_BASE": "http://192.168.20.118:30080",
        "RAGFLOW_API_KEY": "ragflow-TlV2VxzljJgN11H8are6cDdugnsWk3PXWkWqrrv-_wk",
        "FEISHU_DAILY_KB_ID": "8d2301c241f511f1a0657222bb602843"
      }
    }
  }
}

使用 @latest 可在每次启动时自动拉取最新版本,无需手动升级版本号。