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

ext-mcp

v1.0.2

Published

Extendable MCP Framework

Readme

Test Publish English Doc

EXT-MCP

🧩 可扩展 MCP 框架

ext-mcp 包含 中间件模组 两个概念

  • 中间件:用于承载通用能力,基于洋葱模型实现
  • 模组:用于功能扩展,是 MCP 功能的集合 -- 功能指 MCP 协议中的 tool/prompt/resource
 ┌─────────────────────────┐
 │       LLM Request       │
 └─────────────────────────┘
             ↓
       ╔═════════════╗
       ║ middleware1 ║
       ╚═════════════╝
             ↓
       ╔═════════════╗
       ║ middleware2 ║
       ╚═════════════╝
             ↓
╔═══════════════════════════╗
║           mods            ║
║ ┌─────┐  ┌─────┐  ┌─────┐ ║
║ │mod1 │  │mod2 │  │mod3 │ ║
║ └─────┘  └─────┘  └─────┘ ║
╚═══════════════════════════╝
             ↓
       ╔═════════════╗
       ║ middleware2 ║
       ╚═════════════╝
             ↓
       ╔═════════════╗
       ║ middleware1 ║
       ╚═════════════╝

快速上手

🌰 完整示例代码见 demo 目录

安装

npm i ext-mcp

app 入口

import path from "path";
import XMCP from "ext-mcp";

import errorHandler from "./middlewares/error-handler";
import sayGoodbye from "./mods/say-goodbye";

const app = new XMCP({
  name: "my-mcp",
  version: "0.0.1",
});

// 🖇️ 中间件
app.use(path.join(__dirname, "./middlewares/logger")); // file path
app.use(errorHandler); // function
// app.use(require.resolve('@foo/mcp-middleware-logger')); // npm/workspace package

// 🧩 模组
app.installMod(path.join(__dirname, "./mods/say-hello")); // file path
app.installMod(sayGoodbye); // function
// app.installMod(require.resolve('@foo/mcp-mod-demo')); // npm/workspace package

// 启动服务,目前只支持 stdio 模式
app.start();

中间件定义

以实现一个 logger 中间件为例,在上下文中注入 logId 和 logger

import { type Middleware } from "ext-mcp";

export interface LoggerContext {
  logId: string;
  logger: {
    info: (message: string) => void;
    error: (message: string) => void;
  };
}

const middleware: Middleware<LoggerContext> = async (context, next) => {
  context.logId = `foo-log-id`;
  context.logger = createLogger(context.logId);
  context.logger.info(`mcp started: ${context.actionName}`);
  const res = await next();
  context.logger.info(`mcp finished: ${context.actionName}`);
  return res;
};

export default middleware;

模组定义

import type { Mod, Tool } from "ext-mcp";
import { z } from "zod/v3";

const sayHello: Tool<{ name: z.ZodString }> = {
  name: "say-hello",
  config: {
    title: "打个招呼吧",
    description: "用于 MCP 模组测试",
    inputSchema: { name: z.string().describe("用户名字") },
  },
  handler: (context) => {
    const { name } = context.args;
    return {
      content: [
        {
          type: "text",
          text: `Hello, ${name}!`,
        },
      ],
    };
  },
};

const demoMod: Mod = {
  name: "demo-mod",
  version: "0.0.1",
  description: "示例模组",
  tools: [sayHello],
};

export default demoMod;

仓库开发

核心代码在 src 目录,使用示例在 demo 目录

构建和测试

# 安装依赖
npm install

# 构建
npm run build

# 测试
npm test

调试 demo 服务

# 启动调试工具。@see https://github.com/modelcontextprotocol/inspector
npx @modelcontextprotocol/inspector

服务启动后,Command 填入 demo/run.sh 的绝对路径,即可开始调试

配置 demo 服务到 IDE

仓库中已经针对部分 IDE 做了配置,可直接在 IDE 中查看效果,配置文件: