# @buildwithlayer/openapi-to-tools 中文文档

规范地址：https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/

版本：1\.3\.3
npm 元数据更新时间：2025-06-11T19:18:57.790Z
中文译文更新时间：2026-11-08T19:18:09.864Z
软件包许可：UNLICENSED

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40buildwithlayer/openapi-to-tools
原文对照：https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/?lang=original
项目主页：https://github.com/buildwithlayer/openapi-to-tools
源码仓库：https://github.com/buildwithlayer/openapi-to-tools

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：180 kB，52 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- Node.js 要求：\>=18
- 运行依赖：7 个
- 首次发布：2025-05-05T22:38:20.176Z
- 最新版本发布：2025-06-11T19:18:57.554Z
- 近 30 天下载量：7020（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：13（近 12 个月 0 个）

## 中文简介

从 OpenAPI 光谱创建符合 MCP 工具的工具

## 安装

```sh
npm install @buildwithlayer/openapi-to-tools
```

也可以使用：`pnpm add @buildwithlayer/openapi-to-tools`、`yarn add @buildwithlayer/openapi-to-tools`、`bun add @buildwithlayer/openapi-to-tools`

## README

[![npm version](https://badge.fury.io/js/@buildwithlayer%2Fopenapi-to-tools.svg)](https://badge.fury.io/js/@buildwithlayer%2Fopenapi-to-tools) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

# 打开API到工具

> 这是一个简单的软件包,可以将OpenAPI路由转换为供MCP服务器或其他LLM应用使用的工具.

## 先决条件

该项目需要NodeJS(第18版或以后版)和国家预防机制. [节点](http://nodejs.org/) 财务报告和审定财务报表 [国家预防机制](https://npmjs.org/) 非常容易安装. 为了保证你的机器能提供, 尝试运行以下命令.

```sh
$ npm -v && node -v
10.2.4
v20.11.0
```

## 目录

-   [打开API到工具](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-openapi-to-tools)
    -   [先决条件](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-prerequisites)
    -   [目录](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-table-of-contents)
    -   [安装](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-installation)
    -   [使用量](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-usage)
        -   [国 际](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-cli)
        -   [MCP 服务器](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-mcp-server)
    -   [捐款](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-contributing)
    -   [版本](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-versioning)
    -   [许可证](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-license)

## 安装

**在你进来之前:** 请阅读 [先决条件](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/#readme-prerequisites)

要安装和设置库, 运行 :

```sh
$ npm install @buildwithlayer/openapi-to-tools
```

或者,如果你喜欢使用雅恩:

```sh
$ yarn add @buildwithlayer/openapi-to-tools
```

## 使用量

### 国 际

-   `input_file_path` 是任何有效的 OpenAPI Spec 3. X 的路径
-   `output_file_path` 是 JSON 文件写工具的路径

```shell
npx @buildwithlayer/openapi-to-tools <input_file_path> [-o <output_file_path>]
```

### MCP 服务器

```ts
import {addAPIToolsPlugin} from '@buildwithlayer/openapi-to-tools/index.js';
import {apiTools} from './tools.json';

const server = new McpServer(
    {
        name: 'very-cool-server',
        version: '1.0.0',
    },
    {
        capabilities: {
            tools: {},
        },
    },
);

// Add any manual tools
server.tool('hello-world', async () => ({
    content: [
        {
            text: 'Hello, world!',
            type: 'text',
        },
    ],
}));

// Add the API tools (generated with CLI or using the library)
addAPIToolsPlugin(server, apiTools);

// Start receiving messages on stdin and sending messages on stdout
const transport = new StdioServerTransport();
await server.connect(transport);
```

## 捐款

> 这些指示将予更新 _马上_。 。 。 .

请阅读 [捐款额](https://npmcn.com/package/%40buildwithlayer/openapi-to-tools/CONTRIBUTING.md) 详细介绍我们的行为守则和向我们提交拉动请求的程序.

1.  叉开它!
2.  创建您的特性分支 : `git checkout -b my-new-feature`
3.  添加您的更改 : `git add .`
4.  提交更改 : `git commit -am 'Add some feature'`
5.  推到树枝上: `git push origin my-new-feature`
6.  提交拉动请求 :

## 版本

我们用 [交换器](http://semver.org/) 用于版本。 有关现有版本,见 [此仓库上的标记](https://github.com/buildwithlayer/openapi-to-tools/tags)。 。 。 .

## 许可证

目前,这是没有许可证的,需要明确的许可才能使用. 未来,我们将打开这个许可证.

## 常见问题

### @buildwithlayer/openapi-to-tools 是什么？

从 OpenAPI 光谱创建符合 MCP 工具的工具

### 如何安装 @buildwithlayer/openapi-to-tools？

在项目目录运行 npm install @buildwithlayer/openapi-to-tools，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 openapi-to-tools，可以用 npx openapi-to-tools 直接运行。

### @buildwithlayer/openapi-to-tools 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/buildwithlayer\_\_openapi-to-tools 是否存在。

### @buildwithlayer/openapi-to-tools 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @buildwithlayer/openapi-to-tools 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @buildwithlayer/openapi-to-tools 可以商用吗？

@buildwithlayer/openapi-to-tools 使用 UNLICENSED 许可。作者声明为 UNLICENSED，即不授予公开使用许可（与公共领域的 Unlicense 不同）。使用前需获得作者授权。以上为概括，不构成法律意见，请以许可原文为准。

### @buildwithlayer/openapi-to-tools 的下载量有多少？

根据 npm 官方下载统计，@buildwithlayer/openapi-to-tools 在 2026/10/09 – 2026/11/07 这 30 天内被下载 7,020 次，日均约 234 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @buildwithlayer/openapi-to-tools 还在维护吗？

最新版本 1\.3\.3 发布于 2025/06/12（1\.4 年前）；至今共发布 13 个版本，其中过去 12 个月发布了 0 个；首次发布于 2025/05/06。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

