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

yapi-mcp-server

v1.0.19

Published

YApi MCP Server

Readme

yapi-mcp-server

简介

yapi-mcp-serverModel Context Protocol (MCP) 的服务端实现。支持通过 MCP 协议获取 YApi 接口详情。


快速开始

全局node环境需 >=18

配置 mcp.json

在项目根目录下新建或编辑 mcp.json 文件,内容如下:

{
  "mcpServers": {
    "yapi-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "yapi-mcp-server",
        "--yapiToken=你的YApiToken",
        "--yapiHost=https://yapi.xxx.net"
      ]
    }
  }
}
  • 你的YApiToken 替换为实际的 YApi Token(token 获取路径:yapi 项目->设置->token 配置->工具标识)
  • https://yapi.xxx.net 替换为你的 YApi 服务域名

MCP Server 功能

  • 工具名yapi_get_apis_detail
  • 功能:批量获取 YApi 接口的详细信息。
  • 参数
    • apiIds:YApi 接口 ID 组成的数组。例如,接口地址为 /project/1/interface/api/66,则 ID 为 66。支持同时传入多个 ID。
  • 返回值:对应接口的详细信息对象数组,结构与 YApi 返回一致。

实践

mcp配置成功之后,直接对cursor说:

生成接口代码
@api/index.ts
@https://yapi.XXX.net/project/13533/interface/api/1554281
@https://yapi.XXX.net/project/13533/interface/api/1554288
@https://yapi.XXX.net/project/13533/interface/api/1554334

cursor就会调用yapi-mcp-server获取接口的信息,并根据项目代码规范,生成对应的接口代码,比如:

// 删除组织:https://yapi.XXX.net/project/13533/interface/api/1554334
export function deleteOrg(data: { id: number }) {
  return axios({
    url: "/goapi/admin/org/delete",
    method: "post",
    data,
    headers: {
      "Content-Type": "application/json",
    },
  });
}

ai 可以给 接口函数起名字,爽歪歪!

制定规范,使生成的接口代码更符合规范

在 .cursorrules 文件中,编写接口代码的规范,比如:

// .cursorrules

接口代码规范:

- apiName 驼峰且动词前置,保持简洁
- 使用 axiosInstance
- 注释需包含接口名和 yapi 文档链接
- headers 有需要再加

import { axiosInstance as axios } from '@/api/axiosToken'

// {{$value.title}}:{{$value.yapiDocUrl}}
export function {{$value.apiName}}(data) {
  return axios({
    url: '{{$value.path}}',
    method: '{{$value.method}}',
    data,
    // headers: { ... } // 如有自定义 header 再补充
  })
}

参考链接