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

@wangmhaha/apifox-mcp-server

v1.7.5

Published

<!-- * @Descripttion: * @version: * @Author: wangmin * @Date: 2025-03-20 14:39:11 * @LastEditors: wangmin * @LastEditTime: 2025-10-24 18:11:21 --> <!-- * @Descripttion: * @version: * @Author: wangmin * @Date: 2025-03-20 14:39:11 * @LastEditors:

Readme

ApiFox MCP Server

这是一个基于 Model Context Protocol (MCP) 的 ApiFox 接口服务器,用于获取和管理 ApiFox 的接口信息。通过在 Cursor 中配置 MCP 服务,获取对应接口模块信息返回给大模型,让 Cursor 通过接口信息帮助你实现业务逻辑。

功能特点

  • 支持通过 MCP 协议获取 ApiFox 接口信息
  • 提供 HTTP 服务和 CLI 命令行两种使用方式
  • 使用 TypeScript 开发,提供类型安全
  • 支持环境变量配置

快速安装使用


npx @wangmhaha/apifox-mcp-server@latest --apifox-api-key=<your-apifox-api-key> --project=<your-project-id>

配置 cursor 通过 sse 连接到 MCP 服务器

服务器将在配置的端口上启动(默认 3000)。

"apifox-mcp-server": {
    "url": "http://localhost:3000/sse",
  }

推荐通过使用配置文件 JSON 配置

可以通过在 cursor mcp 配置文件中添加以下内容来配置 apifox-mcp-server 服务器:

"apifox-mcp-server": {
  "command": "npx",
  "args": [
    "-y",
    "@wangmhaha/apifox-mcp-server@latest",
    "--local"
  ],
  "env": {
    "APIFOX_API_KEY": "<your-apifox-api-key>",
    "PROJECT_ID": "<your-project-id>"
  }
}

注意事项:

  • 确保 APIFOX_API_KEYPROJECT_ID 正确填写
  • 使用 @latest 确保安装最新版本
  • 必须包含 --local 参数以使用 stdio 模式

Windows 系统特别说明

⚠️ Windows 用户必读: 由于 shebang (#!/usr/bin/env node) 在 Windows 上的兼容性问题,请查看 Windows 用户指南 (WINDOWS.md) 获取详细配置说明。

快速配置:

推荐配置(使用 node 命令)

步骤 1:全局安装

npm install -g @wangmhaha/apifox-mcp-server@latest

步骤 2:找到安装路径

# 在 PowerShell 或 CMD 中运行
npm root -g
# 会输出类似:C:\Users\YourUsername\AppData\Roaming\npm\node_modules

步骤 3:在 Cursor 的 mcp.json 中配置

"apifox-mcp-server": {
  "command": "node",
  "args": [
    "C:\\Users\\YourUsername\\AppData\\Roaming\\npm\\node_modules\\@wangmhaha\\apifox-mcp-server\\build\\cli.js",
    "--local"
  ],
  "env": {
    "APIFOX_API_KEY": "<your-apifox-api-key>",
    "PROJECT_ID": "<your-project-id>"
  }
}

测试配置

在配置前,先在命令行测试:

set APIFOX_API_KEY=<your-key>
set PROJECT_ID=<your-project-id>
node "%APPDATA%\npm\node_modules\@wangmhaha\apifox-mcp-server\build\cli.js" --local

如果看到 "服务器已连接并准备处理请求",说明配置正确。

要求

  • Node.js 版本 >= 18.0.0(运行 node --version 检查)
  • 确保安装路径中的反斜杠在 JSON 中使用双反斜杠 \\

或者从本地源运行

拉取代码安装依赖

pnpm install

打包

pnpm build

运行

pnpm start:http

配置:

"apifox-mcp-server": {
    "url": "http://localhost:3000/sse",
    "env": {
      "APIFOX_API_KEY": "<your-apifox-api-key>",
      "PROJECT_ID": "<your-project-id>"
    }
  }

也可通过 command 模式运行

"apifox-mcp-server": {
    "command": "node",
    "args": [
      "<you-local-path>/build/index.js",
      "--local",
    ],
    "env": {
      "APIFOX_API_KEY": "<your-apifox-api-key>",
      "PROJECT_ID": "<your-project-id>"
    }
  },

如在不在 MCP 配置文件中配置 env 环境变量,请在本地环境变量配置

在项目根目录下修改.evn.example 文件为.env 文件,配置以下环境变量:

APIFOX_API_KEY=your_api_key_here
PROJECT_ID=your_project-ID
PORT=3000  # 可选,默认为 3000

技术栈

  • Node.js
  • TypeScript
  • Express.js
  • Model Context Protocol SDK
  • Zod(数据验证)

许可证

ISC License