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

@zjlab-fe/data-hub-ui-mcp

v0.1.0

Published

MCP server that exposes @zjlab-fe/data-hub-ui metadata to code-review clients.

Readme

@zjlab-fe/data-hub-ui-mcp

一个 stdio MCP (Model Context Protocol) server,为代码审查工具(OCR 等)暴露 @zjlab-fe/data-hub-ui 组件库的元信息。

Tools

所有工具均返回 JSON。

| 名称 | 输入 | 输出 | 描述 | | --- | --- | --- | --- | | get_components | 无 | JSON | 完整组件清单(components.yaml) | | get_components_category | 无 | JSON | 组件分类字典(category.yaml) | | get_components_by_category | category: string | JSON | 按分类过滤组件,返回 category 数组包含目标值的组件条目 | | get_component_props | name: string | JSON | 返回指定组件的声明签名及其 props 类型完整定义 |

  • 一个组件可属于多个分类,get_components_by_category 只要其 category 数组包含目标值即命中。
  • 未知分类不会报错,返回空的 entries 数组。
  • get_component_props 从 CDN 拉取 dist/types/components/<dirName>/index.d.ts 解析;若 props 类型 import 自同目录子文件(如 ./types),会自动追踪拉取。返回结构:{ version, name, dirName, component, propsTypeName, props }。

工作机制

1. 查询 npm registry 的 @zjlab-fe/data-hub-ui@latest 版本
2. 从 cdn.jsdmirror.com 拉取该版本的 metadata/components.yaml 与 metadata/category.yaml
3. 校验:
   - components.yaml 的 version 必须与发布版本一致
   - entries 的 category 必须全部存在于 category.yaml 的 categories 白名单中
4. 校验通过 → 写入版本对齐的快照(TTL 2 小时)
5. 降级链:
   - 缓存新鲜         → 直接返回(source=cache)
   - 刷新成功         → 返回远端(source=remote)
   - 刷新失败且有缓存 → 返回过期缓存(source=stale-cache)
   - 刷新失败且无缓存 → 返回包内置兜底(source=baseline)

日志输出到 stderr,可用环境变量 ZJLAB_DATA_HUB_MCP_LOG_LEVEL 控制(silent / error / info / debug,默认 error)。

安装 & 配置

在 MCP 客户端中配置

{
  "mcpServers": {
    "data-hub-ui": {
      "command": "npx",
      "args": ["-y", "@zjlab-fe/data-hub-ui-mcp"]
      // 可选:需要更详细日志时再显式设置级别
      // "env": { "ZJLAB_DATA_HUB_MCP_LOG_LEVEL": "info" }
    }
  }
}

也可以直接指向构建产物:

{
  "command": "node",
  "args": ["C:/path/to/data-hub-ui-mcp/dist/bin/cli.js"]
}

本地调试

# 安装依赖
npm install

# 构建(tsc + 复制 metadata 到 dist)
npm run build

# 运行测试
npm test

# 以 stdio 方式启动(一般由 MCP 客户端拉起,手动跑用于验证能否启动)
node dist/bin/cli.js

项目结构

data-hub-ui-mcp/
├── metadata/                  # 内置兜底 yaml(构建时复制到 dist/metadata)
│   ├── components.yaml
│   └── category.yaml
├── scripts/
│   └── copy-metadata.mjs      # 构建后复制 metadata 到 dist
├── src/
│   ├── bin/
│   │   └── cli.ts             # stdio 入口
│   ├── config.ts              # 远端路径 / 镜像 / 缓存等单点维护
│   ├── logger.ts              # 分级日志
│   ├── metadata-types.ts      # 类型定义
│   ├── component-types.ts     # 组件 .d.ts 解析(声明签名 + props 类型 + import 追踪)
│   ├── metadata-store.ts      # 快照加载、刷新、校验、降级
│   └── server.ts              # 工具注册(registerTool + zod)
└── test/
    └── metadata-store.test.mjs

维护要点

1. 远端元信息路径

src/config.ts 中 componentsPath / categoryPath 描述的是 @zjlab-fe/data-hub-ui 包内的相对路径,需与实际发包路径保持一致:

export const metadataConfig = {
  packageName: '@zjlab-fe/data-hub-ui',
  componentsPath: 'metadata/components.yaml',
  categoryPath: 'metadata/category.yaml',
  componentTypesDir: 'dist/types/components',
  // ...
};

2. 依赖的 data-hub-ui 发包配置

data-hub-ui 的 package.json 的 files 字段必须包含 metadata,否则 CDN 上拉不到这两个 yaml(本 MCP 会一直走 baseline 降级分支):

{
  "files": ["es", "lib", "dist", "metadata", "README.md", "LICENSE"]
}

3. 同步内置 yaml

每次 data-hub-ui 发版后,建议同步刷新本 MCP 项目 metadata/ 下的两个 yaml 并发个补丁版本,让离线兜底数据保持最新。

缓存清理

删除缓存快照文件即可立即失效缓存:

  • Windows: %LOCALAPPDATA%\zjlab-fe-data-hub-ui-mcp\metadata-snapshot.json
  • macOS: ~/Library/Caches/zjlab-fe-data-hub-ui-mcp/metadata-snapshot.json
  • Linux: $XDG_CACHE_HOME/zjlab-fe-data-hub-ui-mcp/metadata-snapshot.json 或 ~/.cache/zjlab-fe-data-hub-ui-mcp/metadata-snapshot.json

License

ISC