mcp-apifox-connector
A Model Context Protocol bridge enabling AI assistants to ingest and leverage detailed API specifications directly from Apifox documentation, thereby streamlining API comprehension and integration throughout the software development lifecycle.
Author

sujianqingfeng
Quick Info
Actions
Tags
Apifox MCP Connector Module
This module serves as a specialized Model Context Protocol (MCP) intermediary designed to link the Apifox API management environment with external AI reasoning agents.
Introduction
This component establishes a crucial link between the Apifox platform—a comprehensive toolset for API design, development, and testing—and any AI assistant capable of processing information via the MCP standard. Its primary function is to facilitate the seamless retrieval of rich API metadata from Apifox assets, significantly reducing friction in understanding and applying API endpoints during coding and testing phases.
Core Capabilities
- Parses and extracts requisite identifiers (Project ID, API ID) from standard Apifox URL formats.
- Fetches comprehensive API schema details from the Apifox backend using the extracted identifiers.
- Ensures native, high-fidelity data exchange with any MCP-compliant artificial intelligence entity.
Prerequisites for Operation
- An active Apifox account possessing the necessary scope permissions (e.g., read access).
- A valid Personal Access Token (PAT) generated within Apifox settings.
- An operational AI application configured to utilize the Model Context Protocol.
Installation Guide
Installation can be performed globally via package managers:
bash
Global installation via npm
npm install -g mcp-apifox-connector
Alternatively, using pnpm
pnpm add -g mcp-apifox-connector
Configuration Procedures
Configuration determines how the system authenticates and runs the connector. Two common methods are shown below:
Option A: Environment Variable Injection
Define the settings in your primary configuration file (e.g., mcp_config.json):
{ "mcpServers": { "apifox_gateway": { "command": "npx", "args": [ "-y", "mcp-apifox-connector@latest" ], "env": { "APIFOX_ACCESS_TOKEN": "YOUR_SECRET_TOKEN_HERE" } } } }
Option B: Direct Command-Line Argument Passing
Embed the token directly during the invocation command:
{ "mcpServers": { "apifox_gateway": { "command": "npx", "args": [ "-y", "mcp-apifox-connector@latest", "--token=YOUR_SECRET_TOKEN_HERE" ] } } }
Usage Patterns
Access to the underlying API documentation is granted via shared collaborative links, provided the linked user possesses 'Maintainer' or higher privileges for the target project:
https://app.apifox.com/link/project/${projectId}/apis/api-${apiId}
Available Toolset
Tool 1: URL Identifier Extraction (extract-apifox-identifiers)
This function parses input text to isolate the necessary IDs for subsequent calls.
- Input Parameter (
text): A string containing the full Apifox URL or a partial path referencing an API. - Output: A structured JSON object detailing the extracted
projectIdand the correspondingapiId.
Tool 2: API Specification Retrieval (fetch-detailed-api-spec)
This function queries the Apifox service to retrieve the full specification for a given API endpoint.
- Input Parameter (
projectId): The unique identifier for the Apifox project. - Input Parameter (
apiId): The unique identifier for the specific API resource. - Output: The complete OpenAPI (Swagger) specification document relevant to the requested API.
