Knife4j MCP Server

MCP server for querying Knife4j / Swagger multi-module API docs

Local serverstdioTypeScript

What is the Knife4j MCP server?

Knife4j MCP server is a locally run integration for AI assistants that speak the Model Context Protocol. MCP server for querying Knife4j / Swagger multi-module API docs.

What you get

一个基于 Node.js + TypeScript 的标准 MCP server(stdio),用于读取 Knife4j / Swagger 多模块接口文档,并为 Agent 提供结构化接口查询能力。

Setting it up

The server ships on npm as @chaselen/knife4j-mcp, so your MCP client can launch it on demand — there is no separate build step. Add the server block to your client's configuration, restart it, and the tools register themselves.

What the assistant can call

Once Knife4j is connected, these are the calls the assistant has available:

  • OpenCode — The OpenCode tool exposed by this server

Configuration and credentials

You will need 3 environment variables: SWAGGER_RESOURCES_URL, SWAGGER_BASIC_AUTH, SWAGGER_BASE_URL. The server will not start without them, which is usually why the tools fail to appear on a first run. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • Missing credentials fail quietly in some clients — if no tools show up, check the environment block first.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the knife4j mcp server does with a few real requests.

Choosing this one

Plenty of developer tooling servers cover similar ground. The differences that matter in practice are scope of access and how much setup stands between you and a working tool call. Knife4j's toolset — OpenCode — is a fair guide to whether it matches your workflow. It is maintained by chaselen; worth a glance at recent repository activity before you build anything load-bearing on it.

We check each listing at SyncDev against the project's documentation before it goes live — if something here drifts out of date, it is a bug worth reporting.

Available tools

ToolWhat it does
OpenCodeThe OpenCode tool exposed by this server.

How to install the Knife4j MCP server

{
  "mcpServers": {
    "knife4j-swagger": {
      "command": "npx",
      "args": ["-y", "@chaselen/knife4j-mcp"],
      "env": {
        "SWAGGER_RESOURCES_URL": "http://127.0.0.1:3301/swagger-resources",
        "SWAGGER_BASIC_AUTH": "demo:demo"
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

VariableDescriptionRequired
SWAGGER_RESOURCES_URLEndpoint or connection string the server talks to.Yes
SWAGGER_BASIC_AUTHConfiguration value read at startup.Optional
SWAGGER_BASE_URLEndpoint or connection string the server talks to.Yes

Example prompts to try

  • Use Knife4j to OpenCode.

Frequently asked questions

It connects Knife4j to MCP-compatible AI assistants such as Claude and Cursor, exposing 1 tool (OpenCode) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Knife4j directly.