OpenAPI仕様をMCP tool定義に変換します。パラメータの競合を自動的に解決し、HTTPリクエストの構築機能も備えています。
別名 agentfront/mcp-from-openapi
- スター
- 12
- ツール
- —
- ダウンロード数(30日間)
- —
- 最新バージョン
- —
- 最終コミット
- 2026年11月12日
- ライセンス
- Apache-2.0
from-openapi MCPとは
from-openapiはMCPサーバーです。 OpenAPI仕様をMCP tool定義に変換します。パラメータの競合を自動的に解決し、HTTPリクエストの構築機能も備えています。.
プロジェクトのREADMEから生成された概要
from-openapi MCP server について
REST APIとAIエージェントの橋渡しを検討している開発者は、このライブラリを使用してOpenAPI仕様をすぐに利用可能なMCP tool定義に変換できます。パス、クエリ、リクエストボディなど、異なる場所に同じ名前が登場するパラメータ競合の処理という困難なタスクを自動化します。明示的なマッパーと組み込みのリクエストビルダーを提供することで、手動での組み立てなしにHTTPリクエストが正しく構築されることを保証します。
このツールはNode.jsまたはCloudflare WorkersのようなV8 isolateで動作し、URL、ファイル、またはJSONオブジェクトから仕様を読み込むことができます。異なるAIクライアント向けの特化機能が含まれており、Claude、OpenAI、またはGeminiをターゲットに指定することで、出力されるスキーマが各モデルの要件に一致するようにできます。また、SSRF防止などのセキュリティ機能や、Bearer、OAuth2、AWS Sig V4を含むさまざまな認証スキームをサポートしています。
単なる変換にとどまらず、analyzeToolSetによるトークン予算レポートや、仕様の不足を特定するためのリンティングといったキュレーション機能も提供します。ユーザーはタグ、メソッド、またはパスのglobを使用してツールをフィルタリングし、エージェント向けに精査された機能セットを作成できます。
できること
- 1APIパラメータの命名競合の解決HTTPリクエストの異なる部分から重複するパラメータの名前を自動的に変更し、スキーマの衝突を防ぎます。
- 2クライアント固有のツールスキーマの生成Claude、OpenAI、またはGeminiの要件に合わせて特別にフォーマットされたJSONスキーマを出力します。
- 3HTTPリクエスト構築の自動化ツールの入力を、複雑なクエリのシリアル化やmultipartボディを含む有効なHTTPリクエストに直接変換します。
- 4AIトークン消費量の監視ツールセットのトークンコストを推定し、AIエージェントの精度低下を防ぎます。
プロジェクトの README から作成されています。すべてのユースケースは、その引用と照らし合わせて確認されています。
from-openapi MCPのインストール方法
フォーマット検証日 2026年11月10日Cursor に追加Gooseに追加Claude Codeにfrom-openapi MCPをインストール
$ claude mcp add mcp-from-openapi -- npx -y mcp-from-openapiCursorにfrom-openapi MCPをインストール
~/.cursor/mcp.json
{
"mcpServers": {
"mcp-from-openapi": {
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}VS Codeにfrom-openapi MCPをインストール
.vscode/mcp.json
{
"servers": {
"mcp-from-openapi": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}VS Code CLIにfrom-openapi MCPをインストール
$ code --add-mcp '{"name":"mcp-from-openapi","type":"stdio","command":"npx","args":["-y","mcp-from-openapi"]}'Claude Desktopにfrom-openapi MCPをインストール
claude_desktop_config.json
{
"mcpServers": {
"mcp-from-openapi": {
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}Codexにfrom-openapi MCPをインストール
$ codex mcp add mcp-from-openapi -- npx -y mcp-from-openapiCodex config.tomlにfrom-openapi MCPをインストール
~/.codex/config.toml
[mcp_servers.mcp-from-openapi] command = "npx" args = ["-y", "mcp-from-openapi"]
Gemini CLIにfrom-openapi MCPをインストール
$ gemini mcp add -s user mcp-from-openapi npx -- -y mcp-from-openapiGemini settings.jsonにfrom-openapi MCPをインストール
~/.gemini/settings.json
{
"mcpServers": {
"mcp-from-openapi": {
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}自動チェック
実行日 2026年11月14日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。コードを読み、サーバーに必要最小限のアクセス権を与えてください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能agentfront/mcp-from-openapi is public and reachablegithub.com/agentfront/mcp-from-openapi ↗合格
- パッケージがこのリポジトリをソースとして指定mcp-from-openapi names agentfront/mcp-from-openapi as sourcenpmjs.com/package/mcp-from-openapi ↗合格
- ビルドの来歴 (Sigstore 証明)Sigstore attestation for mcp-from-openapinpmjs.com/package/mcp-from-openapi/v/2.9.3#provenance ↗合格
- オープンソースライセンス (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit or release 2026-11-12github.com/agentfront/mcp-from-openapi ↗合格
- OpenSSF Scorecard未チェック
- パッケージ名が有名なパッケージに酷似していないNo popular package one edit away from mcp-from-openapi合格
- パッケージおよびその依存関係に重大な勧告なし未チェック
- モデルへの隠れた指示がない0 tool descriptions and the README read; no override phrases, credential paths or hidden characters合格
- 破壊的なツールがラベル付けされている未チェック
- リモートエンドポイントが MCP ハンドシェイクに応答未チェック
README
GitHubで見るmcp-from-openapi
Convert OpenAPI specifications into MCP tool definitions with automatic parameter conflict resolution
What This Solves
When converting OpenAPI specs to MCP tools, you hit parameter conflicts -- the same name appears in different locations (path, query, body). This library resolves them automatically and gives you an explicit mapper for building HTTP requests.
The Problem:
paths:
/users/{id}:
post:
parameters:
- name: id # path
in: path
requestBody:
content:
application/json:
schema:
properties:
id: # body -- CONFLICT!
type: string
The Solution:
{
inputSchema: {
properties: {
pathId: { type: "string" }, // Automatically renamed
bodyId: { type: "string" } // Automatically renamed
}
},
mapper: [
{ inputKey: "pathId", type: "path", key: "id" },
{ inputKey: "bodyId", type: "body", key: "id" }
]
}
Now you know exactly how to build the HTTP request.
Features
- Built-in Request Builder --
buildHttpRequest()applies the full OpenAPI serialization table (form/deepObject/pipeDelimited queries, label/matrix paths, multipart, binary,wholeBody) so you never hand-write request assembly - Client Compatibility Targets --
target: 'claude' | 'openai' | 'gemini' | 'strict'emits schemas each client actually accepts (inlined refs, closed objects, collapsed unions, demoted formats) - Context-Budget Reports --
analyzeToolSet()estimates the token bill per tool and warns at the thresholds where agent accuracy degrades - Overlays & Lint -- apply OpenAPI Overlay curation files at load time;
lint()flags the spec gaps that hurt tool-calling accuracy - Curation-Grade Filtering -- Filter by tag, method, path glob (
/admin/**), operationId, areadOnlyOnlysafety switch, andx-mcpextension flags with root < path < operation precedence - Smart Parameter Handling -- Automatic conflict detection and resolution across path, query, header, cookie, and body;
allOfbodies flatten, union and binary bodies map cleanly (wholeBody,binarymarkers) - Complete Schemas -- Input schema combines all parameters; output schema from responses (with oneOf unions); clean JSON Schema 2020-12 output (
nullableunions, normalizedexamples) - MCP-Native Tools --
titleand toolannotations(readOnly/destructive/idempotent hints) inferred from HTTP semantics, overridable via thex-mcpextension family; spec-compliant tool names (64-char cap, stable hash truncation, collision dedup); deterministic tool ordering for prompt-cache friendliness;toSdkTool()for one-line SDK registration - Security Resolution -- Framework-agnostic auth for Bearer, Basic, Digest, API Key, OAuth2, OpenID, mTLS, HMAC, AWS Sig V4; per-scheme
includeSecurityInInput - SSRF Prevention -- Blocks internal IPs, localhost, and cloud metadata endpoints by default during
$refresolution; one-flagsecureDefaultsposture for untrusted specs - Multiple Input Sources -- Load from URL, file, YAML string, or JSON object
- Rich Metadata -- Authentication, servers, tags, deprecation, external docs,
x-frontmcpextension - Production Ready -- Full TypeScript support, validation, structured errors, 100% test coverage (enforced)
- Runtime Agnostic -- Works on Node and V8 isolates (Cloudflare Workers) alike
Installation
npm install mcp-from-openapi
# or
yarn add mcp-from-openapi
# or
pnpm add mcp-from-openapi
Quick Start
import { OpenAPIToolGenerator } from "mcp-from-openapi";
// Load an OpenAPI spec
const generator = await OpenAPIToolGenerator.fromURL(
"https://api.example.com/openapi.json",
);
// Generate MCP tools
const tools = await generator.generateTools();
// Each tool has everything you need
tools.forEach((tool) => {
console.log(tool.name); // "createUser"
console.log(tool.title); // "Create a user" (from summary/extensions)
console.log(tool.annotations); // { readOnlyHint: false, destructiveHint: true, ... }
console.log(tool.inputSchema); // Combined schema for all params
console.log(tool.outputSchema); // Response schema
console.log(tool.mapper); // How to build the HTTP request
console.log(tool.metadata); // Auth, servers, tags, etc.
});
Building Requests
buildHttpRequest() turns a tool plus input values into a ready-to-send request — style/explode serialization, deepObject queries, multipart, binary, and wholeBody handled correctly:
import { buildHttpRequest } from "mcp-from-openapi";
const request = buildHttpRequest(tool, { id: "42", filter: { tag: "news" } });
// { url: 'https://api.example.com/users/42?filter[tag]=news',
// method: 'GET', headers: {...}, body: undefined, ... }
await fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body as BodyInit,
});
The mapper array stays public for anyone who needs custom request assembly — see Request Builder and Parameter Conflicts for its contract.
Serving with the Official MCP SDK
import { toSdkTool, buildHttpRequest } from "mcp-from-openapi";
import { fromJsonSchema } from "@modelcontextprotocol/server"; // SDK v2
for (const tool of await generator.generateTools({ target: "claude" })) {
server.registerTool(...toSdkTool(tool, { fromJsonSchema }), async (input) => {
const request = buildHttpRequest(tool, input);
const response = await fetch(request.url, {
method: request.method,
headers: request.headers,
body: request.body as BodyInit,
});
return { content: [{ type: "text", text: await response.text() }] };
});
}
Documentation
| Document | Description |
|---|---|
| Getting Started | Loading specs, generating tools, building requests |
| Configuration | LoadOptions, GenerateOptions, RefResolutionOptions |
| Parameter Conflicts | How conflict detection and resolution works |
| Request Builder | buildHttpRequest — full OpenAPI parameter serialization |
| Client Targets | Per-client schema dialects (Claude, OpenAI, Gemini) |
| Curation | Token budgets, overlays, lint, trimming, response hints |
| Type Signatures | TypeScript call contracts for code-execution surfaces |
| Modern MCP Fields | Tool _meta, icons, x-mcp-header, elicitation descriptors |
| Arazzo Workflows | fromArazzo() — Arazzo 1.0 workflows as consolidated MCP tools |
| Tested Examples | Runnable examples, each executed as an e2e test on every CI run |
| Response Schemas | Output schemas, status codes, oneOf unions |
| Annotations & Extensions | Tool title, annotation inference, x-mcp extension family |
| Security | SecurityResolver, all auth types, custom resolvers |
| SSRF Prevention | Ref resolution security, blocked IPs and hosts |
| Format Resolution | Format-to-schema enrichment (uuid, date-time, email, int32, etc.) |
| Naming Strategies | Custom tool naming and conflict resolvers |
| SchemaBuilder | JSON Schema utility methods |
| Error Handling | Error classes, context, and patterns |
| x-frontmcp Extension | Custom OpenAPI extension for MCP annotations |
| API Reference | Complete types, interfaces, and exports |
| Examples | MCP server, Zod, filtering, security, and more |
| Architecture | System overview, data flow, design patterns |
Requirements
- Node.js >= 20.0.0
- TypeScript >= 5.0 (for TypeScript users)
- Peer dependency:
zod@^4.0.0
Contributing
Contributions are welcome! Start with the contributing guide; this project follows the Contributor Covenant. Bug reports and feature requests go through the issue templates.
Security
Report vulnerabilities privately — see the
security policy.
When loading untrusted specs, use secureDefaults: true.
Related Projects
License
from-openapi MCPのよくある質問
from-openapi MCPをClaude Codeに追加するには
ターミナルでclaude mcp add mcp-from-openapi -- npx -y mcp-from-openapiを実行します。すべてのプロジェクトで利用するには--scope userを追加します。
from-openapi MCPをCursorに追加するには
~/.cursor/mcp.jsonを開き、上記のインストールセクションに示すCursor設定を使ってmcpServersの下にサーバーを追加します。
OpenAPI仕様におけるパラメータの競合をどのように処理しますか?
パス、クエリ、ボディなど、異なる場所に同じパラメータ名が存在する場合、それらを自動的に検出し、名前を変更することで競合を解決します。
ClaudeやOpenAIなどの異なるAIクライアントで使用できますか?
はい、各クライアントが受け入れ可能なスキーマを出力することで、Claude、OpenAI、Geminiなどの特定のクライアントとの互換性をサポートしています。
ツールのトークン使用量の管理に役立ちますか?
はい、ツールごとのトークンコストを推定するコンテキスト予算レポートが含まれており、しきい値に達した際に警告を表示します。
サポートされている認証方法は何ですか?
Bearer、Basic、Digest、API Key、OAuth2、OpenID、mTLS、HMAC、AWS Sig V4を、フレームワークに依存しない形でサポートしています。