The ApiFox MCP Server is a service that integrates with Cursor via the Model Context Protocol (MCP) to provide access to ApiFox interface information. This allows large language models to utilize your API documentation when helping you implement business logic in Cursor.
The fastest way to get started is using npx:
npx @wangmhaha/apifox-mcp-server@latest --apifox-api-key=<your-apifox-api-key> --project=<your-project-id>
If you prefer to install from source:
pnpm install
pnpm build
pnpm start:http
You can configure the server using environment variables. Create a .env
file in the project root by copying .env.example
:
APIFOX_API_KEY=your_api_key_here
PROJECT_ID=your_project-ID
PORT=3000 # Optional, defaults to 3000
To connect Cursor to the MCP server using SSE, add the following to your Cursor MCP configuration:
"apifox-mcp-server": {
"url": "http://localhost:3000/sse"
}
For a more complete setup, use the command configuration approach:
"apifox-mcp-server": {
"command": "npx",
"args": ["-y", "@wangmhaha/apifox-mcp-server@latest", "--local"],
"env": {
"APIFOX_API_KEY": "<your-apifox-api-key>",
"PROJECT_ID": "<your-project-id>"
}
}
If running the server from a local build:
"apifox-mcp-server": {
"command": "node",
"args": [
"<your-local-path>/build/index.js",
"--local"
],
"env": {
"APIFOX_API_KEY": "<your-apifox-api-key>",
"PROJECT_ID": "<your-project-id>"
}
}
The server leverages several technologies:
The server runs on port 3000 by default but can be configured using the PORT environment variable.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.