apifable
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
**Read the spec. Understand the API. Integrate with confidence.**
[![NPM version][ico-version]][link-npm]
[![Software License][ico-license]](LICENSE)
[![GitHub Tests Action Status][ico-github-action]][link-github-action]
[![Total Downloads][ico-downloads]][link-downloads]
English | 繁體中文
---
Overview
apifable is an MCP server that helps AI integrate APIs more smoothly into TypeScript frontend projects. It makes it easy to explore API structure, search endpoints, and generate TypeScript types, giving your AI agent the context it needs to write accurate integration code.
✨ Features
- 📦 **AI-ready API context** — give AI the structure it needs to understand and work with your API
- 📘 **OpenAPI 3.0 / 3.1 support** — works with standard specs as a reliable source of truth
- 🤖 **MCP server for AI agents** — plug into Claude, Cursor, and Windsurf
- 🔍 **API exploration tools** — browse endpoints, search by keyword, and inspect full request/response details
- 🏷️ **TypeScript type generation** — generate TypeScript type definitions ready to use in frontend code
Getting Started
Installation
Run apifable init to set up your project configuration:
This creates apifable.config.json in your project root. The config file should be committed to version control so the spec path is shared with your team.
After the command starts, you can choose between **Manual file** and **Remote URL**.
1. Manual file
Use this mode if your OpenAPI spec already lives in the project, or if you want to manage spec updates yourself.
init will ask for the local file path, such as openapi.yaml.
This generates the following apifable.config.json:
You then need to place your OpenAPI spec at that path manually. When the backend API changes, you also need to update that file manually.
2. Remote URL
Use this mode if your OpenAPI spec is available from a stable remote URL, such as the OpenAPI spec endpoint provided by your backend API docs.
init will first ask for the remote URL, such as https://api.example.com/openapi.yaml (supports yaml and json files), and then ask for the local output path, such as openapi.yaml.
This generates the following apifable.config.json:
> [!NOTE]
> In this mode, init also adds the downloaded local spec path to .gitignore automatically, because the file is intended to be refreshed from the remote source. Of course, you can decide for yourself whether to commit it to version control.
You can then run the following command to download the OpenAPI spec from the remote URL to your local path (spec.url → spec.path). Whenever the spec changes, just run it again to refresh:
Headers
For non-sensitive headers that can be shared with your team, add spec.headers to apifable.config.json:
Auth Headers (Secret Tokens)
If downloading the remote OpenAPI spec requires authentication (private API), store secret headers in .apifable/auth.json. This file should **not** be committed to version control:
Both apifable.config.json and .apifable/auth.json support ${ENV_VAR} syntax in header values.
Headers Priority (highest to lowest)
1. .apifable/auth.json headers (overrides same-named keys)
2. apifable.config.json spec.headers
Claude Code
Add the following to your .mcp.json:
For other AI agents such as Cursor and Windsurf, you can follow the same approach to configure apifable as an MCP server.
Usage
Here are some example prompts you can use to explore APIs and build features.
Explore the API
Build a feature