Show HN:我们做了一个 MCP 服务器,以便 Cursor 可以根据 API 文档构建任何东西
Show HN: We made an MCP Server so Cursor can build things from REST API docs

原始链接: https://www.npmjs.com/package/apidog-mcp-server

Apidog MCP 服务器将您的 Apidog API 文档连接到像 Cursor 这样的 AI 驱动的 IDE,从而实现 AI 辅助开发。它的工作原理是将您的 Apidog 项目的 API 文档缓存在本地,允许 AI 访问并利用它来执行代码生成、DTO 更新、添加注释以及基于您的 API 规范创建 MVC 代码等任务。 设置包括从 Apidog 生成 API 访问令牌并检索您的项目 ID,然后使用提供的 JSON 代码片段在您的 IDE 中配置 MCP 服务器,并将占位符替换为您的令牌和项目 ID。为了增强安全性,建议将 `APIDOG_ACCESS_TOKEN` 设置为环境变量。 此外,服务器还可以直接读取 Swagger/OAS 文件,从而无需 Apidog 项目 ID。对于内部部署,请指定 `--apidog-api-base-url` 参数。请记住为您的 MCP 服务器配置命名,以便 AI 轻松识别,并避免使用通用名称。由于服务器处于测试阶段,非常欢迎您提供反馈。

Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN:我们制作了一个 MCP 服务器,以便 Cursor 可以根据 API 文档构建任何内容 (npmjs.com) goargp 9 分钟前 12 分 | 隐藏 | 往期 | 收藏 | 讨论 加入我们 6 月 16-17 日在旧金山举办的 AI 初创公司学校! 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:

原文

The Apidog MCP Server allows you to use your API documentation from Apidog projects as a data source for AI-powered IDEs like Cursor. This means Agentic AI can directly access and work with your API documentation, speeding up development and making your workflow more efficient.

With Apidog MCP Server, developers can leverage the AI assistant to:

  • Generate or modify code based on API documentation.
  • Search through API documentation content.
  • And much more! Let your imagination and your team's creativity guide you. 😜

🎯 How Apidog MCP Server Works?

Once the Apidog MCP Server is set up, it automatically reads and caches all API documentation data from your Apidog project on your local machine. The AI can then retrieve and utilize this data seamlessly.

Simply instruct the AI on what you’d like to achieve with the API documentation. Here are some examples:

  1. Generate Code: "Use MCP to fetch the API documentation and generate Java records for the 'Product' schema and related schemas".
  2. Update DTOs: "Based on the API documentation, add the new fields to the 'Product' DTO".
  3. Add Comments: "Add comments for each field in the 'Product' class based on the API documentation".
  4. Create MVC Code: "Generate all the MVC code related to the endpoint '/users' according to the API documentation".
  • Node.js (version 18 or higher, preferably the latest LTS version).
  • An IDE that supports MCP, such as:
    • Cursor
    • VS Code + Cline plugin

Step 1. Generate an Access Token in Apidog

  • Open Apidog, hover over your avatar at the top-right corner, and click Account Settings > API Access Token.
  • Create a new API access token (refer to the help documentation for details).
  • Copy the access token and replace <access-token> in the configuration file below.

Step 2. Get the Apidog Project ID

  • Open the desired project in Apidog.
  • Click project Settings at the left sidebar, and copy the Project ID from the Basic Settings page.
  • Copy the project ID and replace <project-id> in the configuration file below.

Step 3. Configure the IDE

  • Copy the following JSON configuration code to add to the MCP configuration file in your IDE:
{
  "mcpServers": {
    "API docuemntation": {
      "command": "npx",
      "args": [
        "-y",
        "apidog-mcp-server@latest",
        "--project-id=<project-id>"
      ],
      "env": {
        "APIDOG_ACCESS_TOKEN": "<access-token>"
      }
    }
  }
}

If you're on Windows and the configuration file above isn't working, try using the configuration file below instead:

{
  "mcpServers": {
    "API docuemntation": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "apidog-mcp-server@latest",
        "--project-id=<project-id>"
      ],
      "env": {
        "APIDOG_ACCESS_TOKEN": "<access-token>"
      }
    }
  }
}
  • Add the copied JSON configuration code to the MCP file in your IDE:
    • For Cursor: Add to the global ~/.cursor/mcp.json or the project-specific .cursor/mcp.json.**
    • For Cline: Open the Cline panel > MCP Server > Configure MCP Server.
  • Replace <access-token> and <project-id> with your personal Apidog API access token and project ID.
  • Name the MCP Server something like "API Documentation" or "xxx API Documentation" to help the AI recognize its purpose. Avoid generic names like "Apidog" or "Apidog MCP", as it might confuse AI.
  • If you need to work with API documentation from several projects, simply add multiple MCP Server configurations to the configuration file. Each project should have its own unique <project-id>. For clarity, name each MCP Server following the format "xxx API Documentation".
  • If your team syncs the MCP configuration file to a code repository, it is recommended to remove the line "APIDOG_ACCESS_TOKEN": "<access-token>" and instead, configure the APIDOG_ACCESS_TOKEN as an environment variable on each member's machine to prevent token leakage.
  • For users of the on-premise deployment, add the following parameter to the MCP configuration file in your IDE: "--apidog-api-base-url=<API address of the on-premise server, starting with http:// or https://>". Additionally, ensure that your can access www.npm.com properly.
  • In addition to the Apidog project, Apidog MCP Server also has the ability to directly read Swagger or OpenAPI Specification (OAS) files. To use this feature:
    • Remove the --project-id=<project-id> parameter.
    • Add the--oas=<oas-url-or-path>parameter, such as npx apidog-mcp-server --oas https://petstore.swagger.io/v2/swagger.json or npx apidog-mcp-server --oas ~/data/petstore/swagger.json.

The Apidog MCP Server is currently in beta. We’d love to hear your feedback and suggestions! Join our Discord or Slack community for support and updates.

联系我们 contact @ memedata.com