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

yapi-mcp-interface

v1.1.1

Published

用于查询 YApi 接口数据定义的 MCP

Readme

YApi MCP Interface

这是一个基于 Model Context Protocol (MCP) 的 YApi 接口查询工具,支持从 YApi 服务器获取接口详细信息。

功能特性

  1. 获取接口详细信息

    • 接口基本信息(标题、路径、请求方法等)
    • 入参参数(请求体)
    • 返回响应值及结构
  2. 检查当前YApi 配置信息

    • 获取当前 YApi 服务器的配置信息,包括 URL、项目令牌是否已配置。

工具列表

get_interface_details

获取 YApi 接口的详细信息。

参数:

  • interface_id (number, 必需): YApi 接口 ID

get_yapi_config

获取当前 YApi 配置信息。

参数:

MCP 接入指南

MacOS / Linux

{
  "mcpServers": {
    "yapi-mcp-interface": {
      "command": "npx",
      "args": ["-y", "yapi-mcp-interface"],
      "env": {
        "YAPI_URL": "https://example.com",
        "YAPI_PROJECT_TOKEN": "your_yapi_project_token"
      }
    }
  }
}

Windows

{
  "mcpServers": {
    "yapi-mcp-interface": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "yapi-mcp-interface"],
      "env": {
        "YAPI_URL": "https://example.com",
        "YAPI_PROJECT_TOKEN": "your_yapi_project_token"
      }
    }
  }
}

接入MCP后和智能体对话中返回值示例(已预设返回格式-只有在使用stdio时才生效)

  • 基本信息(Basic Information)
    • 接口名称 (例如:获取用户列表)
    • 请求方法及路径 (例如:POST /api/users)
  • 请求参数(Body)
    {
      "name": "用户名", // 类型: string, 必填: false, 备注: "用户名"
      "age": 18 // 类型: number, 必填: false, 备注: "年龄"
    }
  • 响应数据结构(Response Data)
    {
      "code": 200, // 类型: number, 备注: "状态码"
      "msg": "success", // 类型: string, 备注: "状态描述"
      "data": {
        "id": 1, // 类型: number, 备注: "用户ID"
        "name": "张三", // 类型: string, 备注: "用户名"
        "age": 18 // 类型: number, 备注: "年龄"
      }
    }

注意事项

  1. 配置正确性:确保 YApi 服务器地址和令牌配置正确
  2. 参数格式:接口 ID 必须是数字格式,其他参数也需要符合预期格式
  3. 环境变量:初始化时需要设置 YAPI_URL(YApi 服务器地址) 和 YAPI_PROJECT_TOKEN(YApi 项目令牌)
  4. 使用传输协议:本地默认使用 stdio 协议,添加启用参数 --http 可以使用 Streamable HTTP 协议,启动成功后可根据段口号localhost:xxxx/mcp 访问MCP服务

故障排除

常见问题

  1. MCP 服务器无法启动

    • 检查 Node.js 版本是否 >= 18.0.0
    • 检查依赖是否安装正确
  2. 无法连接到 YApi 服务器

    • 检查 YApi 服务器地址是否正确 (例如:https://example.com)
    • 检查网络连接是否正常
    • 检查 YApi 令牌是否有效
  3. 获取YApi项目token

    • 登录YApi后(设置-token配置-复制项目令牌)
  4. 获取接口id

    • 登录YApi后(接口-接口列表-点击其中某个接口浏览器地址栏上显示的接口ID)
  5. 在智能体对话中怎么触发yapi-mcp-interface工具

    • 需要确认模型是否已经绑定了且正常启用 yapi-mcp-interface 工具
    • 如果已绑定且启用可以直接问 获取一下当前yapi配置信息 这时智能体就会调用工具中的 get_yapi_config 去查询当前配置
    • 可以智能体对话中问 获取yapi接口id为1234 这时智能体就会调用工具中的 get_interface_details 去查询接口详情
  6. 切换项目需要重新配置令牌

    • 重新获取项目令牌,并更新MCP配置中的令牌值
  7. 当使用设备因为某些原因无法直接使用更高版本的node时

    • 建议使用nvm管理node版本并下载大于等于18版本的node
      # MacOS / Linux中可使用
      which node # 查看当前node使用路径
    • 找到node的安装运行路径 例如:
      {
        "mcpServers": {
          "yapi-mcp-interface": {
            "command": "/path/.nvm/versions/node/vx.x.x/bin/npx",
            "args": ["-y", "yapi-mcp-interface"],
            "env": {
              "YAPI_URL": "https://example.com",
              "YAPI_PROJECT_TOKEN": "your_yapi_project_token",
              "PATH": "/path/.nvm/versions/node/vx.x.x/bin:/usr/local/bin:/usr/bin:/bin"
            }
          }
        }
      }

日志查看

MCP 服务器的日志会输出到终端,您可以通过查看终端输出来排查问题。