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

api-create-mcp

v1.5.2

Published

MCP Server for creating API interfaces in ZeroRunner

Readme

API Create MCP Server

用于 ZeroRunner 系统的 MCP Server,支持通过 AI 助手创建和管理 API 接口。

📋 功能特性

  • 创建 API 接口 - 支持完整的接口配置(方法、URL、请求头、参数、请求体等)
  • 📋 获取接口列表 - 支持按项目、模块、名称等条件筛选
  • 🔍 获取接口详情 - 根据 ID 获取接口的完整信息

🚀 快速开始

安装

npm install -g api-create-mcp

或使用 npx(推荐):

npx -y api-create-mcp

配置

支持两种配置方式(按优先级排序):

  1. 环境变量(临时配置,优先级最高)
  2. 配置文件(推荐,一次配置永久使用)

方式一:配置文件(推荐)

创建配置文件 ~/.api-create-mcp/config.json

{
  "baseUrl": "https://zerorunner-api.magic-school.com",
  "token": "your-token-here"
}

macOS/Linux:

mkdir -p ~/.api-create-mcp
cat > ~/.api-create-mcp/config.json << EOF
{
  "baseUrl": "https://zerorunner-api.magic-school.com",
  "token": "your-token-here"
}
EOF

Windows (PowerShell):

New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.api-create-mcp"
@"
{
  "baseUrl": "https://zerorunner-api.magic-school.com",
  "token": "your-token-here"
}
"@ | Out-File -FilePath "$env:USERPROFILE\.api-create-mcp\config.json" -Encoding utf8

方式二:环境变量

通过环境变量配置:

  • BASE_URL: 后端 API 地址(默认: https://zerorunner-api.magic-school.com
  • TOKEN: 认证 Token(可选)

注意: 环境变量的优先级高于配置文件,如果同时设置了环境变量和配置文件,会优先使用环境变量的值。

在 MCP 客户端中使用

Cursor 配置(推荐)

Cursor 是一个支持 MCP 的代码编辑器,配置方法:

  1. 创建配置文件 ~/.api-create-mcp/config.json(见上方配置说明)

  2. 配置 Cursor MCP 服务器

    编辑配置文件:

    • macOS: ~/Library/Application Support/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Windows: %APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
    • Linux: ~/.config/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

    添加以下配置:

    {
      "mcpServers": {
        "api-create-mcp": {
          "command": "npx",
          "args": ["-y", "api-create-mcp"]
        }
      }
    }
  3. 重启 Cursor 使配置生效

  4. 开始使用:在 Cursor 的 AI 聊天中直接使用,例如:

    • "请帮我获取项目 1 下的所有接口列表"
    • "请帮我创建一个 GET 接口,URL 是 /api/user/info,项目 ID 是 1,模块 ID 是 1"

详细使用说明请参考 CURSOR_USAGE.md

Claude Desktop 配置

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json(macOS)或 %APPDATA%\Claude\claude_desktop_config.json(Windows):

方式一:使用配置文件(推荐,无需每次传token)

{
  "mcpServers": {
    "api-create": {
      "command": "npx",
      "args": ["-y", "api-create-mcp"]
    }
  }
}

确保已创建配置文件 ~/.api-create-mcp/config.json(见上方配置说明)。

方式二:通过环境变量传递(临时配置)

{
  "mcpServers": {
    "api-create": {
      "command": "npx",
      "args": ["-y", "api-create-mcp"],
      "env": {
        "BASE_URL": "https://zerorunner-api.magic-school.com",
        "TOKEN": "your-token-here"
      }
    }
  }
}

使用插件配置变量

如果使用 MCP 插件系统,可以通过配置变量引用:

{
  "mcpServers": {
    "api-create": {
      "command": "npx",
      "args": ["-y", "api-create-mcp"],
      "env": {
        "BASE_URL": "{{base_url}}",
        "TOKEN": "{{token}}"
      }
    }
  }
}

🛠️ 开发

本地开发

# 克隆项目
git clone <repository-url>
cd api-create-mcp

# 安装依赖
npm install

# 构建
npm run build

# 运行
npm start

# 开发模式(监听文件变化)
npm run dev

本地测试

提供了本地测试脚本,可以直接测试 API 调用,无需完整的 MCP 客户端:

# 方式一:使用 npm 脚本(推荐)
npm run test

# 方式二:手动设置环境变量后运行
export TOKEN=your-token-here
export BASE_URL=https://zerorunner-api.magic-school.com
npm run test

测试脚本功能:

  • ✅ 测试获取接口列表
  • ✅ 测试获取接口详情
  • ✅ 显示详细的请求和响应信息
  • ✅ 自动从配置文件读取 token 和 baseUrl

配置 token 的方式:

  1. 环境变量(临时):

    export TOKEN=your-token-here
    npm run test
  2. 配置文件(推荐):

    # 创建配置文件
    mkdir -p ~/.api-create-mcp
    cat > ~/.api-create-mcp/config.json << EOF
    {
      "baseUrl": "https://zerorunner-api.magic-school.com",
      "token": "your-token-here"
    }
    EOF
       
    # 运行测试
    npm run test

发布到 npm

# 登录 npm
npm login

# 发布
npm publish --access public

📖 API 工具说明

1. create_api

创建新的 API 接口。

必填参数:

  • name: 接口名称
  • method: HTTP 请求方法(GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
  • url: 接口 URL
  • project_id: 项目 ID
  • module_id: 模块 ID

可选参数:

  • description: 接口描述
  • headers: 请求头列表
  • params: URL 查询参数
  • body: 请求体内容
  • body_mode: 请求体模式(raw, form-data, x-www-form-urlencoded)
  • body_language: 请求体语言类型(JSON, XML, TEXT, HTML, JAVASCRIPT, CSS)
  • status: 接口状态(10-生效,20-失效)
  • priority: 优先级(1-高,2-中,3-低)
  • tags: 标签列表
  • remarks: 备注信息
  • variables: 变量列表
  • extracts: 提取器列表
  • validators: 校验器列表

2. get_api_list

获取接口列表。

参数:

  • project_id: 项目 ID(可选)
  • module_id: 模块 ID(可选)
  • name: 接口名称(模糊搜索,可选)
  • page: 页码(默认: 1)
  • page_size: 每页数量(默认: 10)

3. get_api_detail

获取接口详细信息。

参数:

  • id: 接口 ID(必填)

📝 示例

创建简单的 GET 接口

{
  "name": "获取用户信息",
  "method": "GET",
  "url": "/api/user/info",
  "project_id": 1,
  "module_id": 1,
  "description": "获取当前登录用户的基本信息"
}

创建带请求体的 POST 接口

{
  "name": "创建用户",
  "method": "POST",
  "url": "/api/user/create",
  "project_id": 1,
  "module_id": 1,
  "description": "创建新用户",
  "headers": [
    {
      "key": "Content-Type",
      "value": "application/json"
    }
  ],
  "body": "{\"username\": \"test\", \"email\": \"[email protected]\"}",
  "body_mode": "raw",
  "body_language": "JSON"
}

🔧 技术栈

  • TypeScript: 类型安全的 JavaScript
  • @modelcontextprotocol/sdk: MCP 协议 SDK
  • axios: HTTP 客户端

📄 许可证

MIT

🤝 贡献

欢迎提交 Issue 和 Pull Request!