apifable
MCP server that helps AI agents explore OpenAPI specs, search endpoints, and generate TypeScript types.
README
<div align="center">

apifable
Read the spec. Understand the API. Integrate with confidence.
English | 繁體中文
</div>
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:
npx apifable@latest init
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.
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, and then ask for the local output path, such as ./openapi.yaml.
[!NOTE] In this mode,
initalso adds the downloaded local spec path to.gitignoreautomatically, because the file is intended to be refreshed from the remote source.
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:
npx apifable@latest fetch
Headers
For non-sensitive headers that can be shared with your team, add spec.headers to apifable.config.json:
{
"spec": {
"path": "openapi.yaml",
"url": "https://example.com/openapi.yaml",
"headers": {
"X-Api-Version": "2"
}
}
}
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:
{
"headers": {
"Authorization": "Bearer YOUR_SECRET_TOKEN"
}
}
Both apifable.config.json and .apifable/auth.json support ${ENV_VAR} syntax in header values.
{
"headers": {
"Authorization": "Bearer ${MY_API_KEY}"
}
}
Headers Priority (highest to lowest)
.apifable/auth.jsonheaders (overrides same-named keys)apifable.config.jsonspec.headers
Claude Code
Add the following to your .mcp.json:
{
"mcpServers": {
"apifable": {
"command": "npx",
"args": ["-y", "apifable@latest", "mcp"]
}
}
}
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
List all APIs
Show me APIs related to posts
List APIs under the Post tag
Show me the API details for post comments
Show me the API details for GET /posts/{id}/comments
Show me the API details for postComments
Build a feature
Implement the post comments feature
Post page: src/pages/posts/[id].tsx
Related APIs:
- GET /posts/{id}/comments (list post comments)
- POST /posts/{id}/comments (create a post comment)
[!TIP] When writing a prompt to build a feature, include relevant context: page paths, component locations, related APIs, and any patterns or examples to follow.
AI Agent Guidance
Add the following to your project's AGENTS.md to help AI agents use apifable more effectively:
## API Integration (apifable)
- Always use `get_endpoint` to verify the exact path, method, and parameters before writing integration code. Never assume.
- When presenting endpoint list data from apifable tools, display exactly these columns in order: `Method` (Uppercase), `Path`, `Summary`. Keep all values verbatim, including summary prefixes like `[ 32 - 001 ]`. Do not omit, rename, paraphrase, or add extra columns.
- When saving generated types, store them under `src/types/` and name files by domain (e.g., `src/types/auth.ts`, `src/types/user.ts`), not by OpenAPI tag names.
The above is a recommended starting point. Feel free to adjust the endpoint list columns and the types folder path to match your project.
MCP Tools Reference
get_spec_info
Returns the API title, version, description, servers, and all tags with their endpoint counts. Start here to understand the shape of an unfamiliar spec.
list_endpoints_by_tag
Inputs:
tag(string): The tag name to filter bylimit(number, optional): Max endpoints to returnoffset(number, optional): Number of endpoints to skip (default: 0)
Returns all endpoints belonging to the given tag. The response includes total, offset, and hasMore fields for pagination. Includes a warning when results exceed 30 items and no limit is specified.
search_endpoints
Inputs:
query(string): Keyword to search fortag(string, optional): Restrict search to a specific taglimit(number, optional): Max results to return (default: 10)
Keyword search across operationId, path, summary, and description. Results are ranked by relevance. If no exact matches are found, automatically falls back to fuzzy search. The response includes a matchType field ("exact" or "fuzzy"); fuzzy results also include a score field per result.
get_endpoint
Inputs (choose one):
method(string) +path(string): HTTP method and endpoint path (e.g.get+/users/{id})operationId(string): Operation ID (e.g.listUsers)
Returns the full endpoint object, including parameters, requestBody, and responses, with supported internal component $refs resolved inline.
search_schemas
Inputs:
query(string): Keyword to search forlimit(number, optional): Max results to return (default: 10)
Keyword search across schema name and description. Results are ranked by relevance. If no exact matches are found, automatically falls back to fuzzy search. The response includes a matchType field ("exact" or "fuzzy"); fuzzy results also include a score field per result. Empty results may also include a message field with guidance for the next step.
get_schema
Inputs:
name(string): Schema name fromcomponents/schemas
Returns the full schema with supported internal component $refs resolved.
get_types
Inputs (choose one mode):
schemas(string[]): Array of schema names fromcomponents/schemasmethod(string) +path(string): HTTP method and endpoint pathoperationId(string): Operation ID (e.g.listUsers)
Generates self-contained TypeScript declarations as code text. In endpoint mode it follows supported internal component $refs before collecting schema dependencies. It automatically includes transitive dependencies and does not include import statements.
Mode rules:
- Use exactly one mode per call:
schemas,method+path, oroperationId - Do not mix modes in the same call
Limitations
- External
$refs (e.g. references to other files or URLs) are not supported. - OpenAPI 2.0 (Swagger) is not supported. Only OpenAPI 3.0 and 3.1 specs are supported.
Sponsor
If you think this package has helped you, please consider Becoming a sponsor to support my work~ and your avatar will be visible on my major projects.
<p align="center"> <a href="https://www.patreon.com/ycs77"> <img src="https://cdn.jsdelivr.net/gh/ycs77/static/sponsors.svg" alt="Sponsors" /> </a> </p>
<a href="https://www.patreon.com/ycs77"> <img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Become a Patron" /> </a>
Credits
- @reapi/mcp-openapi — for the initial inspiration
License
Star History
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。