
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 分