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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wginit/mcp-api-manager

v1.0.1

Published

接口管理工具,实现前后端接口对接

Readme

简介

基于 MCP(Model Context Protocol)实现的接口文档解析与前端请求文件生成服务。支持:

  • 解析多样化 Markdown 接口文档(使用 markdown-it 进行容错解析)
  • 自动按“模块”聚合生成 API 请求文件(每个模块一个 JS 文件)
  • 可选生成对应的 mock 数据文件

依赖要求:Node.js 20+

集成到 MCP 客户端

在你的 mcp.json 中注册该服务(stdio 方式):

{
    "mcpServers": {
        "mcp-api-manager": {
            "command": "npx",
            "args": ["-y", "@wginit/mcp-api-manager@latest"]
        }
    }
}

服务启动后通过标准输入输出(stdio)与 MCP 客户端通信。

工具:parse-api-doc

  • 功能:解析本地 Markdown 接口文档并自动生成 API 请求文件(按模块聚合)与可选 mock 文件
  • 入参:
    • filePath: string,接口文档路径(绝对或相对路径均可)
    • apiDir: string,生成 API 请求文件保存目录
    • generateMock: boolean,是否生成 mock 数据(默认 false)

调用示例(概念示例,实际在 MCP 客户端内发起):

{
    "name": "parse-api-doc",
    "arguments": {
        "filePath": "D:\\project\\mcp-server\\api-manager\\docs\\api.md",
        "apiDir": "D:\\project\\mcp-server\\api-manager\\src\\api",
        "generateMock": true
    }
}

成功返回中会列出生成的文件绝对路径清单。

Markdown 文档格式支持说明

解析器使用 markdown-it,通过 tokens 解析,兼容度较高。建议遵循以下结构(不强制完全一致):

  • 二级标题划分接口:## 接口名或模块名
  • 三级标题分节:
    • ### 接口信息:使用列表项描述
      • - **接口名称**: xxx
      • - **请求方式**: GET|POST|PUT|DELETE|PATCH
      • - **接口路径**: /path/to/api
      • - **功能描述**: 文本说明
    • ### 请求参数:可包含
      • #### 请求体参数 (ModelName):表格,列建议包含「参数名 | 类型 | 必填 | 说明 | 示例值」
    • ### 请求示例:代码块(json 或 js 等)
    • ### 响应示例
      • 可直接放一个成功示例代码块;或使用 #### 成功响应#### 错误响应 子标题分别放置
    • 可选:### 错误响应示例:代码块

解析结果结构(每个接口):

  • method / path / name / desc
  • request.bodyModelrequest.bodyParams[](若检测到请求体参数表格)
  • requestExample / responseExample(成功)/ errorResponseExample(错误)

生成结果

  • API 请求文件按“模块”聚合
    • 模块依据接口路径的“目录部分”划分(去掉最后一段),例如:/estate/inspection/taskcontroller/saveTaskController
      • 模块键为 estate/inspection/taskcontroller
      • 文件名会被驼峰化输出为 estateInspectionTaskcontroller.js
    • 单个文件内导出该模块下所有接口方法
    • 方法名基于完整路径驼峰化生成,避免重名
    • 每个方法形如:
/**
 * 描述文本
 * @param {Object} params
 * @param {string} params.foo - foo
 * @returns {Promise<any>}
 */
export function estateInspectionTaskcontrollerSaveTaskController(params) {
    return request({
        url: "/estate/inspection/taskcontroller/saveTaskController",
        method: "POST",
        data: params,
    });
}
  • Mock 文件(当开启 generateMock
    • 仍按接口逐个生成,便于替换/对照
    • 输出目录:<apiDir>/mock
    • 文件名示例:estateInspectionTaskcontrollerSaveTaskController.mock.js
    • 内容:默认导出解析自“响应示例”的 JSON(若为空则为 {}