MCP Swagger Server logo

MCP Swagger Server

Community
zaizaizhao

MCP Swagger Server 将任何符合 OpenAPI/Swagger 规范的 REST API 转换为 Model Context Protocol (MCP) 格式,让 AI 助手能够理解和调用您的 API。

Publisherzaizaizhao
Repositorymcp-swagger-server
LanguageTypeScript
Forks
17
Stars
76
Available tools
0
Transport typestdio
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    MCP Swagger Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    76 stars and 17 forks from the linked repository.

MCP Swagger Server(mss)

TypeScript Node.js License Trust Score

将 OpenAPI/Swagger 规范转换为 Model Context Protocol (MCP) 格式的工具

零配置将您的 REST API 转换为 AI 可调用的工具

🚀 快速开始 • 📖 使用指南 • 🛠️ 开发

Languages: English | 中文


🎬 快速演示

Demo GIF

🎯 项目截图

项目截图

🎯 项目简介

MCP Swagger Server 是一个将 OpenAPI/Swagger 规范转换为 Model Context Protocol (MCP) 格式的工具。

📦 项目结构

mcp-swagger-server/
├── packages/
│   ├── mcp-swagger-server/     # 🔧 核心 MCP 服务器 (可用)
│   ├── mcp-swagger-parser/     # 📝 OpenAPI 解析器 (可用)
│   └── mcp-swagger-api/        # 🔗 REST API 后端 (可用)
└── scripts/                    # 🔨 构建脚本

✨ 核心特性

  • 🔄 零配置转换: 输入 OpenAPI 规范,立即获得 MCP 工具
  • 🎯 渐进式命令行: 提供逐步引导的命令行界面,方便用户配置
  • 🖥️ 终端优先体验: 以 CLI / 交互式终端作为主要使用方式
  • 🔌 多传输协议: 支持 SSE、Streamable 和 Stdio 传输
  • 🔐 安全认证: 支持 Bearer Token 认证保护 API 访问

🚀 快速开始

环境要求

  • Node.js ≥ 20.0.0
  • pnpm ≥ 8.0.0 (推荐)

安装

bash
npm i mcp-swagger-server -g

命令说明

  • mss:交互式终端界面(默认)
  • mcp-swagger-server / mcp-swagger:标准命令行(适合脚本和 AI 客户端集成)
  • mss --openapi ...:直接启动模式(跳过交互界面)

说明:交互式会话模式下不支持 STDIO 启动;如需 STDIO,请使用 mss --openapi ... --transport stdio(兼容别名:mcp-swagger-server --transport stdio ...)。

快速启动

交互式启动(推荐新手)

bash
mss

一键启动(非交互)

bash
mss --openapi https://api.example.com/openapi.json \
  --operation-filter-methods GET \
  --operation-filter-methods POST \
  --transport streamable \
  --auth-type bearer \
  --bearer-token "your-token-here"

# 使用配置文件
mss --config config.json

📖 使用指南

命令行选项

bash
# 基本用法
mss [选项]

# 选项:
--openapi, -o       OpenAPI 规范的 URL 或文件路径
--transport, -t     传输协议 (stdio|sse|streamable)
--port, -p          端口号
--endpoint, -e      自定义端点路径 (默认 sse:/sse, streamable:/mcp)
--base-url          覆盖 API 基础 URL(优先级最高)
--watch, -w         监控文件变化
--env               环境变量文件路径 (.env)

# Bearer Token 认证选项:
--auth-type         认证类型 (bearer)
--bearer-token      直接指定 Bearer Token
--bearer-env        从环境变量读取 Token
--config, -c        配置文件路径
--custom-header     自定义请求头 "Key=Value" (可重复)
--custom-header-env 环境变量请求头 "Key=VAR_NAME" (可重复)
--custom-headers-config  自定义请求头配置文件 (JSON)
--debug-headers     请求头调试日志

# 操作过滤选项:
--operation-filter-methods <method>         HTTP方法过滤 (可重复) [示例: GET]
--operation-filter-paths <path>             路径过滤 (支持通配符, 可重复) [示例: /api/*]
--operation-filter-operation-ids <id>       操作ID过滤 (可重复) [示例: getUserById]
--operation-filter-status-codes <code>      状态码过滤 (可重复) [示例: 200]
--operation-filter-parameters <param>       参数过滤 (可重复) [示例: userId]

提示:如果要在 mss 中直接启动(跳过交互界面),请显式传入 --openapi 参数。若 OpenAPI 文档中的 servers.url 是相对路径(如 /v1),请优先使用远程 URL 加载文档,或显式传入 --base-url。Swagger 2.0 文档会在启动时自动转换为 OpenAPI 3.x(含 host/basePath 映射)。

Xquik API Key 请求头示例

bash
export XQUIK_API_KEY="your-xquik-api-key"
mss --openapi https://xquik.com/openapi.json \
  --base-url https://xquik.com \
  --custom-header-env x-api-key=XQUIK_API_KEY \
  --transport streamable \
  --port 3323

🔐 Bearer Token 认证

mcp-swagger-server 支持 Bearer Token 认证,可以保护需要身份验证的 API 访问。

认证方式

1. 直接指定 Token

bash
mss --auth-type bearer --bearer-token "your-token-here" --openapi https://api.example.com/openapi.json --transport streamable

环境变量配置

创建 .env 文件:

env
# 基础配置
MCP_PORT=3322
MCP_TRANSPORT=stdio
MCP_OPENAPI_URL=https://api.example.com/openapi.json
MCP_ENDPOINT=/mcp
MCP_BASE_URL=https://api.example.com/v1

# 认证配置
MCP_AUTH_TYPE=bearer
API_TOKEN=your-bearer-token-here

🤖 与 AI 助手集成

Claude Desktop 配置

json
{
  "mcpServers": {
    "swagger-converter": {
      "command": "mss",
      "args": [
        "--openapi", "https://petstore.swagger.io/v2/swagger.json",
        "--transport", "stdio"
      ]
    },
    "secured-api": {
      "command": "mss",
      "args": [
        "--openapi", "https://api.example.com/openapi.json",
        "--transport", "stdio",
        "--auth-type", "bearer",
        "--bearer-env", "API_TOKEN"
      ],
      "env": {
        "API_TOKEN": "your-bearer-token-here"
      }
    }
  }
}

🛠️ 开发

构建系统

bash
# 构建所有包
pnpm build

# 构建核心工作区包
pnpm build:packages

# 终端开发模式(CLI / parser watch)
pnpm dev

# 清理构建产物
pnpm clean

🤝 贡献

欢迎贡献!请先阅读 贡献指南。

📄 许可证

MIT License - 详见 LICENSE 文件。


Built with ❤️ by ZhaoYaNan(ZTE)

⭐ Star • 🐛 Issues • 💬 Discussions

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "your-username-mcp-swagger-server": {
      "command": "",
      "args": []
    }
  }
}

Use MCP Swagger Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP Swagger Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP Swagger Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP Swagger Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "your-username-mcp-swagger-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-swagger-monorepo"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP Swagger Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP Swagger Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP Swagger Server to help me with this task?
MCP Swagger Server
Sure. I read it.
Here is what I found using MCP Swagger Server.

Frequently asked questions

What is the MCP Swagger Server MCP server used for?

MCP Swagger Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP Swagger Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP Swagger Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP Swagger Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP Swagger Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP Swagger Server MCP to TypingMind?

MCP Swagger Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCP Swagger Server MCP provide in TypingMind?

MCP Swagger Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP Swagger Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP Swagger Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇