Converts OpenAPI specifications into MCP tool definitions with automatic parameter conflict resolution and built-in HTTP request building.
Also known as agentfront/mcp-from-openapi
- Stars
- 12
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- —
- Last commit
- Nov 12, 2026
- License
- Apache-2.0
What is from-openapi MCP?
from-openapi converts OpenAPI specifications into MCP tool definitions with automatic parameter conflict resolution and built-in HTTP request building.
Summary generated from the project's README
About from-openapi MCP server
Developers looking to bridge the gap between REST APIs and AI agents can use this library to transform OpenAPI specifications into ready-to-use MCP tool definitions. It automates the difficult task of handling parameter conflicts where the same name appears in different locations like the path, query, or request body. By providing an explicit mapper and a built-in request builder, it ensures that HTTP requests are constructed correctly without manual assembly.
The tool works in Node.js or V8 isolates like Cloudflare Workers and supports loading specifications from URLs, files, or JSON objects. It includes specialized features for different AI clients, allowing users to target Claude, OpenAI, or Gemini to ensure the emitted schemas match what each specific model accepts. It also provides security features like SSRF prevention and support for various authentication schemes including Bearer, OAuth2, and AWS Sig V4.
Beyond simple conversion, it offers curation capabilities such as token budget reports via analyzeToolSet and linting to identify specification gaps. Users can filter tools by tags, methods, or path globs to create a refined set of capabilities for their agents.
What you can do with it
- 1Resolve API parameter naming conflictsAutomatically rename overlapping parameters from different parts of an HTTP request to prevent schema collisions.
- 2Generate client-specific tool schemasEmit JSON schemas that are specifically formatted for the requirements of Claude, OpenAI, or Gemini.
- 3Automate HTTP request constructionConvert tool inputs directly into valid HTTP requests including complex query serialization and multipart bodies.
- 4Monitor AI token consumptionEstimate the token cost of a toolset to prevent accuracy degradation in AI agents.
Written from the project's README. Every use case is checked against a quote from it.
How to install from-openapi MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall from-openapi MCP in Claude Code
$ claude mcp add mcp-from-openapi -- npx -y mcp-from-openapiInstall from-openapi MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"mcp-from-openapi": {
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}Install from-openapi MCP in VS Code
.vscode/mcp.json
{
"servers": {
"mcp-from-openapi": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}Install from-openapi MCP in VS Code CLI
$ code --add-mcp '{"name":"mcp-from-openapi","type":"stdio","command":"npx","args":["-y","mcp-from-openapi"]}'Install from-openapi MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"mcp-from-openapi": {
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}Install from-openapi MCP in Codex
$ codex mcp add mcp-from-openapi -- npx -y mcp-from-openapiInstall from-openapi MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.mcp-from-openapi] command = "npx" args = ["-y", "mcp-from-openapi"]
Install from-openapi MCP in Gemini CLI
$ gemini mcp add -s user mcp-from-openapi npx -- -y mcp-from-openapiInstall from-openapi MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"mcp-from-openapi": {
"command": "npx",
"args": [
"-y",
"mcp-from-openapi"
]
}
}
}Automated checks
Ran Nov 14, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachableagentfront/mcp-from-openapi is public and reachablegithub.com/agentfront/mcp-from-openapi ↗Pass
- Package names this repository as its sourcemcp-from-openapi names agentfront/mcp-from-openapi as sourcenpmjs.com/package/mcp-from-openapi ↗Pass
- Build provenance (Sigstore attestation)Sigstore attestation for mcp-from-openapinpmjs.com/package/mcp-from-openapi/v/2.9.3#provenance ↗Pass
- Open source license (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-12github.com/agentfront/mcp-from-openapi ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNo popular package one edit away from mcp-from-openapiPass
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubmcp-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 questions
How do I add from-openapi MCP to Claude Code?
Run claude mcp add mcp-from-openapi -- npx -y mcp-from-openapi in your terminal. Add --scope user to make it available in every project.
How do I add from-openapi MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
How does the library handle parameter conflicts in OpenAPI specs?
It automatically detects and resolves conflicts where the same parameter name appears in different locations like path, query, or body by renaming them.
Can I use this with different AI clients like Claude or OpenAI?
Yes, it supports specific client compatibility targets including Claude, OpenAI, and Gemini by emitting schemas each client accepts.
Does it help with managing token usage for tools?
Yes, it includes context-budget reports that estimate the token cost per tool and warn you when thresholds are reached.
What authentication methods are supported?
The library provides framework-agnostic support for Bearer, Basic, Digest, API Key, OAuth2, OpenID, mTLS, HMAC, and AWS Sig V4.