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

myai-mcp

v0.1.2

Published

MyAI 翻译平台的 MCP 服务(stdio 协议):飞书授权登录 + 热门短视频解析入库

Readme

myai-mcp

MyAI 翻译平台的 MCP 服务(stdio 协议),提供飞书授权登录与短视频上传解析能力。

授权逻辑与业务前端 my-translation-web 完全对齐:

  1. 飞书网页授权(https://open.feishu.cn/open-apis/authen/v1/authorize)获取临时 code
  2. POST /admin/fsCodeLogin?code=xxx 换取业务 token(code 走 query 参数)
  3. 后续请求携带 Authorization: Bearer <token>X-Version
  4. GET /admin/getInfo 获取用户资料;POST /admin/logout 登出

MCP 侧在此之上补充了:本地回环回调(自动完成授权)、state 防 CSRF、 凭证文件持久化(0o600)、JWT 过期本地预判与远端校验兜底。

工具列表

| 工具 | 说明 | | --- | --- | | auth_status | 查询登录状态(本地过期预判 + 临期远端校验) | | feishu_login | 打开浏览器完成飞书授权,回环回调自动换取 token | | submit_auth_code | 兜底入口:手动粘贴回调 URL 或 code 完成登录 | | current_user | 拉取当前登录用户完整资料 | | logout | 远端登出(尽力而为)并清除本地凭证 | | upload_douyin_video | 抖音来源:提交链接/分享全文做解析入库(不是发布到抖音) | | upload_other_video | 其他来源:本地视频文件上传后解析入库(标题 + 绝对路径) | | short_video_detail | 查询解析详情;contentanalysis 均非空视为处理完成 | | list_hot_accounts | 查询辅助创作的全部达人账号(ID/账号名/定位/赛道/标签/代表作数) | | hot_account_detail | 按账号名或 ID 查达人详情(自动列表匹配 → 详情,字段全量返回) |

短视频模块说明

本模块是热门短视频的解析入库能力(对应前端上传弹窗),不是把视频投稿/发布到 抖音、视频号、B 站等平台。服务端通过 MCP instructionssrc/server/instructions.ts) 向客户端模型下发分流规则:用户说「上传视频」时先问来源——抖音只需链接/分享全文, 其他来源需要标题 + 本地绝对路径,不追问封面、简介、定时发布等发布类信息。

业务契约与前端 shortVideoHotUploadDialog.vue 严格一致:

  • 抖音路径:三条链接正则与前端逐字符一致(网页 video/note、v.douyin 短链、 iesdouyin 分享链),校验通过后将 trim 后的原文整段提交,由后端提取链接。
  • 其他视频路径POST /scriptwriting/upload/getToken 获取火山 STS 临时凭证, Node 端经 @volcengine/openapiUploadMedia 上传至 MYAI_VOD_SPACE_NAME 空间 (路径 commentary/{env}/video/{时间戳}_{原文件名},含 Snapshot 封面截图, 与前端 TTUploader 行为等价),再以完整播放 URL 提交解析。
  • 返回语义:提交接口返回 data: { id, idIsNew }——idIsNew=0 表示视频已存在 (id 为重复数据的详情 ID);idIsNew=1 表示新增成功(id 为新建数据的详情 ID, 可立即用 short_video_detail 轮询解析进度)。新提交解析预计 3-5 分钟,完成后飞书通知。 兼容旧契约:data 为标量 ID 时视为已存在。

快速开始

npm install
npm run build
npm test

Cursor mcp.json 配置示例(通过 npx 使用已发布的包):

{
  "mcpServers": {
    "myai": {
      "command": "npx",
      "args": ["-y", "myai-mcp"],
      "env": {
        "MYAI_ENV": "test",
        "MYAI_API_BASE_URL": "https://your-backend.example.com/api",
        "MYAI_FEISHU_APP_ID": "cli_xxxxxxxxxxxxxxxx",
        "MYAI_VOD_URL_PREFIX": "https://your-vod-cdn.example.com",
        "MYAI_VOD_SPACE_NAME": "your-vod-space"
      }
    }
  }
}

配置

全部通过环境变量注入(见 .env.example)。

必填项(防泄密,包内不内置任何内部地址与应用标识,缺失时启动报错并列出缺失键):

| 变量 | 说明 | | --- | --- | | MYAI_API_BASE_URL | 业务后端 API 根地址(含 /api 前缀),由部署方提供 | | MYAI_FEISHU_APP_ID | 飞书应用 App ID(形如 cli_xxx),由部署方提供 | | MYAI_VOD_URL_PREFIX | 火山文件完整播放 URL 前缀,由部署方提供 | | MYAI_VOD_SPACE_NAME | 火山 VOD 空间名,由部署方提供 |

可选项(有内置默认值):

| 变量 | 默认值 | 说明 | | --- | --- | --- | | MYAI_ENV | test | 运行环境:test(测试)| prod(线上),决定上传路径环境段 commentary/{env}/video/… | | MYAI_CALLBACK_HOST | 127.0.0.1 | 回环回调主机 | | MYAI_CALLBACK_PORT | 52530 | 回环回调端口(0 为随机) | | MYAI_REDIRECT_URI | 无 | 显式 redirect_uri(优先于回环地址) | | MYAI_CREDENTIALS_PATH | ~/.myai-mcp/credentials.json | 凭证持久化路径 | | MYAI_AUTH_TIMEOUT_MS | 180000 | 等待授权回调超时 | | MYAI_X_VERSION | cn | 业务后端 X-Version 请求头 | | MYAI_LOG_LEVEL | info | 日志级别(日志走 stderr) |

白名单说明

回环授权要求 http://127.0.0.1:52530/callback 在飞书应用的「重定向 URL」白名单内。 若暂未配置白名单,可在浏览器手动完成授权后,将回调 URL(或其中的 code) 粘贴给 submit_auth_code 工具完成登录。

注意:若将 MYAI_REDIRECT_URI 显式设置为非本地回环地址(如业务网页地址), feishu_login 会直接报错并引导走 submit_auth_code(本地服务收不到该地址的回调, 干等只会超时)。

目录结构

src/
├── index.ts            # 组合根:依赖装配 + stdio 启动
├── config.ts           # MYAI_* 环境变量集中配置
├── auth/
│   ├── authManager.ts  # 登录态编排(工具层唯一入口)
│   ├── feishuAuth.ts   # 回环 OAuth + code 解析/换 token
│   └── tokenStore.ts   # 凭证持久化 + JWT 过期预判
├── http/
│   └── apiClient.ts    # fetch 封装 + 若依信封归一化
├── services/
│   └── shortVideo.ts   # 短视频领域层(校验/提交/详情,契约与前端一致)
├── upload/
│   └── vodUploader.ts  # 火山 VOD Node 端上传(STS + Snapshot 封面)
├── server/
│   ├── instructions.ts # initialize 下发的意图分流规则(防止误判为发布视频)
│   └── tools/          # 一文件一工具 + index.ts 聚合注册
└── utils/              # logger(stderr)/ errors / browser
test/                   # node:test 单测(编译到 dist-test)