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

zhenai-yapi-mcp

v1.0.3

Published

MCP server for YApi documentation management - retrieve API docs and collections from YApi

Downloads

29

Readme

yapi-mcp-server

一个用于YApi的 MCP (Model Context Protocol) 服务器,允许 Claude 和其他 AI 助手获取 API 文档和集合信息。

功能特性

  • 🔍 getApiDoc: 获取指定接口的详细文档
  • 📚 getApiList: 获取指定接口集合
  • 🔐 支持 Cookie 认证
  • 📝 结构化的 API 文档格式
  • ⚡ 基于 MCP 协议的高效通信

安装

npm install yapi-mcp-server

配置

在使用前,需要设置以下环境变量:

export COOKIE="yapi_cookie_string"
export BASE_URL="https://your-yapi-domain.com"

Claude Desktop 配置

在 Claude Desktop 的配置文件中添加:

{
  "mcpServers": {
    "zhenai-yapi-mcp": {
      "command": "/Users/mac/.nvm/versions/node/v20.18.1/bin/node", // 本地node路径
      "args": [
        "/Users/mac/.nvm/versions/node/v20.18.1/bin/npx", // 本地npx路径
        "zhenai-yapi-mcp"
      ],
      "disabled": false,
      "env": {
        "BASE_URL": "https://xxx.com", // yapi地址
        "COOKIE": "" // yapi cookie
      }
    }
  }
}

配置文件位置

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/claude/claude_desktop_config.json

使用方法

获取 API 文档

通过 Claude 调用 getApiDoc 工具:

{
  "name": "getApiDoc",
  "arguments": {
    "id": "123"
  }
}

返回结果示例

{
  "success": true,
  "id": "123",
  "title": "获取用户信息",
  "path": "/api/user/info",
  "method": "GET",
  "queryParmas": {
    "userId": {
      "type": "string",
      "description": "用户ID"
    }
  },
  "responseBody": {
    "code": {
      "type": "number",
      "description": "状态码"
    },
    "data": {
      "type": "object",
      "description": "用户信息"
    }
  }
}

获取 API 集合

通过 Claude 调用 getApiList 工具:

{
  "name": "getApiList",
  "arguments": {
    "id": "456"
  }
}

返回结果示例

{
  "success": true,
  "id": "456",
  "list": [
    {
      "name": "获取用户信息",
      "path": "/api/user/info",
      "method": "GET"
    },
    {
      "name": "更新用户信息",
      "path": "/api/user/update",
      "method": "POST"
    }
  ]
}

开发

本地开发

# 克隆项目
git clone https://github.com/yourusername/yapi-mcp-server.git
cd yapi-mcp-server

# 安装依赖
npm install

# 开发模式(直接运行源码)
npm run dev

# 构建项目
npm run build

# 测试MCP服务器
npm test

项目结构

yapi-mcp-server/
├── dist/                    # 构建输出目录
├── src/                     # 源代码目录
│   └── index.js            # 主入口文件
├── bin/                     # 可执行文件
│   └── yapi-mcp            # CLI工具
├── scripts/                 # 构建脚本
│   └── build.js            # 构建脚本
├── README.md               # 项目文档
├── LICENSE                 # 许可证文件
└── package.json            # 项目配置

环境变量说明

| 变量名 | 描述 | 示例 | | ---------- | ---------------- | -------------------------------- | | COOKIE | YApi 登录 Cookie | _yapi_token=xxx; _yapi_uid=xxx | | BASE_URL | YApi 服务地址 | https://yapi.example.com |

获取 Cookie 的方法

  1. 在浏览器中登录 YApi
  2. 打开开发者工具 → Network
  3. 刷新页面,找到任意 API 请求
  4. 复制请求头中的 Cookie

故障排除

常见问题

  1. 认证失败

    • 检查 Cookie 是否过期
    • 确认 BASE_URL 是否正确
  2. 连接错误

    • 确保 YApi 服务可访问
    • 检查网络连接
  3. 权限问题

    • 确认用户有访问对应 API 的权限

版本历史

  • 1.0.0: 初始版本
    • 支持 getApiDocgetApiList 工具
    • 基本的 MCP 协议实现

相关链接