@buildwithlayer/openapi-to-tools

中文文档
1.3.3发布于 2025/06/12UNLICENSEDESM + CJS近 30 天下载 7020

A tool to create MCP compliant tools from an OpenAPI Spec

原始使用文档
文档目录9 节
  1. Prerequisites
  2. Table of contents
  3. Installation
  4. Usage
  5. CLI
  6. MCP Server
  7. Contributing
  8. Versioning
  9. License

npm version code style: prettier

OpenAPI to Tools

This is a simple package to convert OpenAPI routes to tools to be used by MCP servers or other LLM applications.

Prerequisites

This project requires NodeJS (version 18 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

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

Table of contents

Installation

BEFORE YOU INSTALL: please read the prerequisites

To install and set up the library, run:

$ npm install @buildwithlayer/openapi-to-tools

Or if you prefer using Yarn:

$ yarn add @buildwithlayer/openapi-to-tools

Usage

CLI

  • input_file_path is a path to any valid OpenAPI Spec 3.X.X
  • output_file_path is a path to a JSON file to write the tools
npx @buildwithlayer/openapi-to-tools <input_file_path> [-o <output_file_path>]

MCP Server

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);

Contributing

These instructions will be updated soon.

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests to us.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request :sunglasses:

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

Currently, this is unlicensed and requires explicit permission to use. In the future, we will open up this license.

版本与发布记录

@buildwithlayer/openapi-to-tools 共发布 13 个版本,首次发布于 2025/05/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.3.3latest2025/06/121.4 年前
1.3.22025/06/051.4 年前
1.3.12025/06/021.4 年前
1.3.02025/05/291.4 年前
1.2.22025/05/271.5 年前
1.2.12025/05/231.5 年前

关于 @buildwithlayer/openapi-to-tools 的常见问题

@buildwithlayer/openapi-to-tools 是什么?

A tool to create MCP compliant tools from an OpenAPI Spec

如何安装 @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 和提交记录判断。