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

apipost-sync-local

v1.0.3

Published

MCP server for syncing ApiPost projects to local JSON files via OpenAPI

Readme

ApiPost Sync Local MCP

一个 MCP 工具,用于从 ApiPost 同步项目数据到本地,让 AI 助手能够获取和理解你的 API 项目结构。

安装

方式一:全局安装(推荐)

npm install -g apipost-sync-local

然后在 MCP 配置文件中添加:

{
  "mcpServers": {
    "apipost-sync": {
      "command": "apipost-sync-local"
    }
  }
}

指定配置文件路径(可选):

{
  "mcpServers": {
    "apipost-sync": {
      "command": "apipost-sync-local",
      "env": {
        "CONFIG_PATH": "/path/to/your/apipost.json"
      }
    }
  }
}

方式二:使用 npx(无需安装)

{
  "mcpServers": {
    "apipost-sync": {
      "command": "npx",
      "args": ["-y", "apipost-sync-local"]
    }
  }
}

指定配置文件路径(可选):

{
  "mcpServers": {
    "apipost-sync": {
      "command": "npx",
      "args": ["-y", "apipost-sync-local"],
      "env": {
        "CONFIG_PATH": "/path/to/your/apipost.json"
      }
    }
  }
}

各编辑器配置位置

| 编辑器 | 配置位置 | |--------|----------| | Claude Desktop | %APPDATA%\Claude\claude_desktop_config.json (Windows) / ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) | | Cursor | 设置 → MCP → 添加服务器 | | VSCode + Cline/Roo Code | 插件设置中找到 MCP 配置 |


配置

在使用前,需要在项目根目录创建 apipost.json 配置文件:

{
  "host": "https://open.apipost.net",
  "project": [
    {
      "api-token": "your-api-token",
      "project_id": "your-project-id",
      "name": "项目名称"
    }
  ]
}

配置说明

| 字段 | 类型 | 必填 | 说明 | |------|------|------|------| | host | string | 是 | ApiPost API 地址,默认为 https://open.apipost.net | | project | array | 是 | 项目列表 | | project[].api-token | string | 是 | ApiPost 项目的 API Token | | project[].project_id | string | 是 | ApiPost 项目 ID | | project[].name | string | 否 | 项目名称(便于识别) |

如何获取 API Token 和项目 ID

  1. 登录 ApiPost
  2. 进入项目设置 → 开放平台
  3. 创建 API Token,获取 api-tokenproject_id

工具列表

sync_apipost_project

同步 ApiPost 项目数据,获取项目的完整 API 信息。

参数

| 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | config_path | string | 否 | 配置文件路径,默认为当前工作目录下的 apipost.json |

返回数据

返回配置中所有项目的详细信息,包括:

  • 项目基本信息
  • API 接口列表
  • 接口详情(路径、方法、参数等)

示例调用

使用默认配置路径:

{
  "name": "sync_apipost_project"
}

指定配置文件路径:

{
  "name": "sync_apipost_project",
  "arguments": {
    "config_path": "/path/to/your/apipost.json"
  }
}

返回示例

[
  {
    "project_id": "xxx",
    "project_name": "我的API项目",
    "api_token": "xxx",
    "apis": [
      {
        "path": "/api/users",
        "method": "GET",
        "description": "获取用户列表"
      }
    ]
  }
]

使用场景

  1. API 文档查询 - 让 AI 助手了解你的 API 结构
  2. 代码生成 - 基于项目 API 自动生成调用代码
  3. 接口调试 - 快速了解接口参数和返回格式
  4. 项目文档 - 自动生成 API 文档

系统要求

  • Node.js 18+

开发文档

项目结构

apipost-sync-local/
├── src/
│   ├── index.js        # 入口文件,MCP 服务器主逻辑
│   └── utils/
│       ├── utils.js    # 工具函数(配置读取、请求封装)
│       └── api.js      # ApiPost API 接口封装
├── apipost.json        # 配置文件示例
├── package.json
└── publish.js          # 发布脚本

开发环境

安装依赖

npm install

开发模式

# 直接运行
npm start

# 带热重载
npm run dev

发布流程

# 升级 patch 版本 (1.0.0 → 1.0.1)
npm run release

# 升级 minor 版本 (1.0.0 → 1.1.0)
npm run release:minor

# 升级 major 版本 (1.0.0 → 2.0.0)
npm run release:major

技术栈

扩展开发

添加新工具

src/index.jstools 数组中添加新工具定义:

const tools = [
  {
    name: 'sync_apipost_project',
    description: '获取ApiPost项目数据'
  },
  // 添加新工具
  {
    name: 'new_tool_name',
    description: '工具描述',
    inputSchema: z.object({
      // 参数定义
    })
  }
]

然后在 CallToolRequestSchema 处理器中添加对应的处理逻辑。

添加新 API

src/utils/api.js 中添加新的 API 方法:

export const newApiMethod = (options) => {
  const config = readConfig();
  return request(config.host + '/open/new/endpoint', {
    method: 'GET',
    ...options,
  });
};

License

MIT