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

@zhin.js/mcp-feature

v1.0.13

Published

Convention-based MCP client Feature for Zhin Plugin Runtime

Readme

@zhin.js/mcp-feature

下一代 MCP Client Feature。它从 mcp/<name>.ts 发现 provider-neutral client definition,并将连接实例的创建、启动、调用和销毁绑定到 Plugin owner 与 generation lease。

目录约定

mcp/
├── filesystem.ts
└── memory.ts

只发现一级 .ts 文件。连接参数、URL、command 和 secret 应从 owner config/resource 读取,不写入另一份全局 MCP 配置 registry。

定义 MCP Client

import { defineMcp } from '@zhin.js/mcp-feature';
import { mcpTransportFactoryToken } from '../plugin.js';

export default defineMcp({
  description: 'Workspace filesystem tools',
  create(context) {
    const client = context.use(mcpTransportFactoryToken).create(context.config);
    return {
      start: () => client.connect(),
      stop: () => client.close(),
      listTools: () => client.listTools(),
      callTool: (name, input) => client.callTool(name, input),
    };
  },
});

create() 在 projection prepare 中执行,只能构造 inert client;网络连接必须放在 start()。具体 stdio/HTTP transport 和 MCP SDK 由 Plugin Resource 或可选 adapter 提供,本包没有相关第三方依赖。

单文件插件可用 setup({ addMcp }) 注册 defineMcp(...)。它仍走相同的连接 handoff、 owner 继承和 generation 回收。

生命周期

prepare candidate: create()
before commit:     candidate.start()
commit:            publish new McpIndex
old lease = 0:     previous.stop()
rollback:          candidate.stop()

MCP 候选连接不会触碰旧 client。旧 turn 继续通过旧 projection 与 snapshot lease 完成在途调用;新 turn 只看到已启动并已提交的新 client。要求排他连接时,连接必须由 Process Host 持有,并让 generation 只原子切换逻辑路由,不能在 shadow prepare 中抢占旧连接。

McpIndex 对连接使用 owner inheritance。动态工具名由 client 返回;orchestrator 可投影为 {connection}__{tool},但该模型命名不改变 Capability identity。

验证

pnpm --filter @zhin.js/mcp-feature test
pnpm --filter @zhin.js/mcp-feature build