YApi MCP server

Integrates with YApi for API management, enabling seamless access to API documentation for tasks like code generation, testing, and integration planning.
Back to servers
Setup instructions
Provider
lzsheng
Release date
Mar 05, 2025
Language
TypeScript
Stats
16 stars

Yapi Auto MCP Server allows you to interact with YApi API documentation directly through AI programming tools like Cursor that support the Model Context Protocol (MCP). It creates a seamless bridge between your AI coding environment and YApi interface management platform.

Installation Options

Using npx (Recommended)

The easiest way to use Yapi Auto MCP Server is with npx, which doesn't require any installation:

  1. First, get your YApi Token from your YApi platform's project settings
  2. Configure your MCP-enabled tool (like Cursor) with the following settings:
{
  "mcpServers": {
    "yapi-auto-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "yapi-auto-mcp",
        "--stdio",
        "--yapi-base-url=https://your-yapi-domain.com",
        "--yapi-token=projectId:your_token_here"
      ]
    }
  }
}

Using Environment Variables

You can also configure the server using environment variables:

{
  "mcpServers": {
    "yapi-auto-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "yapi-auto-mcp",
        "--stdio"
      ],
      "env": {
        "YAPI_BASE_URL": "https://yapi.example.com",
        "YAPI_TOKEN": "projectId:token1,projectId2:token2",
        "YAPI_CACHE_TTL": "10",
        "YAPI_LOG_LEVEL": "info"
      }
    }
  }
}

Local Development Mode

For developers who need to customize the server:

  1. Clone and install dependencies:
git clone <repository-url>
cd yapi-mcp
pnpm install
  1. Create a .env file in the project root with your configuration:
YAPI_BASE_URL=https://your-yapi-domain.com
YAPI_TOKEN=projectId:your_token_here,projectId2:your_token2_here
PORT=3388
YAPI_CACHE_TTL=10
YAPI_LOG_LEVEL=info
  1. Start the server in SSE mode (HTTP service):
pnpm run dev

Then configure in Cursor:

{
  "mcpServers": {
    "yapi-mcp": {
      "url": "http://localhost:3388/sse"
    }
  }
}

Usage Guide

Getting Your YApi Token

  1. Log in to your YApi platform
  2. Navigate to project settings
  3. Generate or view your token in the Token configuration section

Token format:

  • Single project: projectId:token
  • Multiple projects: projectId1:token1,projectId2:token2

Example Commands

Once configured, you can use these commands in your AI tool:

  1. Search interfaces:

    "Find all user login related interfaces"

  2. View interface details:

    "Show detailed information for the user registration interface"

  3. Create new interface:

    "Create a new interface for getting user lists, with path /api/users using GET method"

  4. Update interface:

    "Update the user login interface to add a verification code parameter"

Advanced Configuration

Command-line Arguments

Parameter Description Example Default
--yapi-base-url YApi server base URL --yapi-base-url=https://yapi.example.com -
--yapi-token YApi project tokens --yapi-token=1026:token1,1027:token2 -
--yapi-cache-ttl Cache duration (minutes) --yapi-cache-ttl=10 10
--yapi-log-level Log level --yapi-log-level=info info
--port HTTP service port (SSE mode) --port=3388 3388
--stdio Enable stdio mode (required for MCP) --stdio -

Log Levels

  • debug: Outputs all logs including detailed debug information
  • info: Outputs info, warning, and error logs (default)
  • warn: Only outputs warning and error logs
  • error: Only outputs error logs
  • none: No logs output

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "yapi-mcp" '{"url":"http://localhost:3388/sse"}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "yapi-mcp": {
            "url": "http://localhost:3388/sse"
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "yapi-mcp": {
            "url": "http://localhost:3388/sse"
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later