
Openapi Sync Mcp
io.github.akintomiwa-fisayo由 GitHub 账号 akintomiwa-fisayo 发布v6.4.2更新于 Oct 24, 2026
Type-safe MCP server for OpenAPI Sync to inspect, validate, and synchronize OpenAPI specs.
概览
让助手检查、校验并同步 OpenAPI 规范,并生成带类型的 API 客户端与校验模式。
- 可以做什么
- 把 openapi-sync 命令行工具封装为 MCP 工具,助手可以分页筛选列出接口、查看单个接口的详细信息,并在不重新加载规范的情况下读取生成的 TypeScript 类型声明。它还能校验配置与规范、运行诊断健康检查、从远程 URL 同步规范、生成带类型的客户端(fetch、axios、react-query、swr、rtk-query、next-fetch)以及 Zod、Yup 或 Joi 校验模式,并清理过期的生成文件。命令均为非交互式,并输出机器可读的 JSON。
- 适用场景
- 当项目维护 OpenAPI 规范,并希望助手在开发流程中浏览接口、检查规范或配置健康状况,或重新生成类型、客户端与校验模式时,适合使用。
- 运行要求
- 以 npm 包(openapi-sync-mcp,底层为 openapi-sync)形式通过 stdio 在本地运行,需要 Node.js 和 npx。需要配置文件(openapi.sync.json、.ts 或 .js)或等效的命令行参数来提供规范 URL 或本地文件。获取远程规范需要网络访问。受保护的规范需要凭据,且必须在 TypeScript 或 JavaScript 配置文件中通过环境变量引用。
安装
在 SourceWeft 中
- 打开 控制台中的 Openapi Sync Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
[NPM Version] [License] [Tests]
OpenAPI Sync
OpenAPI Sync is a powerful developer tool that automates the synchronization of your API documentation with your codebase using OpenAPI (formerly Swagger) specifications. It generates TypeScript types, fully-typed API clients (Fetch, Next.js Fetch, Axios, React Query, SWR, RTK Query), endpoint definitions, runtime validation schemas (Zod, Yup, Joi), and comprehensive documentation from your OpenAPI schema—ensuring type safety from API specification through client implementation to runtime validation.
Core Features
- ⚡ Zero-Config Presets - 10 pre-configured framework presets (React Query, SWR, Axios, Fetch, RTK Query, Next.js, Python) for instant setup
- 🔄 Real-time API Synchronization - Automatically syncs OpenAPI specs from remote URLs with configurable intervals
- 📝 Automatic Type Generation - Generates TypeScript interfaces for all endpoints with full nested support
- 🔐 Runtime Validation - Generate Zod, Yup, or Joi schemas from OpenAPI specs with all constraints preserved
- 🎯 Interactive Setup Wizard - Streamlined configuration with auto-enabled tag-based folder splitting
- 🛡️ Enterprise Ready - Error handling, validation, state persistence, and custom code preservation
- 📦 Folder Splitting - Organize code by tags or custom logic with aggregator files for easy imports
- 📚 Rich Documentation - JSDoc comments with cURL examples and inline usage guides
- 🤖 Agent-Ready Endpoints - Browse endpoints with pagination and path filtering, inspect deep endpoint details, and read generated types without reloading the spec
- 🩺 Diagnostic Doctor - Diagnostic health checks for config validity, spec accessibility, peer dependencies, cache, and folder write permissions
- 🧹 Stale File Purge - Manifest-based stale code detection and cleanup with dry-run support to prevent orphaned code
- 🔄 Custom Code Injection - Preserve your custom code between regenerations with protected sections
Installation
⚠️ macOS Big Sur Users: If you encounter an esbuild error (
Symbol not found: _SecTrustCopyCertificateChain), install[email protected]first. See Troubleshooting for details.
🤖 Using with AI Agents
All CLI commands and programmatic APIs are agent-safe — no interactive prompts, fully non-blocking. Use --json for machine-readable output and --silent to suppress logs.
Full agent reference:
llms.txt— a structured discovery file for LLMs, Copilots, and MCP tools.
Agent Quick-Start (no prompts)
Machine-Readable Output (--json)
Every command emits a single, pure JSON object to stdout when --json is passed, making it safe to pipe directly into jq or consume from automated agents. All human-readable progress logs are suppressed or directed to stderr.
Dry Run (preview without writing files)
Compact, fast previews of planned files:
Layouts & Output Directories
- Flat Mode (Default): When
folderSplitis omitted or empty ({}), files are placed directly in the API folder (endpoints.ts,types/index.ts,types/shared.ts). - Tag-Split Mode: Setting
folderSplit: { byTags: true }organizes endpoints into tag subfolders (e.g.{tag}/endpoints.ts,{tag}/types.ts,shared.ts). - Custom Client Directory:
clientGeneration.outputDir(or CLI--output) is fully supported in both flat and folder-split layouts. In flat mode, clients are placed directly in{outputDir}/clients.ts(orapi.ts), while in folder-split mode clients are placed in{outputDir}/{tag}/client.tsand aggregated at{outputDir}/clients.ts, with relative imports resolving back to your generated types and endpoints.
Programmatic API (TypeScript)
Exit Codes
Agent-safe vs Interactive Commands
Quick Start
Option 1: Interactive Setup (Recommended) 🎯
The easiest way to get started is with the interactive setup wizard:
The wizard will guide you through:
- 📝 Configuration file format selection (TypeScript, JSON, or JavaScript)
- 🌐 API specification source (URL or local file)
- 📁 Folder organization options (split by tags or custom logic)
- 🚀 Client generation options (React Query, SWR, Fetch, Axios, RTK Query)
- ✅ Validation library setup (Zod, Yup, Joi)
- 🔧 Custom code preservation settings
- 🏷️ Type naming preferences (operationId usage, prefix)
- 🚫 Endpoint filtering (exclude by tags)
- 📚 Documentation options (cURL examples)
Option 2: Manual Setup
1. Create openapi.sync.json in your project root:
2. Run the sync command:
3. Use generated types and endpoints:
View detailed quick start guide →
⚡ Presets (Zero-Config Framework Setup)
Presets bundle opinionated defaults for your framework, client library, and validation stack into a single name. Instead of configuring dozens of settings by hand, pick a preset during npx openapi-sync init or set "preset": "<name>" in your config file. Any explicit configuration values you define always override preset defaults.
Using a Preset
In the CLI Setup Wizard:
Non-Interactive / CI:
In JSON (openapi.sync.json):
In TypeScript (openapi.sync.ts):
View presets guide on website →
API Client Generation
Generate fully-typed API clients with hooks for popular libraries:
Generate Fetch Client
Generate Axios Client
Generate React Query Hooks
Generate SWR Hooks
Generate RTK Query API
Generate Next.js Fetch Client (App Router & Server Components)
Usage in Next.js App Router (Server Components):
Filter by Tags or Endpoints
Usage Example (React Query)
1. Generate the client:
2. Use in your React components:
Client Generation Options
Custom Code Preservation
Generated clients support custom code sections that are preserved during regeneration:
View complete client generation guide →
Configuration
Supports multiple configuration formats: openapi.sync.json, openapi.sync.ts, or openapi.sync.js
Basic Example:
Advanced TypeScript Example:
🔐 Protected Specs & Stored Authentication (auth)
Fetch OpenAPI specifications protected behind Bearer tokens, Basic auth, API keys, or custom headers.
⚠️ IMPORTANT FOR HUMANS & AI AGENTS: Referencing environment variables for credentials requires using a TypeScript (
openapi.sync.ts) or JavaScript (openapi.sync.js) configuration file. Static JSON (openapi.sync.json) does not support JavaScript runtime expressions likeprocess.env. Always useopenapi.sync.tsoropenapi.sync.jswhen dynamic environment variables are needed to keep secrets safe and prevent invalid JSON syntax errors.
TypeScript Example (openapi.sync.ts):
JavaScript Example (openapi.sync.js):
View full configuration options →
CLI Commands
Interactive Setup
Launch an interactive wizard that guides you through creating your configuration file. Perfect for first-time setup or exploring available options.
Sync API Types
Synchronize your OpenAPI specifications and generate TypeScript types, endpoints, and validation schemas.
Zero-Config CLI Execution & Config Overrides
You can run openapi-sync directly from terminal scripts or CI/CD pipelines without creating a configuration file on disk. Pass any property supported by the configuration file via CLI flags:
[!NOTE] If run without a configuration file on disk and without necessary CLI flags (e.g.
--api-url,--api <name>=<url>, or--config-json),openapi-syncwill display the standardConfigNotFoundError, prompting you to runnpx openapi-sync init.
Generate API Client
Generate fully-typed API clients for various frameworks and libraries.
Available Commands & Options
CLI Flag Aliases
Flags are interchangeable across init, sync, validate, and generate-client:
- Output folder:
--output-folderor--folder(-f) (defaults to project root"") - Validation library:
--validation-libraryor--validation-lib(--validations-library) - Tag folder split:
--folder-splitor--split-by-tags - Type prefix:
--types-prefixor--type-prefix
Diagnostic Health Checks (doctor)
Run an automated environment audit to diagnose config syntax, specification accessibility, optional peer dependencies (zod, yup, joi), cache state, and directory write permissions:
Output Example:
Stale File Detection & Cleanup (purge)
Whenever endpoints or schemas are removed from your OpenAPI specification, previously generated files can become orphaned in your codebase. openapi-sync tracks generated artifacts via .openapi-sync/manifest.json and automatically detects stale files.
Inspecting Endpoints & Types (get-endpoint, read-type)
AI agents and developers can query specific endpoint metadata or read generated type declarations without loading huge files or blowing LLM context windows:
Typed Error Codes & Recovery
All CLI commands and programmatic methods throw structured error objects extending OpenApiSyncError. Each error exposes a stable code string:
Documentation
For complete documentation including:
- Configuration Options - All available settings and customization
- Generated Output - Understanding generated files and structure
- Custom Code Injection - Preserve your code between regenerations
- Validation Schemas - Runtime validation with Zod, Yup, or Joi
- Advanced Examples - Complex configurations and use cases
- API Reference - Programmatic usage and type definitions
- Troubleshooting - Common issues and solutions
Visit openapi-sync.com
🔌 MCP Server (Model Context Protocol)
openapi-sync ships with a complete Model Context Protocol (MCP) server. AI agents (Claude Desktop, Cursor, Windsurf, Zed, and any MCP-compatible client) can query endpoints, inspect schemas, read generated types, and execute syncs directly via type-safe tool calls over stdio — without pasting entire 5MB–15MB specs into prompt context.
The MCP server is published both as part of openapi-sync and as a dedicated zero-install companion package on npm: openapi-sync-mcp.
[npm version] [Glama] [Install in Cursor]
4 Ways Users & Agents Can Access OpenAPI Sync
Starting the Server
Transport: The server uses stdio transport — it reads JSON-RPC from stdin and writes responses to stdout. The working directory (
cwd) of the process is used as the project root for reading and writing files.
Host Configuration Guides
1. Cursor Configuration
Create or update .cursor/mcp.json in your project root:
Or add it globally via Cursor Settings → Features → MCP → + Add New MCP Server.
2. Claude Desktop Configuration
Edit your configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
3. Windsurf (Codeium) Configuration
Add to ~/.codeium/windsurf/mcp_config.json:
4. Zed Configuration
Add to your Zed settings.json under context_servers:
5. Google Antigravity Configuration
Add to your global configuration (~/.gemini/config/mcp_config.json) or project root (.agents/mcp_config.json):
Available MCP tools
Typical agent workflow via MCP
Tool input/output types
All tools return JSON-serialized versions of the same structured types used by the programmatic API:
openapi_sync_sync→SyncResultopenapi_sync_generate_client→SyncResultopenapi_sync_validate→ValidationResultopenapi_sync_doctor→DoctorResult({ healthy, checks, recommendations })openapi_sync_list_endpoints→Record<string, EndpointSummary[]>openapi_sync_get_endpoint_details→{ apiName, endpoint }openapi_sync_read_generated_type→stringopenapi_sync_init→{ success, configFile, message, errors }openapi_sync_read_config→{ found, file, path, content }
Troubleshooting
macOS Big Sur (11.x) - esbuild Installation Error
Error: dyld: Symbol not found: _SecTrustCopyCertificateChain when installing openapi-sync
Cause: The default esbuild version requires macOS 12.0+ APIs that aren't available in Big Sur.
Solution: Install a compatible esbuild version before installing openapi-sync:
Alternatively, add an override to your package.json:
Note: This issue only affects macOS Big Sur (darwin 20.x). Users on macOS 12+ are not affected.
License
ISC License - see LICENSE file for details.
Contributing
Contributions welcome! Submit pull requests to our GitHub repository.
Contributors
A special thanks to the following contributors for their valuable work on this project:
[Fisayo Akintomiwa] [Opemipo Akintomiwa] [Ayotunde Obasa]Support / Donate
If you find OpenAPI Sync useful and would like to support its development, thank you — your support helps pay for hosting, CI, and ongoing maintenance.
You can support the project in any of the following ways:
- Sponsor the maintainer on GitHub: https://github.com/sponsors/akintomiwa-fisayo
- Back the project on Open Collective (placeholder): https://opencollective.com/fisayo-akintomiwa
Thank you for considering supporting the project — every bit helps.
来源:README.md,提交 8f9cde0
工具
0版本历史
1- v6.4.2最新Sep 18, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分